tree: 9a0961b232e5723b43f1173e259871b281d7bafe [path history] [tgz]
  1. test/
  2. .eslintrc
  3. .jscs.json
  4. .npmignore
  5. .travis.yml
  6. CHANGELOG.md
  7. implementation.js
  8. index.js
  9. LICENSE
  10. Makefile
  11. package.json
  12. polyfill.js
  13. README.md
  14. shim.js
PoCs/nodejs_poc/node_modules/string.prototype.trim/README.md

String.prototype.trim Version Badge

Build Status dependency status dev dependency status License Downloads

npm badge

browser support

An ES5 spec-compliant String.prototype.trim shim. Invoke its “shim” method to shim String.prototype.trim if it is unavailable.

This package implements the es-shim API interface. It works in an ES3-supported environment and complies with the spec.

Most common usage:

var assert = require('assert');
var trim = require('string.prototype.trim');

assert(trim(' \t\na \t\n') === 'a');

trim.shim(); // will be a no-op if not needed

assert(trim(' \t\na \t\n') === ' \t\na \t\n'.trim());

Engine Bugs

Some implementations of String#trim incorrectly trim zero-width spaces. This shim detects and corrects this behavior.

Tests

Simply clone the repo, npm install, and run npm test