1 | var toIndexedObject = require('../internals/to-indexed-object');
|
2 | var toLength = require('../internals/to-length');
|
3 | var toAbsoluteIndex = require('../internals/to-absolute-index');
|
4 |
|
5 |
|
6 | var 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 |
|
13 |
|
14 | if (IS_INCLUDES && el != el) while (length > index) {
|
15 | value = O[index++];
|
16 |
|
17 | if (value != value) return true;
|
18 |
|
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 |
|
25 | module.exports = {
|
26 |
|
27 |
|
28 | includes: createMethod(true),
|
29 |
|
30 |
|
31 | indexOf: createMethod(false)
|
32 | };
|