0.1.1 • Published 5 years ago

@utilities/string v0.1.1

Weekly downloads
-
License
MIT
Repository
github
Last release
5 years ago

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](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/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

0.1.0

5 years ago

0.1.1

5 years ago

0.0.22

5 years ago

0.0.21

5 years ago

0.0.20

6 years ago

0.0.19

6 years ago

0.0.18

6 years ago

0.0.17

6 years ago

0.0.16

6 years ago

0.0.15

6 years ago

0.0.14

6 years ago

0.0.13

6 years ago

0.0.12

6 years ago

0.0.11

6 years ago

0.0.10

6 years ago

0.0.9

6 years ago

0.0.8

6 years ago

0.0.7

6 years ago

0.0.6

6 years ago

0.0.5

6 years ago

0.0.4

6 years ago

0.0.3

6 years ago

0.0.2

6 years ago

0.0.1

6 years ago

0.0.0

6 years ago