An ES-spec-compliant String.prototype.substr
shim/polyfill/replacement that works as far down as ES3.
This package implements the es-shim API interface. It works in an ES3-supported environment and complies with the spec.
npm install --save string.prototype.substr
var assert = require('assert');
var substr = require('string.prototype.substr');
assert(substr('abc', 1) === 'bc');
substr.shim(); // will be a no-op if not needed
assert(substr(' \t\na \t\n') === ' \t\na \t\n'.substr());
Clone the repo, npm install
, and run npm test