|
|
6 anos atrás | |
|---|---|---|
| .. | ||
| test | 6 anos atrás | |
| .eslintrc | 6 anos atrás | |
| .jscs.json | 6 anos atrás | |
| .npmignore | 6 anos atrás | |
| .travis.yml | 6 anos atrás | |
| CHANGELOG.md | 6 anos atrás | |
| LICENSE | 6 anos atrás | |
| Makefile | 6 anos atrás | |
| README.md | 6 anos atrás | |
| implementation.js | 6 anos atrás | |
| index.js | 6 anos atrás | |
| package.json | 6 anos atrás | |
| polyfill.js | 6 anos atrás | |
| shim.js | 6 anos atrás | |
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());
Some implementations of String#trim incorrectly trim zero-width spaces. This shim detects and corrects this behavior.
Simply clone the repo, npm install, and run npm test