This is a
playground to test code. It runs a full
Node.js environment and already has all of
npm’s 400,000 packages pre-installed, including
string.prototype.trim with all
npm packages installed. Try it out:
This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.
An ES5 spec-compliant
String.prototype.trim shim. Invoke its "shim" method to shim
String.prototype.trim if it is unavailable.
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