var shim;
try {
shim = require('./shim-es4');
} catch (e) {
// Probably excluded via browserify -u lib/shim-es4.js
shim = {};
}
var prototypes = {
bind: Function.prototype.bind,
every: Array.prototype.every,
some: Array.prototype.some,
indexOf: Array.prototype.indexOf,
forEach: Array.prototype.forEach,
map: Array.prototype.map,
filter: Array.prototype.filter,
reduce: Array.prototype.reduce,
trim: String.prototype.trim
};
function createShimMethod(key) {
shim[key] = function (obj) {
var args = Array.prototype.slice.call(arguments, 1);
return prototypes[key].apply(obj, args);
};
}
for (var key in prototypes) {
Eif (prototypes.hasOwnProperty(key) && prototypes[key]) {
createShimMethod(key);
}
}
Iif (!shim.bind) {
shim.bind = function (fn, scope) {
return function () {
return fn.apply(scope, arguments);
};
};
}
Eif (Object.keys) {
shim['getKeys'] = Object.keys;
}
Eif ('object' === typeof JSON && JSON.parse && JSON.stringify) {
shim['JSON'] = JSON;
}
module.exports = shim;
|