source: trip-planner-front/node_modules/core-js/internals/array-last-index-of.js

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

initial commit

  • Property mode set to 100644
File size: 1.2 KB
Line 
1'use strict';
2/* eslint-disable es/no-array-prototype-lastindexof -- safe */
3var toIndexedObject = require('../internals/to-indexed-object');
4var toInteger = require('../internals/to-integer');
5var toLength = require('../internals/to-length');
6var arrayMethodIsStrict = require('../internals/array-method-is-strict');
7
8var min = Math.min;
9var $lastIndexOf = [].lastIndexOf;
10var NEGATIVE_ZERO = !!$lastIndexOf && 1 / [1].lastIndexOf(1, -0) < 0;
11var STRICT_METHOD = arrayMethodIsStrict('lastIndexOf');
12var FORCED = NEGATIVE_ZERO || !STRICT_METHOD;
13
14// `Array.prototype.lastIndexOf` method implementation
15// https://tc39.es/ecma262/#sec-array.prototype.lastindexof
16module.exports = FORCED ? function lastIndexOf(searchElement /* , fromIndex = @[*-1] */) {
17 // convert -0 to +0
18 if (NEGATIVE_ZERO) return $lastIndexOf.apply(this, arguments) || 0;
19 var O = toIndexedObject(this);
20 var length = toLength(O.length);
21 var index = length - 1;
22 if (arguments.length > 1) index = min(index, toInteger(arguments[1]));
23 if (index < 0) index = length + index;
24 for (;index >= 0; index--) if (index in O && O[index] === searchElement) return index || 0;
25 return -1;
26} : $lastIndexOf;
Note: See TracBrowser for help on using the repository browser.