string-tools
Some useful functions for working with strings
Last updated 12 years ago by 75lb .
Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install string-tools 
SYNC missed versions from official npm registry.

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

string-tools

Example

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

s.symbol

some cross platform symbols (tick and cross)

Kind: static property of string-tools

s.escapeRegExp()

escape special regular expression characters

Kind: static method of string-tools
Example

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

s.fill(fillWith, len) ⇒ string

Create a new string filled with the supplied character

Kind: static method of string-tools

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

Example

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

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

Add padding to the right of a string

Kind: static method of string-tools

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

Example

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

s.repeat(input, times) ⇒ string

returns the input string repeated the specified number of times

Kind: static method of string-tools

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

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

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

Kind: static method of string-tools

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

© 2015 Lloyd Brookes <75pound@gmail.com>. Documented by jsdoc-to-markdown.

Current Tags

  • 1.0.0                                ...           latest (11 years ago)

6 Versions

  • 1.0.0                                ...           11 years ago
  • 0.1.8                                ...           11 years ago
  • 0.1.7                                ...           11 years ago
  • 0.1.6                                ...           11 years ago
  • 0.1.5                                ...           12 years ago
  • 0.1.4                                ...           12 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 1
Dependencies (0)
None
Dev Dependencies (1)

Copyright 2013 - present © cnpmjs.org | Home |