0.11.0 • Published 6 years ago

karmia-utility-string v0.11.0

Weekly downloads
2
License
MIT
Repository
github
Last release
6 years ago

karmia-utility-string

Karmia utility string module

Usage

const karmia_utility_string = require('karmia-utility-string').default,
    kstring = new karmia_utility_string();

strip

  • string <string>
  • mask_character <string> Default: " \t\n\r\0\x0B"
// Strip whitespaces
const string = '    Hello, world.    ';
kstring.strip(string);

// Strip specified characters
const string = '"Hello, world."';
kstring.strip(string, '"');

lstrip

  • string <string>
  • mask_character <string> Default: " \t\n\r\0\x0B"
// Strip whitespaces
const string = '    Hello, world.';
kstring.lstrip(string);

// Strip specified characters
const string = '"Hello, world.';
kstring.lstrip(string, '"');

rstrip

  • string <string>
  • mask_character <string> Default: " \t\n\r\0\x0B"
// Strip whitespaces
const string = 'Hello, world.    ';
kstring.rstrip(string);

// Strip specified characters
const string = 'Hello, world."';
kstring.rstrip(string, '"');

normalize

  • string <string>
  • form <string> Default: "NFKC"
const string = '\u202b123\r\nABC\rdef\nアイウエオガ';
kstring.normalize(string); // Return: '123\nABC\ndef\nアイウエオガ'

unquote

  • string <string>
const string = '"Hello, world."';
kstring.unquote(string);

zfill

  • string <string>
  • width <number>
  • encoding <string>
const string = '1';
kstring.zfill(string, 3);

camelCase

  • string <string>
  • capitalize <boolean> Default: false
const string = 'snake_case_string';
kstring.camelCase(string);

snakeCase

  • string <string>
const string = 'camelCaseString';
kstring.snakeCase(string);

kebabCase

  • string <string>
const string = 'camelCaseString';
kstring.kebabCase(string);

parse

  • string <string>
  • delimiter <string/regexp> Default: /,? /
  • separator <string/regexp> Default: =
const string = 'key1=value1, key2=value2';
kstring.parse(string, /,? /, '=');

toBoolean

  • string <string>
// Should be true
kstring.toBoolean('true');
kstring.toBoolean('True');
kstring.toBoolean('TRUE');
kstring.toBoolean('0');
kstring.toBoolean(1);
kstring.toBoolean(true);
kstring.toBoolean('false_1');

// Should be false
kstring.toBoolean('false');
kstring.toBoolean('False');
kstring.toBoolean('FALSE');
kstring.toBoolean('');
kstring.toBoolean(0);
kstring.toBoolean(false);
0.11.0

6 years ago

0.10.3

8 years ago

0.10.2

8 years ago

0.10.1

8 years ago

0.10.0

8 years ago

0.9.8

8 years ago

0.9.7

8 years ago

0.9.6

8 years ago

0.9.5

8 years ago

0.9.4

8 years ago

0.9.3

8 years ago

0.9.2

8 years ago

0.9.1

8 years ago

0.9.0

8 years ago

0.8.1

8 years ago

0.8.0

8 years ago

0.7.4

8 years ago

0.7.3

8 years ago

0.7.2

9 years ago

0.7.1

9 years ago

0.7.0

9 years ago

0.6.0

10 years ago

0.5.2

10 years ago

0.5.1

10 years ago

0.5.0

10 years ago

0.4.0

10 years ago

0.3.1

10 years ago

0.3.0

10 years ago

0.2.0

10 years ago

0.1.1

10 years ago

0.1.0

10 years ago