string-operations

0.1.4 • Public • Published

stringOperations

This library will do operation on string like padLeft, padRight, replaceAll and truncate.

Installation

$ npm install string-operations

API

var stringOps = require('string-operations');

padRight and padLeft

 
options     one or more of the following:
   value      data which you want to pad- default value will be empty string ''
   padChar    pad character which you want to append the value default value will be white space ' '
   maxLength  Total length of data after padding
 
var options = {
   value: 'abcde',
   padChar: ' ',
   maxLength: '7'
 };
 
var result = stringOps.padRight(options);
console.log(result);
 
// prints 'abcde  '
 
var options = {
   value: 'abcde',
   padChar: '0',
   maxLength: '7'
 };
 
var result = stringOps.padLeft(options);
console.log(result);
 
// prints '00abcde'

replaceAll

 
obj:
   value:    input data where you want to replace character
   repTo:    character you want to replace
   repWith:  Character with whom you want to replace
 
 
var obj = {
  value: 'abcdefga',
  repTo: 'a',
  repWith: 'A'
};
 
 var result = stringOperation.replaceAll(obj);
 console.log(result);
 
 // prints AbcdefgA

truncate

 
value:        input data where you want to truncate
maxLength:    maxLength you want
 
var result = stringOperation.truncate('abcd', 3);
console.log(result);
 
// prints abc

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 0.1.4
    0
    • latest

Version History

  • Version
    Downloads (Last 7 Days)
    • Published
  • 0.1.4
    0
  • 0.0.4
    0
  • 0.0.3
    0
  • 0.0.2
    0

Package Sidebar

Install

npm i string-operations

Weekly Downloads

0

Version

0.1.4

License

MIT

Last publish

Collaborators

  • prabhay759