array.prototype.findindex
Advanced tools
Comparing version 2.0.2 to 2.1.0
@@ -0,1 +1,14 @@ | ||
# 2.1.0 | ||
- [New] add `auto` entry point | ||
- [Fix] remove `detect` file, broken/unused in v2 | ||
- [Refactor] use split-up `es-abstract` (77% bundle size decrease) | ||
- [Performance] avoid checking `arguments` indexes beyond `arguments.length` | ||
- [Performance] inline `ES.Call` since `IsCallable` is already checked prior to the loop. | ||
- [Deps] update `define-properties` | ||
- [meta] Only apps should have lockfiles | ||
- [meta] add missing LICENSE file | ||
- [Tests] add `npm run lint` | ||
- [Tests] use shared travis-ci configs | ||
- [Tests] use `aud` in posttest | ||
# 2.0.2 | ||
@@ -2,0 +15,0 @@ - [Performance] the entry point should use the native function when compliant |
// Array.prototype.findIndex - MIT License (c) 2013 Paul Miller <http://paulmillr.com> | ||
// For all details and docs: <https://github.com/paulmillr/Array.prototype.findIndex> | ||
'use strict'; | ||
var ES = require('es-abstract/es6'); | ||
var IsCallable = require('es-abstract/2019/IsCallable'); | ||
var ToLength = require('es-abstract/2019/ToLength'); | ||
var ToObject = require('es-abstract/2019/ToObject'); | ||
module.exports = function findIndex(predicate) { | ||
var list = ES.ToObject(this); | ||
var length = ES.ToLength(list.length); | ||
if (!ES.IsCallable(predicate)) { | ||
var list = ToObject(this); | ||
var length = ToLength(list.length); | ||
if (!IsCallable(predicate)) { | ||
throw new TypeError('Array#findIndex: predicate must be a function'); | ||
} | ||
if (length === 0) return -1; | ||
var thisArg = arguments[1]; | ||
if (length === 0) { | ||
return -1; | ||
} | ||
var thisArg; | ||
if (arguments.length > 0) { | ||
thisArg = arguments[1]; | ||
} | ||
for (var i = 0, value; i < length; i++) { | ||
value = list[i]; | ||
if (ES.Call(predicate, thisArg, [value, i, list])) return i; | ||
// inlined for performance: if (Call(predicate, thisArg, [value, i, list])) return i; | ||
if (predicate.apply(thisArg, [value, i, list])) { | ||
return i; | ||
} | ||
} | ||
return -1; | ||
}; |
'use strict'; | ||
var define = require('define-properties'); | ||
var ES = require('es-abstract/es6'); | ||
var RequireObjectCoercible = require('es-abstract/2019/RequireObjectCoercible'); | ||
@@ -14,4 +14,4 @@ var implementation = require('./implementation'); | ||
var boundShim = function findIndex(array, predicate) { | ||
ES.RequireObjectCoercible(array); | ||
var boundShim = function findIndex(array, predicate) { // eslint-disable-line no-unused-vars | ||
RequireObjectCoercible(array); | ||
var args = slice.call(arguments, 1); | ||
@@ -22,4 +22,4 @@ return polyfill.apply(array, args); | ||
define(boundShim, { | ||
getPolyfill: getPolyfill, | ||
implementation: implementation, | ||
getPolyfill: getPolyfill, | ||
shim: shim | ||
@@ -26,0 +26,0 @@ }); |
{ | ||
"name": "array.prototype.findindex", | ||
"version": "2.0.2", | ||
"description": "Array.prototype.findIndex ES6 polyfill.", | ||
"version": "2.1.0", | ||
"description": "Array.prototype.findIndex ES2015 polyfill.", | ||
"keywords": [ | ||
"Array.prototype.findIndex", | ||
"findIndex", | ||
"es6" | ||
"es6", | ||
"es2015" | ||
], | ||
"main": "index.js", | ||
"scripts": { | ||
"tests-only": "es-shim-api --bound && mocha test.js", | ||
"test": "npm run tests-only" | ||
"lint": "eslint .", | ||
"pretest": "npm run lint", | ||
"tests-only": "es-shim-api --bound && mocha test", | ||
"test": "npm run tests-only", | ||
"posttest": "npx aud --production" | ||
}, | ||
@@ -25,10 +29,13 @@ "repository": { | ||
"devDependencies": { | ||
"@es-shims/api": "^1.0.0", | ||
"@es-shims/api": "^2.1.2", | ||
"@ljharb/eslint-config": "^16.0.0", | ||
"aud": "^1.0.0", | ||
"chai": "^3.5.0", | ||
"eslint": "^6.8.0", | ||
"mocha": "^2.4.5" | ||
}, | ||
"dependencies": { | ||
"define-properties": "^1.1.2", | ||
"es-abstract": "^1.5.0" | ||
"define-properties": "^1.1.3", | ||
"es-abstract": "^1.17.4" | ||
} | ||
} |
'use strict'; | ||
var implementation = require('./implementation'); | ||
module.exports = function getPolyfill() { | ||
// Detect if an implementation exists | ||
// Detect early implementations which skipped holes in sparse arrays | ||
// eslint-disable-next-line no-sparse-arrays | ||
var implemented = Array.prototype.findIndex && ([, 1].findIndex(function (item, idx) { | ||
@@ -10,4 +13,3 @@ return idx === 0; | ||
return implemented ? Array.prototype.findIndex : require('./implementation'); | ||
return implemented ? Array.prototype.findIndex : implementation; | ||
}; |
@@ -6,3 +6,3 @@ 'use strict'; | ||
module.exports = function shimArrayPrototypeFindIndex() { | ||
module.exports = function shimFindIndex() { | ||
var polyfill = getPolyfill(); | ||
@@ -9,0 +9,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
175
12698
6
1
Updateddefine-properties@^1.1.3
Updatedes-abstract@^1.17.4