Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
module.exports = function find(predicate) {
var list = ES.ToObject(this);
var length = ES.ToLength(list.length);
if (!ES.IsCallable(predicate)) {
throw new TypeError('Array#find: predicate must be a function');
}
if (length === 0) {
return void 0;
}
var thisArg;
if (arguments.length > 0) {
thisArg = arguments[1];
}
for (var i = 0, value; i < length; i++) {
value = list[i];
// inlined for performance: if (ES.Call(predicate, thisArg, [value, i, list])) {
if (predicate.apply(thisArg, [value, i, list])) {
var atShim = function at(pos) {
ES.RequireObjectCoercible(this);
var O = ES.ToObject(this);
var S = ES.ToString(O);
var position = ES.ToInteger(pos);
var size = S.length;
if (position < 0 || position >= size) {
return '';
}
// Get the first code unit and code unit value
var cuFirst = S.charCodeAt(position);
var cuSecond;
var nextIndex = position + 1;
var len = 1;
// Check if it’s the start of a surrogate pair.
var isHighSurrogate = cuFirst >= 0xD800 && cuFirst <= 0xDBFF;
if (isHighSurrogate && size > nextIndex /* there is a next code unit */) {
cuSecond = S.charCodeAt(nextIndex);
if (cuSecond >= 0xDC00 && cuSecond <= 0xDFFF) { // low surrogate
}
var items = ES.ToObject(arrayLike);
var mapFn, T;
if (typeof arguments[1] !== 'undefined') {
mapFn = arguments[1];
if (!ES.IsCallable(mapFn)) {
throw new TypeError('When provided, the second argument to `Array.from` must be a function');
}
if (arguments.length > 2) {
T = arguments[2];
}
}
var len = ES.ToLength(items.length);
var A = ES.IsCallable(C) ? ES.ToObject(new C(len)) : new Array(len);
var k = 0;
var kValue, mappedValue;
while (k < len) {
kValue = items[k];
if (mapFn) {
mappedValue = typeof T === 'undefined' ? mapFn(kValue, k) : ES.Call(mapFn, T, [kValue, k]);
} else {
mappedValue = kValue;
}
defineProperty(A, k, {
'configurable': true,
'enumerable': true,
'value': mappedValue,
'writable': true
});
k += 1;
throw new TypeError('`Array.from` requires an array-like object, not `null` or `undefined`');
}
var mapFn, T;
if (typeof arguments[1] !== 'undefined') {
mapFn = arguments[1];
if (!ES.IsCallable(mapFn)) {
throw new TypeError('When provided, the second argument to `Array.from` must be a function');
}
if (arguments.length > 2) {
T = arguments[2];
}
}
var arrayLike = ES.ToObject(parseIterableLike(items));
var len = ES.ToLength(arrayLike.length);
var A = ES.IsCallable(C) ? ES.ToObject(new C(len)) : new Array(len);
var k = 0;
var kValue, mappedValue;
while (k < len) {
kValue = arrayLike[k];
if (mapFn) {
mappedValue = typeof T === 'undefined' ? mapFn(kValue, k) : ES.Call(mapFn, T, [kValue, k]);
} else {
mappedValue = kValue;
}
defineProperty(A, k, {
'configurable': true,
'enumerable': true,
'value': mappedValue,
'writable': true
});
var C = this;
if (items === null || typeof items === 'undefined') {
throw new TypeError('`Array.from` requires an array-like object, not `null` or `undefined`');
}
var mapFn, T;
if (typeof arguments[1] !== 'undefined') {
mapFn = arguments[1];
if (!ES.IsCallable(mapFn)) {
throw new TypeError('When provided, the second argument to `Array.from` must be a function');
}
if (arguments.length > 2) {
T = arguments[2];
}
}
var arrayLike = ES.ToObject(parseIterableLike(items));
var len = ES.ToLength(arrayLike.length);
var A = ES.IsCallable(C) ? ES.ToObject(new C(len)) : new Array(len);
var k = 0;
var kValue, mappedValue;
while (k < len) {
kValue = arrayLike[k];
if (mapFn) {
mappedValue = typeof T === 'undefined' ? mapFn(kValue, k) : ES.Call(mapFn, T, [kValue, k]);
} else {
mappedValue = kValue;
}
defineProperty(A, k, {
'configurable': true,
'enumerable': true,
'value': mappedValue,
module.exports = function includes(searchElement) {
var fromIndex = arguments.length > 1 ? ES.ToInteger(arguments[1]) : 0;
if (indexOf && !$isNaN(searchElement) && $isFinite(fromIndex) && typeof searchElement !== 'undefined') {
return indexOf.apply(this, arguments) > -1;
}
var O = ES.ToObject(this);
var length = ES.ToLength(O.length);
if (length === 0) {
return false;
}
var k = fromIndex >= 0 ? fromIndex : Math.max(0, length + fromIndex);
while (k < length) {
if (ES.SameValueZero(searchElement, O[k])) {
return true;
}
k += 1;
}
return false;
};
module.exports = function from(arrayLike) {
var defineProperty = supportsDescriptors ? Object.defineProperty : function put(object, key, descriptor) {
object[key] = descriptor.value;
};
var C = this;
if (arrayLike === null || typeof arrayLike === 'undefined') {
throw new TypeError('`Array.from` requires an array-like object, not `null` or `undefined`');
}
var items = ES.ToObject(arrayLike);
var mapFn, T;
if (typeof arguments[1] !== 'undefined') {
mapFn = arguments[1];
if (!ES.IsCallable(mapFn)) {
throw new TypeError('When provided, the second argument to `Array.from` must be a function');
}
if (arguments.length > 2) {
T = arguments[2];
}
}
var len = ES.ToLength(items.length);
var A = ES.IsCallable(C) ? ES.ToObject(new C(len)) : new Array(len);
var k = 0;
var kValue, mappedValue;
module.exports = function findIndex(predicate) {
var list = ES.ToObject(this);
var length = ES.ToLength(list.length);
if (!ES.IsCallable(predicate)) {
throw new TypeError('Array#findIndex: predicate must be a function');
}
if (length === 0) {
return -1;
}
var thisArg;
if (arguments.length > 0) {
thisArg = arguments[1];
}
for (var i = 0, value; i < length; i++) {
value = list[i];
module.exports = function getOwnPropertyDescriptors(value) {
ES.RequireObjectCoercible(value);
if (!isES5) {
throw new TypeError('getOwnPropertyDescriptors requires Object.getOwnPropertyDescriptor');
}
var O = ES.ToObject(value);
return reduce(getAll(O), function (acc, key) {
var descriptor = getDescriptor(O, key);
if (typeof descriptor !== 'undefined') {
safePut(acc, key, descriptor);
}
return acc;
}, {});
};