JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 27005
  • Score
    100M100P100Q38879F

Some useful functions for working with strings

Package Exports

  • string-tools

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (string-tools) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

view on npm npm module downloads per month Build Status Dependency Status

string-tools

Example

var s = require("string-tools");

string-tools.symbol

some cross platform symbols (tick and cross)

string-tools.escapeRegExp()

escape special regular expression characters

Example

> w.escapeRegExp("(.*)");
'\\(\\.\\*\\)'

string-tools.fill(fillWith, len) ⇒ string

Create a new string filled with the supplied character

Param Type Description
fillWith string the fill character
len number the length of the output string

Example

> w.fill("a", 10)
'aaaaaaaaaa'
> w.fill("ab", 10)
'aaaaaaaaaa'

string-tools.padRight(input, width, [padWith]) ⇒ string

Add padding to the right of a string

Param Type Default Description
input string the string to pad
width number the desired final width
[padWith] string "" "" the padding character

Example

> w.padRight("clive", 1)
'clive'
> w.padRight("clive", 1, "-")
'clive'
> w.padRight("clive", 10, "-")
'clive-----'

string-tools.repeat(input, times) ⇒ string

returns the input string repeated the specified number of times

Param Type Description
input string input string to repeat
times number the number of times to repeat

string-tools.clipLeft(input, width, [prefix]) ⇒ string

returns the input string clipped from the left side in order to meet the specified width

Param Type Default Description
input string input string to repeat
width number the desired final width
[prefix] string "..." the prefix to replace the clipped region