main
Last change
on this file since d565449 was d565449, checked in by stefan toskovski <stefantoska84@…>, 4 weeks ago |
Update repo after prototype presentation
|
-
Property mode
set to
100644
|
File size:
1.3 KB
|
Rev | Line | |
---|
[d565449] | 1 | 'use strict';
|
---|
| 2 |
|
---|
| 3 | var ToIntegerOrInfinity = require('es-abstract/2024/ToIntegerOrInfinity');
|
---|
| 4 | var ToLength = require('es-abstract/2024/ToLength');
|
---|
| 5 | var ToObject = require('es-object-atoms/ToObject');
|
---|
| 6 | var SameValueZero = require('es-abstract/2024/SameValueZero');
|
---|
| 7 | var $isNaN = require('es-abstract/helpers/isNaN');
|
---|
| 8 | var $isFinite = require('es-abstract/helpers/isFinite');
|
---|
| 9 | var GetIntrinsic = require('get-intrinsic');
|
---|
| 10 | var callBound = require('call-bind/callBound');
|
---|
| 11 | var isString = require('is-string');
|
---|
| 12 |
|
---|
| 13 | var $charAt = callBound('String.prototype.charAt');
|
---|
| 14 | var $indexOf = GetIntrinsic('%Array.prototype.indexOf%'); // TODO: use callBind.apply without breaking IE 8
|
---|
| 15 | var $max = GetIntrinsic('%Math.max%');
|
---|
| 16 |
|
---|
| 17 | module.exports = function includes(searchElement) {
|
---|
| 18 | var fromIndex = arguments.length > 1 ? ToIntegerOrInfinity(arguments[1]) : 0;
|
---|
| 19 | if ($indexOf && !$isNaN(searchElement) && $isFinite(fromIndex) && typeof searchElement !== 'undefined') {
|
---|
| 20 | return $indexOf.apply(this, arguments) > -1;
|
---|
| 21 | }
|
---|
| 22 |
|
---|
| 23 | var O = ToObject(this);
|
---|
| 24 | var length = ToLength(O.length);
|
---|
| 25 | if (length === 0) {
|
---|
| 26 | return false;
|
---|
| 27 | }
|
---|
| 28 | var k = fromIndex >= 0 ? fromIndex : $max(0, length + fromIndex);
|
---|
| 29 | while (k < length) {
|
---|
| 30 | if (SameValueZero(searchElement, isString(O) ? $charAt(O, k) : O[k])) {
|
---|
| 31 | return true;
|
---|
| 32 | }
|
---|
| 33 | k += 1;
|
---|
| 34 | }
|
---|
| 35 | return false;
|
---|
| 36 | };
|
---|
Note:
See
TracBrowser
for help on using the repository browser.