Quick module to trim any characters from either side of a string.
JavaScript
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
.gitignore
.travis.yml
Readme.md
index.js
package.json
test.js

Readme.md

Trimmer

NPM version Build status Test coverage Gittip

Trim any characters from either side of a string.

Installation

npm install trimmer --save

API

var trim = require('trimmer');
  • trim(string [, characters])
  • trim.left(string [, characters])
  • trim.right(string [, characters])

Please note: characters can be one of either an string, array or function.

trim('  test  ') // 'test'
trim.left('  test  ') // 'test  '
trim.right('  test  ') // '  test'

trim('test', 't') // 'es'
trim('testing', 'ing') // 'test'
trim.left('test', 't') // 'est'
trim.right('test', 't') // 'tes'

License

MIT