Code coverage report for lib/shim.js

Statements: 80.95% (17 / 21)      Branches: 69.23% (9 / 13)      Functions: 50% (2 / 4)      Lines: 80.95% (17 / 21)      Ignored: none     

All files » lib/ » shim.js
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 501 1 1         1                       1 9 31458 31458       1 9 9       1               1 1     1 1     1  
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;