source: trip-planner-front/node_modules/core-js/internals/array-includes.js@ e29cc2e

Last change on this file since e29cc2e was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 1.3 KB
Line 
1var toIndexedObject = require('../internals/to-indexed-object');
2var toLength = require('../internals/to-length');
3var toAbsoluteIndex = require('../internals/to-absolute-index');
4
5// `Array.prototype.{ indexOf, includes }` methods implementation
6var createMethod = function (IS_INCLUDES) {
7 return function ($this, el, fromIndex) {
8 var O = toIndexedObject($this);
9 var length = toLength(O.length);
10 var index = toAbsoluteIndex(fromIndex, length);
11 var value;
12 // Array#includes uses SameValueZero equality algorithm
13 // eslint-disable-next-line no-self-compare -- NaN check
14 if (IS_INCLUDES && el != el) while (length > index) {
15 value = O[index++];
16 // eslint-disable-next-line no-self-compare -- NaN check
17 if (value != value) return true;
18 // Array#indexOf ignores holes, Array#includes - not
19 } else for (;length > index; index++) {
20 if ((IS_INCLUDES || index in O) && O[index] === el) return IS_INCLUDES || index || 0;
21 } return !IS_INCLUDES && -1;
22 };
23};
24
25module.exports = {
26 // `Array.prototype.includes` method
27 // https://tc39.es/ecma262/#sec-array.prototype.includes
28 includes: createMethod(true),
29 // `Array.prototype.indexOf` method
30 // https://tc39.es/ecma262/#sec-array.prototype.indexof
31 indexOf: createMethod(false)
32};
Note: See TracBrowser for help on using the repository browser.