UNPKG

raptor-polyfill

Version:

Polyfills for various EcmaScript 5 and EcmaScript 6 methods distributed as CommonJS modules that can be require'd individually or as a whole.

24 lines (21 loc) 782 B
// ES5 15.4.4.19 // http://es5.github.com/#x15.4.4.19 // https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Objects/Array/map if (!Array.prototype.map) { var toObject = require('./_toObject'); Array.prototype.map = function map(fun /*, thisp*/) { var self = toObject(this), length = self.length >>> 0, result = new Array(length), thisp = arguments[1]; // If no callback function or if callback is not a callable function if (typeof fun !== 'function') { throw new TypeError(fun + " is not a function"); } for (var i = 0; i < length; i++) { if (i in self) result[i] = fun.call(thisp, self[i], i, self); } return result; }; }