JSPM

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

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 Some useful functions for working with strings

Contents

###s.symbol some cross platform symbols (tick and cross)

###escapeRegExp() escape special regular expression characters

####Example

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

###fill(fillWith, len) Create a new string filled with the supplied character

  • fillWith string the fill character
  • len number the length of the output string

Returns: string

####Example

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

###padRight(input, width, [padWith]) Add padding to the right of a string

  • input string the string to pad
  • width number the desired final width
  • [padWith] string the padding character

Returns: string

####Example

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

###repeat(input, times) returns the input string repeated the specified number of times

  • input string input string to repeat
  • times number the number of times to repeat

Returns: string

###clipLeft(input, width, [prefix]) returns the input string clipped from the left side in order to meet the specified width

  • input string input string to repeat
  • width number the desired final width
  • [prefix] string the prefix to replace the clipped region

Returns: string