PageRenderTime 21ms CodeModel.GetById 11ms app.highlight 6ms RepoModel.GetById 1ms app.codeStats 1ms

/node_modules/babel-polyfill/node_modules/core-js/library/modules/_array-includes.js

https://bitbucket.org/worklabschd/bingle_customer2
JavaScript | 23 lines | 17 code | 0 blank | 6 comment | 14 complexity | 921f878797c27ded0e522898f237739e MD5 | raw file
 1// false -> Array#indexOf
 2// true  -> Array#includes
 3var toIObject = require('./_to-iobject');
 4var toLength = require('./_to-length');
 5var toAbsoluteIndex = require('./_to-absolute-index');
 6module.exports = function (IS_INCLUDES) {
 7  return function ($this, el, fromIndex) {
 8    var O = toIObject($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
14    if (IS_INCLUDES && el != el) while (length > index) {
15      value = O[index++];
16      // eslint-disable-next-line no-self-compare
17      if (value != value) return true;
18    // Array#indexOf ignores holes, Array#includes - not
19    } else for (;length > index; index++) if (IS_INCLUDES || index in O) {
20      if (O[index] === el) return IS_INCLUDES || index || 0;
21    } return !IS_INCLUDES && -1;
22  };
23};