npm.io
1.0.1 • Published 8 years ago

uc-strings

Licence
MIT
Version
1.0.1
Deps
0
Size
10 kB
Vulns
0
Weekly
0

Unchained UI

Strings

NPM Version NPM Downloads

Various functions to work with strings

Usage

Just import methods you need

import { length } from 'uc-strings'
Methods
length(str)

return the proper length of the string. Counts the actual characters and not unicode surrogate pairs

substring(str, begin, end)

return the proper substring from the string. Counts the actual characters and not unicode surrogate pairs

removeHash(str)

Removes # symbol from the beginig of the string

removeQuotes(str)

Removes ' or " quotes form the begining and end of the string

toCamelCase(str)

Transfroms _ or - cases into camelCase

pluralize(single, plural, opts)

Return the function that accepts a number and return a string with corresponded word.

Optios are:

  • zeroIsEmpty – boolean, default false. If true return empty string when number is zero.
slugify(str)

Returns slugified string

License MIT

velocityzen

Keywords