Get unlimited public & private packages + package-based permissions with npm Pro.Get started »

strings-util

1.0.0 • Public • Published

strings-util

String utility methods.

Install

$ npm install strings-util

Usage

const stringsUtil = require('strings-util');
 
stringsUtil.trim('  test  ');
// => "test"
stringsUtil.trimLeft('  test  ');
// => "test  "
stringsUtil.trimRight('  test  ');
// => "  test"
 
stringsUtil.startsWith('test string', 'test');
// => true
stringsUtil.endsWith('test string', 'string');
// => true
 
stringsUtil.capitalize('test');
// => "Test"
stringsUtil.capitalize('test string');
// => "Test String"

API

string trim(str)

Trims leading and trailing whitespace from the given string.

string trimLeft(str)

Removes whitespace from the left end of the string.

string trimRight(str)

Removes whitespace from the right end of the string.

boolean startsWith(str, prefix)

Checks whether str starts with prefix.

boolean endsWith(str, suffix)

Checks whether str ends with suffix.

string capitalize(str)

Transforms the first character of each word to uppercase; other characters are unaffected.

Resources

Install

npm i strings-util

DownloadsWeekly Downloads

7

Version

1.0.0

License

Apache-2.0

Unpacked Size

5.72 kB

Total Files

4

Last publish

Collaborators

  • avatar