es-string-html-methods
Version:
An ES-spec-compliant shim/polyfill/replacement for the Annex B String.prototype HTML methods that works as far down as ES3
19 lines (15 loc) • 380 B
JavaScript
;
var define = require('define-properties');
module.exports = function shimHelper(property, getPolyfill) {
return function shim() {
var polyfill = getPolyfill();
var o = {};
o[property] = polyfill;
var p = {};
p[property] = function () {
return String.prototype[property] !== polyfill;
};
define(String.prototype, o, p);
return polyfill;
};
};