extendscript-es5-shim
Version:
a collection of useful es5-shims for Extendscript
29 lines (24 loc) • 784 B
JavaScript
/*
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/some
*/
// Production steps of ECMA-262, Edition 5, 15.4.4.17
// Reference: http://es5.github.io/#x15.4.4.17
if (!Array.prototype.some) {
Array.prototype.some = function(callback, thisArg) {
if (this === void 0 || this === null) {
throw new TypeError('Array.prototype.some called on null or undefined');
}
if (callback.__class__ !== 'Function') {
throw new TypeError(callback + ' is not a function');
}
var t = Object(this);
var len = t.length >>> 0;
var T = arguments.length > 1 ? thisArg : void 0;
for (var i = 0; i < len; i++) {
if (i in t && callback.call(T, t[i], i, t)) {
return true;
}
}
return false;
};
}