@utilities/string
TypeScript icon, indicating that this package has built-in type declarations

0.1.1 • Public • Published

npm version Build Status Coverage Status Code Climate Inch CI

Dependency Status devDependency Status

Known Vulnerabilities

@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

Alexander

Links to package pages:

github.com   npmjs.com   travis-ci.org   coveralls.io   inch-ci.org

License

MIT

Package Sidebar

Install

npm i @utilities/string

Weekly Downloads

0

Version

0.1.1

License

MIT

Unpacked Size

25.3 kB

Total Files

9

Last publish

Collaborators

  • alykoshin