UNPKG

unexpected

Version:

Minimalistic BDD assertion toolkit inspired by [expect.js](https://github.com/LearnBoost/expect.js)

50 lines (43 loc) 1.12 kB
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) { if (prototypes.hasOwnProperty(key) && prototypes[key]) { createShimMethod(key); } } if (!shim.bind) { shim.bind = function (fn, scope) { return function () { return fn.apply(scope, arguments); }; }; } if (Object.keys) { shim['getKeys'] = Object.keys; } if ('object' === typeof JSON && JSON.parse && JSON.stringify) { shim['JSON'] = JSON; } module.exports = shim;