@utilities/string
v0.1.1
Published
Set of misc utilities for strings
Downloads
9
Readme
@utilities/string
Set of misc utilities for strings
If you have different needs regarding the functionality, please add a feature request.
Installation
npm install --save @utilities/string
Usage
Function lpad()
Returns: a string filled with characters to the specified length.
Arguments:
- s - string;
- size - string length;
- c - character that is used to fill the string to size.
Example:
const lpad = ('12345', 10, '0') => {
c = c || ' ';
if (c.length > 1) console.warn('lpad expects one padding character');
while (s.length < size) s = c + s;
return s;
};
Will print:
'0000012345'
Function repeat()
Returns: <function> a string filled with characters to the specified length.
Arguments:
- c - character that is used to fill the string to size;
- len - string length.
Example:
const repeat = (9, 10) => {
return lpad('', len, c);
};
Will print:
'9999912345'
Function lpadZeros()
Credits
Links to package pages:
github.com npmjs.com travis-ci.org coveralls.io inch-ci.org
License
MIT