first commit
This commit is contained in:
20
node_modules/array.prototype.findlast/.editorconfig
generated
vendored
Normal file
20
node_modules/array.prototype.findlast/.editorconfig
generated
vendored
Normal file
@@ -0,0 +1,20 @@
|
||||
root = true
|
||||
|
||||
[*]
|
||||
indent_style = tab
|
||||
indent_size = 4
|
||||
end_of_line = lf
|
||||
charset = utf-8
|
||||
trim_trailing_whitespace = true
|
||||
insert_final_newline = true
|
||||
max_line_length = 150
|
||||
|
||||
[CHANGELOG.md]
|
||||
indent_style = space
|
||||
indent_size = 2
|
||||
|
||||
[*.json]
|
||||
max_line_length = off
|
||||
|
||||
[Makefile]
|
||||
max_line_length = off
|
||||
37
node_modules/array.prototype.findlast/.eslintrc
generated
vendored
Normal file
37
node_modules/array.prototype.findlast/.eslintrc
generated
vendored
Normal file
@@ -0,0 +1,37 @@
|
||||
{
|
||||
"root": true,
|
||||
|
||||
"extends": "@ljharb",
|
||||
|
||||
"rules": {
|
||||
"array-bracket-newline": 0,
|
||||
"id-length": 0,
|
||||
"max-statements-per-line": [2, { "max": 2 }],
|
||||
"new-cap": [2, {
|
||||
"capIsNewExceptions": [
|
||||
"GetIntrinsic",
|
||||
"Call",
|
||||
"Get",
|
||||
"IsCallable",
|
||||
"LengthOfArrayLike",
|
||||
"RequireObjectCoercible",
|
||||
"ToBoolean",
|
||||
"ToObject",
|
||||
"ToString",
|
||||
],
|
||||
}],
|
||||
"no-magic-numbers": 0,
|
||||
},
|
||||
|
||||
"overrides": [
|
||||
{
|
||||
"files": "test/**",
|
||||
"rules": {
|
||||
"func-name-matching": 0,
|
||||
"max-lines-per-function": 0,
|
||||
"no-invalid-this": 1,
|
||||
"strict": 1,
|
||||
},
|
||||
},
|
||||
],
|
||||
}
|
||||
12
node_modules/array.prototype.findlast/.github/FUNDING.yml
generated
vendored
Normal file
12
node_modules/array.prototype.findlast/.github/FUNDING.yml
generated
vendored
Normal file
@@ -0,0 +1,12 @@
|
||||
# These are supported funding model platforms
|
||||
|
||||
github: [ljharb]
|
||||
patreon: # Replace with a single Patreon username
|
||||
open_collective: # Replace with a single Open Collective username
|
||||
ko_fi: # Replace with a single Ko-fi username
|
||||
tidelift: npm/array.prototype.findlast
|
||||
community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
|
||||
liberapay: # Replace with a single Liberapay username
|
||||
issuehunt: # Replace with a single IssueHunt username
|
||||
otechie: # Replace with a single Otechie username
|
||||
custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2']
|
||||
9
node_modules/array.prototype.findlast/.nycrc
generated
vendored
Normal file
9
node_modules/array.prototype.findlast/.nycrc
generated
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"all": true,
|
||||
"check-coverage": false,
|
||||
"reporter": ["text-summary", "text", "html", "json"],
|
||||
"exclude": [
|
||||
"coverage",
|
||||
"test"
|
||||
]
|
||||
}
|
||||
96
node_modules/array.prototype.findlast/CHANGELOG.md
generated
vendored
Normal file
96
node_modules/array.prototype.findlast/CHANGELOG.md
generated
vendored
Normal file
@@ -0,0 +1,96 @@
|
||||
# Changelog
|
||||
|
||||
All notable changes to this project will be documented in this file.
|
||||
|
||||
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
|
||||
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
||||
|
||||
## [v1.2.5](https://github.com/es-shims/Array.prototype.findLast/compare/v1.2.4...v1.2.5) - 2024-03-19
|
||||
|
||||
### Commits
|
||||
|
||||
- [meta] remove useless ESM [`30b3843`](https://github.com/es-shims/Array.prototype.findLast/commit/30b38436f06003ab2ea0a9571e3bc5bbf6d6e9fb)
|
||||
- [Deps] update `call-bind`, `es-abstract` [`f339e4d`](https://github.com/es-shims/Array.prototype.findLast/commit/f339e4d0748f32a640e58ce3282d98d1baf73269)
|
||||
- [actions] remove redundant finisher [`3b66016`](https://github.com/es-shims/Array.prototype.findLast/commit/3b66016b8f9e19084cdcafa1a125eb6b2d26f527)
|
||||
- [Refactor] use `es-object-atoms` where possible [`c7146f1`](https://github.com/es-shims/Array.prototype.findLast/commit/c7146f172d379e423abb95928ca29659d710dceb)
|
||||
- [Dev Deps] update `hasown`, `tape` [`16149a0`](https://github.com/es-shims/Array.prototype.findLast/commit/16149a0cdf6e8a78e386e435d8a6b1f83a792142)
|
||||
|
||||
## [v1.2.4](https://github.com/es-shims/Array.prototype.findLast/compare/v1.2.3...v1.2.4) - 2024-02-05
|
||||
|
||||
### Commits
|
||||
|
||||
- [Deps] update `call-bind`, `define-properties`, `es-abstract`, `es-shim-unscopables`, `get-intrinsic` [`6960289`](https://github.com/es-shims/Array.prototype.findLast/commit/6960289aad2898b3c1c3b874937fe171ccd195cb)
|
||||
- [Refactor] use `es-errors`, so things that only need those do not need `get-intrinsic` [`96e976a`](https://github.com/es-shims/Array.prototype.findLast/commit/96e976af6cbe6240472bf6ac509526e66bb48fbc)
|
||||
- [Dev Deps] update `aud`, `npmignore`, `tape` [`e41c671`](https://github.com/es-shims/Array.prototype.findLast/commit/e41c6718bb4e1f498bc0c7d850fe6f595e6314d1)
|
||||
- [Dev Deps] use `hasown` instead of `has` [`3e81897`](https://github.com/es-shims/Array.prototype.findLast/commit/3e818971d0432e11e639d4e0f13fba7ca7f1392d)
|
||||
- [Dev Deps] update `object-inspect`, `tape` [`09387d9`](https://github.com/es-shims/Array.prototype.findLast/commit/09387d910af91741959ee9106f20b8379b80fdcb)
|
||||
|
||||
## [v1.2.3](https://github.com/es-shims/Array.prototype.findLast/compare/v1.2.2...v1.2.3) - 2023-08-29
|
||||
|
||||
### Commits
|
||||
|
||||
- [Deps] update `define-properties`, `es-abstract`, `get-intrinsic` [`ed6e699`](https://github.com/es-shims/Array.prototype.findLast/commit/ed6e69963e3b7252ce6fc82a92f0843bf92e2cb8)
|
||||
- [Tests] add passing test262 test [`ba57e7f`](https://github.com/es-shims/Array.prototype.findLast/commit/ba57e7fb3d85c5d022f84538ac610cbbad3a1f06)
|
||||
- [Dev Deps] update `@es-shims/api`, `@ljharb/eslint-config`, `aud`, `object-inspect`, `tape` [`fdf9269`](https://github.com/es-shims/Array.prototype.findLast/commit/fdf9269de92629dbbb101e91971efbab45634020)
|
||||
- [Tests] use `globalthis` [`d56fd28`](https://github.com/es-shims/Array.prototype.findLast/commit/d56fd280792c2fa78d6b4efd9c419df5bf49e6d8)
|
||||
|
||||
## [v1.2.2](https://github.com/es-shims/Array.prototype.findLast/compare/v1.2.1...v1.2.2) - 2022-11-02
|
||||
|
||||
### Commits
|
||||
|
||||
- [meta] use `npmignore` to autogenerate an npmignore file [`c8bd8e9`](https://github.com/es-shims/Array.prototype.findLast/commit/c8bd8e9410e3b0468754bcc722d10eade90d6b8d)
|
||||
- [Deps] update `es-abstract`, `get-intrinsic` [`7dd1e37`](https://github.com/es-shims/Array.prototype.findLast/commit/7dd1e3706aa4d1dc8007dc430ad721b787cceece)
|
||||
- [actions] update rebase action to use reusable workflow [`116bfa3`](https://github.com/es-shims/Array.prototype.findLast/commit/116bfa3374f7adbe4363ee186ae397d6175a1386)
|
||||
- [Deps] update `define-properties`, `es-abstract`, `get-intrinsic` [`8a6fcb5`](https://github.com/es-shims/Array.prototype.findLast/commit/8a6fcb543f3854f4124b26a60d651f26cb836658)
|
||||
- [Dev Deps] update `es-value-fixtures`, `object-inspect`, `tape` [`899e29a`](https://github.com/es-shims/Array.prototype.findLast/commit/899e29acdeb046b92e6a19739cc97f0605bd074d)
|
||||
- [Dev Deps] update `aud`, `tape` [`2019883`](https://github.com/es-shims/Array.prototype.findLast/commit/2019883d4a054b95856b6d421e106b9a0fe0f20b)
|
||||
- [Tests] add indication of whether it was shimmed [`c940767`](https://github.com/es-shims/Array.prototype.findLast/commit/c9407677645d551481e8b98f96297fec7518165a)
|
||||
|
||||
## [v1.2.1](https://github.com/es-shims/Array.prototype.findLast/compare/v1.2.0...v1.2.1) - 2022-04-11
|
||||
|
||||
### Commits
|
||||
|
||||
- [Refactor] use `es-shim-unscopables` [`e85dfc7`](https://github.com/es-shims/Array.prototype.findLast/commit/e85dfc7f324f61e1dc2c99129f4bcc7837ce3ac4)
|
||||
|
||||
## [v1.2.0](https://github.com/es-shims/Array.prototype.findLast/compare/v1.1.1...v1.2.0) - 2022-04-11
|
||||
|
||||
### Commits
|
||||
|
||||
- [actions] reuse common workflows [`47e3be7`](https://github.com/es-shims/Array.prototype.findLast/commit/47e3be7cda282144ddc18204534ec5983055a48e)
|
||||
- [Dev Deps] update `eslint`, `@ljharb/eslint-config`, `object-inspect`, `safe-publish-latest`, `tape` [`da9ec92`](https://github.com/es-shims/Array.prototype.findLast/commit/da9ec926ee4393d8cf2e2b74202a059a92ef59ac)
|
||||
- [Dev Deps] update `eslint`, `@ljharb/eslint-config`, `aud`, `auto-changelog`, `object-inspect`, `tape` [`2658604`](https://github.com/es-shims/Array.prototype.findLast/commit/26586043f36390c4967972c2caf318c0bbf583fb)
|
||||
- [actions] update codecov uploader [`9e4ac5e`](https://github.com/es-shims/Array.prototype.findLast/commit/9e4ac5e104a2f258cb818a19d3e6eb4023d1edd3)
|
||||
- [New] `shim`/`auto`: add `findLast` to `Symbol.unscopables` [`a3703b0`](https://github.com/es-shims/Array.prototype.findLast/commit/a3703b0dbeefb1dcd4c4fcec9f89c67bc7513821)
|
||||
- [meta] use `prepublishOnly` script for npm 7+ [`499fd61`](https://github.com/es-shims/Array.prototype.findLast/commit/499fd61f61d094d997b53c34628e477089b6ff96)
|
||||
- [Deps] update `es-abstract` [`9833a38`](https://github.com/es-shims/Array.prototype.findLast/commit/9833a38b6f6d949636fca1e945b2eee1812e142b)
|
||||
- [Deps] update `es-abstract` [`3055ac5`](https://github.com/es-shims/Array.prototype.findLast/commit/3055ac5ad56eb224f72c4cc18a06d0af06c6d2a1)
|
||||
- [Dev Deps] update `@es-shims/api` [`4639a6b`](https://github.com/es-shims/Array.prototype.findLast/commit/4639a6b10b3ecb84e1bc3e645cad1c60de8d99da)
|
||||
|
||||
## [v1.1.1](https://github.com/es-shims/Array.prototype.findLast/compare/v1.1.0...v1.1.1) - 2021-10-01
|
||||
|
||||
### Commits
|
||||
|
||||
- [Refactor] remove ESM entry points [`10118cc`](https://github.com/es-shims/Array.prototype.findLast/commit/10118cc9b896f4c7fa01bfbab17018400b2a7ddb)
|
||||
- [Tests] add new tests from test262 [`11a6b0a`](https://github.com/es-shims/Array.prototype.findLast/commit/11a6b0a9d34bc6bbd8271b37594ec9ba5fd4ca87)
|
||||
- [Deps] update `es-abstract` [`ad74212`](https://github.com/es-shims/Array.prototype.findLast/commit/ad7421298490b3355b1d3f0a8fa51b8704e5a0ba)
|
||||
- [readme] fix URLs [`ea7f11e`](https://github.com/es-shims/Array.prototype.findLast/commit/ea7f11e9ee4961c68104ba43958f5a45a0cffa65)
|
||||
- [Dev Deps] update `@ljharb/eslint-config`, `@es-shims/api` [`b834c11`](https://github.com/es-shims/Array.prototype.findLast/commit/b834c114ae5bea9c1002a31574545b01c479c2fd)
|
||||
|
||||
## [v1.1.0](https://github.com/es-shims/Array.prototype.findLast/compare/v1.0.0...v1.1.0) - 2021-08-07
|
||||
|
||||
### Commits
|
||||
|
||||
- [New] add ESM entry points [`4830a17`](https://github.com/es-shims/Array.prototype.findLast/commit/4830a173290c5b6fbfda494936ebfc13fb188e9b)
|
||||
- [Fix] ES3 engines: ensure nullish receiver throws [`3483d48`](https://github.com/es-shims/Array.prototype.findLast/commit/3483d489b0a2c17509d34aa386de8b83d4c6c0a1)
|
||||
- [Fix] add missing entry points to `exports` [`db8fe56`](https://github.com/es-shims/Array.prototype.findLast/commit/db8fe56e3196ea8e74b6c4bda67efef03f6c6594)
|
||||
- [Dev Deps] update `eslint`, `tape` [`a59f069`](https://github.com/es-shims/Array.prototype.findLast/commit/a59f069678049d3d8589c2ea22cf65160998fde3)
|
||||
- [Deps] update `es-abstract` [`4faa274`](https://github.com/es-shims/Array.prototype.findLast/commit/4faa27421b982962f4b68e199308bfc25300ccc4)
|
||||
|
||||
## v1.0.0 - 2021-07-13
|
||||
|
||||
### Commits
|
||||
|
||||
- Implementation & Tests [`70cf3b1`](https://github.com/es-shims/Array.prototype.findLast/commit/70cf3b1254a43d7fc32bc7726f6c372656f84182)
|
||||
- Initial commit [`d94083f`](https://github.com/es-shims/Array.prototype.findLast/commit/d94083fc3de59677540a3021c6f3082a22a804e6)
|
||||
- npm init [`e016a98`](https://github.com/es-shims/Array.prototype.findLast/commit/e016a98c2ee504e43a7d6018fae31cbe972c1db9)
|
||||
- Only apps should have lockfiles [`cb11c67`](https://github.com/es-shims/Array.prototype.findLast/commit/cb11c670b831ede1df53cf312dc6b0bcd96236cc)
|
||||
21
node_modules/array.prototype.findlast/LICENSE
generated
vendored
Normal file
21
node_modules/array.prototype.findlast/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2021 ECMAScript Shims
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
74
node_modules/array.prototype.findlast/README.md
generated
vendored
Normal file
74
node_modules/array.prototype.findlast/README.md
generated
vendored
Normal file
@@ -0,0 +1,74 @@
|
||||
# array.prototype.findlast <sup>[![Version Badge][npm-version-svg]][package-url]</sup>
|
||||
|
||||
[![github actions][actions-image]][actions-url]
|
||||
[![coverage][codecov-image]][codecov-url]
|
||||
[![dependency status][deps-svg]][deps-url]
|
||||
[![dev dependency status][dev-deps-svg]][dev-deps-url]
|
||||
[![License][license-image]][license-url]
|
||||
[![Downloads][downloads-image]][downloads-url]
|
||||
|
||||
[![npm badge][npm-badge-png]][package-url]
|
||||
|
||||
An ESnext spec-compliant `Array.prototype.findLast` shim/polyfill/replacement that works as far down as ES3.
|
||||
|
||||
This package implements the [es-shim API](https://github.com/es-shims/api) interface. It works in an ES3-supported environment and complies with the proposed [spec](https://tc39.es/proposal-array-find-from-last).
|
||||
|
||||
Because `Array.prototype.findLast` depends on a receiver (the `this` value), the main export takes the array to operate on as the first argument.
|
||||
|
||||
## Getting started
|
||||
|
||||
```sh
|
||||
npm install --save array.prototype.findlast
|
||||
```
|
||||
|
||||
## Usage/Examples
|
||||
|
||||
```js
|
||||
var findLast = require('array.prototype.findlast');
|
||||
var assert = require('assert');
|
||||
|
||||
var arr = [1, [2], [], 3, [[4]]];
|
||||
var isNumber = function (x) { return typeof x === 'number' };
|
||||
|
||||
assert.deepEqual(findLast(arr, isNumber), 3);
|
||||
```
|
||||
|
||||
```js
|
||||
var findLast = require('array.prototype.findlast');
|
||||
var assert = require('assert');
|
||||
/* when Array#findLast is not present */
|
||||
delete Array.prototype.findLast;
|
||||
var shimmed = findLast.shim();
|
||||
|
||||
assert.equal(shimmed, findLast.getPolyfill());
|
||||
assert.deepEqual(arr.findLast(isNumber), findLast(arr, isNumber));
|
||||
```
|
||||
|
||||
```js
|
||||
var findLast = require('array.prototype.findlast');
|
||||
var assert = require('assert');
|
||||
/* when Array#findLast is present */
|
||||
var shimmed = findLast.shim();
|
||||
|
||||
assert.equal(shimmed, Array.prototype.findLast);
|
||||
assert.deepEqual(arr.findLast(isNumber), findLast(arr, isNumber));
|
||||
```
|
||||
|
||||
## Tests
|
||||
Simply clone the repo, `npm install`, and run `npm test`
|
||||
|
||||
[package-url]: https://npmjs.org/package/array.prototype.findlast
|
||||
[npm-version-svg]: https://versionbadg.es/es-shims/Array.prototype.findLast.svg
|
||||
[deps-svg]: https://david-dm.org/es-shims/Array.prototype.findLast.svg
|
||||
[deps-url]: https://david-dm.org/es-shims/Array.prototype.findLast
|
||||
[dev-deps-svg]: https://david-dm.org/es-shims/Array.prototype.findLast/dev-status.svg
|
||||
[dev-deps-url]: https://david-dm.org/es-shims/Array.prototype.findLast#info=devDependencies
|
||||
[npm-badge-png]: https://nodei.co/npm/array.prototype.findlast.png?downloads=true&stars=true
|
||||
[license-image]: https://img.shields.io/npm/l/array.prototype.findlast.svg
|
||||
[license-url]: LICENSE
|
||||
[downloads-image]: https://img.shields.io/npm/dm/array.prototype.findlast.svg
|
||||
[downloads-url]: https://npm-stat.com/charts.html?package=array.prototype.findlast
|
||||
[codecov-image]: https://codecov.io/gh/es-shims/Array.prototype.findLast/branch/main/graphs/badge.svg
|
||||
[codecov-url]: https://app.codecov.io/gh/es-shims/Array.prototype.findLast/
|
||||
[actions-image]: https://img.shields.io/endpoint?url=https://github-actions-badge-u3jn4tfpocch.runkit.sh/es-shims/Array.prototype.findLast
|
||||
[actions-url]: https://github.com/es-shims/Array.prototype.findLast
|
||||
3
node_modules/array.prototype.findlast/auto.js
generated
vendored
Normal file
3
node_modules/array.prototype.findlast/auto.js
generated
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
'use strict';
|
||||
|
||||
require('./shim')();
|
||||
38
node_modules/array.prototype.findlast/implementation.js
generated
vendored
Normal file
38
node_modules/array.prototype.findlast/implementation.js
generated
vendored
Normal file
@@ -0,0 +1,38 @@
|
||||
'use strict';
|
||||
|
||||
var $TypeError = require('es-errors/type');
|
||||
|
||||
var Call = require('es-abstract/2024/Call');
|
||||
var Get = require('es-abstract/2024/Get');
|
||||
var IsCallable = require('es-abstract/2024/IsCallable');
|
||||
var LengthOfArrayLike = require('es-abstract/2024/LengthOfArrayLike');
|
||||
var ToBoolean = require('es-abstract/2024/ToBoolean');
|
||||
var ToObject = require('es-object-atoms/ToObject');
|
||||
var ToString = require('es-abstract/2024/ToString');
|
||||
|
||||
module.exports = function findLast(predicate) {
|
||||
var O = ToObject(this);
|
||||
var len = LengthOfArrayLike(O);
|
||||
|
||||
if (!IsCallable(predicate)) {
|
||||
throw new $TypeError('predicate must be a function');
|
||||
}
|
||||
|
||||
var thisArg;
|
||||
if (arguments.length > 1) {
|
||||
thisArg = arguments[1];
|
||||
}
|
||||
|
||||
var k = len - 1;
|
||||
while (k >= 0) {
|
||||
var Pk = ToString(k);
|
||||
var kValue = Get(O, Pk);
|
||||
var testResult = ToBoolean(Call(predicate, thisArg, [kValue, k, O]));
|
||||
if (testResult) {
|
||||
return kValue;
|
||||
}
|
||||
k -= 1;
|
||||
}
|
||||
|
||||
return void undefined;
|
||||
};
|
||||
28
node_modules/array.prototype.findlast/index.js
generated
vendored
Normal file
28
node_modules/array.prototype.findlast/index.js
generated
vendored
Normal file
@@ -0,0 +1,28 @@
|
||||
'use strict';
|
||||
|
||||
var define = require('define-properties');
|
||||
var callBind = require('call-bind');
|
||||
var callBound = require('call-bind/callBound');
|
||||
var RequireObjectCoercible = require('es-object-atoms/RequireObjectCoercible');
|
||||
|
||||
var implementation = require('./implementation');
|
||||
var getPolyfill = require('./polyfill');
|
||||
var polyfill = getPolyfill();
|
||||
var shim = require('./shim');
|
||||
|
||||
var $slice = callBound('Array.prototype.slice');
|
||||
|
||||
var bound = callBind.apply(polyfill);
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
var boundFindLast = function findLast(array, predicate) {
|
||||
RequireObjectCoercible(array);
|
||||
return bound(array, $slice(arguments, 1));
|
||||
};
|
||||
|
||||
define(boundFindLast, {
|
||||
getPolyfill: getPolyfill,
|
||||
implementation: implementation,
|
||||
shim: shim
|
||||
});
|
||||
|
||||
module.exports = boundFindLast;
|
||||
111
node_modules/array.prototype.findlast/package.json
generated
vendored
Normal file
111
node_modules/array.prototype.findlast/package.json
generated
vendored
Normal file
@@ -0,0 +1,111 @@
|
||||
{
|
||||
"name": "array.prototype.findlast",
|
||||
"version": "1.2.5",
|
||||
"description": "An ESnext spec-compliant `Array.prototype.findLast` shim/polyfill/replacement that works as far down as ES3.",
|
||||
"author": {
|
||||
"name": "Jordan Harband",
|
||||
"email": "ljharb@gmail.com",
|
||||
"url": "http://ljharb.codes"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://github.com/sponsors/ljharb"
|
||||
},
|
||||
"contributors": [
|
||||
{
|
||||
"name": "Jordan Harband",
|
||||
"email": "ljharb@gmail.com",
|
||||
"url": "http://ljharb.codes"
|
||||
}
|
||||
],
|
||||
"license": "MIT",
|
||||
"bugs": {
|
||||
"url": "https://github.com/es-shims/Array.prototype.findLast/issues"
|
||||
},
|
||||
"homepage": "https://github.com/es-shims/Array.prototype.findLast#readme",
|
||||
"main": "index.js",
|
||||
"exports": {
|
||||
".": "./index.js",
|
||||
"./auto": "./auto.js",
|
||||
"./polyfill": "./polyfill.js",
|
||||
"./implementation": "./implementation.js",
|
||||
"./shim": "./shim.js",
|
||||
"./package.json": "./package.json"
|
||||
},
|
||||
"scripts": {
|
||||
"prepack": "npmignore --auto --commentLines=autogenerated",
|
||||
"prepublishOnly": "safe-publish-latest",
|
||||
"prepublish": "not-in-publish || npm run prepublishOnly",
|
||||
"pretest": "npm run --silent lint && evalmd README.md",
|
||||
"posttest": "aud --production",
|
||||
"tests-only": "nyc tape 'test/**/*.js'",
|
||||
"test": "npm run tests-only",
|
||||
"lint": "eslint --ext=js,mjs .",
|
||||
"postlint": "es-shim-api --bound",
|
||||
"version": "auto-changelog && git add CHANGELOG.md",
|
||||
"postversion": "auto-changelog && git add CHANGELOG.md && git commit --no-edit --amend && git tag -f \"v$(node -e \"console.log(require('./package.json').version)\")\""
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/es-shims/Array.prototype.findLast.git"
|
||||
},
|
||||
"keywords": [
|
||||
"Array.prototype.findLast",
|
||||
"find",
|
||||
"findLast",
|
||||
"array",
|
||||
"ESnext",
|
||||
"shim",
|
||||
"polyfill",
|
||||
"last",
|
||||
"es-shim API"
|
||||
],
|
||||
"dependencies": {
|
||||
"call-bind": "^1.0.7",
|
||||
"define-properties": "^1.2.1",
|
||||
"es-abstract": "^1.23.2",
|
||||
"es-errors": "^1.3.0",
|
||||
"es-object-atoms": "^1.0.0",
|
||||
"es-shim-unscopables": "^1.0.2"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@es-shims/api": "^2.4.2",
|
||||
"@ljharb/eslint-config": "^21.1.0",
|
||||
"aud": "^2.0.4",
|
||||
"auto-changelog": "^2.4.0",
|
||||
"es-value-fixtures": "^1.4.2",
|
||||
"eslint": "=8.8.0",
|
||||
"evalmd": "^0.0.19",
|
||||
"for-each": "^0.3.3",
|
||||
"globalthis": "^1.0.3",
|
||||
"has-strict-mode": "^1.0.1",
|
||||
"hasown": "^2.0.2",
|
||||
"in-publish": "^2.0.1",
|
||||
"npmignore": "^0.3.1",
|
||||
"nyc": "^10.3.2",
|
||||
"object-inspect": "^1.13.1",
|
||||
"safe-publish-latest": "^2.0.0",
|
||||
"tape": "^5.7.5"
|
||||
},
|
||||
"testling": {
|
||||
"files": [
|
||||
"test/index.js",
|
||||
"test/shimmed.js"
|
||||
]
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 0.4"
|
||||
},
|
||||
"auto-changelog": {
|
||||
"output": "CHANGELOG.md",
|
||||
"template": "keepachangelog",
|
||||
"unreleased": false,
|
||||
"commitLimit": false,
|
||||
"backfillLimit": false,
|
||||
"hideCredit": true
|
||||
},
|
||||
"publishConfig": {
|
||||
"ignore": [
|
||||
".github/workflows"
|
||||
]
|
||||
}
|
||||
}
|
||||
7
node_modules/array.prototype.findlast/polyfill.js
generated
vendored
Normal file
7
node_modules/array.prototype.findlast/polyfill.js
generated
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
'use strict';
|
||||
|
||||
var implementation = require('./implementation');
|
||||
|
||||
module.exports = function getPolyfill() {
|
||||
return Array.prototype.findLast || implementation;
|
||||
};
|
||||
18
node_modules/array.prototype.findlast/shim.js
generated
vendored
Normal file
18
node_modules/array.prototype.findlast/shim.js
generated
vendored
Normal file
@@ -0,0 +1,18 @@
|
||||
'use strict';
|
||||
|
||||
var define = require('define-properties');
|
||||
var getPolyfill = require('./polyfill');
|
||||
var shimUnscopables = require('es-shim-unscopables');
|
||||
|
||||
module.exports = function shimFindLast() {
|
||||
var polyfill = getPolyfill();
|
||||
define(
|
||||
Array.prototype,
|
||||
{ findLast: polyfill },
|
||||
{ findLast: function () { return Array.prototype.findLast !== polyfill; } }
|
||||
);
|
||||
|
||||
shimUnscopables('findLast');
|
||||
|
||||
return polyfill;
|
||||
};
|
||||
20
node_modules/array.prototype.findlast/test/implementation.js
generated
vendored
Normal file
20
node_modules/array.prototype.findlast/test/implementation.js
generated
vendored
Normal file
@@ -0,0 +1,20 @@
|
||||
'use strict';
|
||||
|
||||
var implementation = require('../implementation');
|
||||
var callBind = require('call-bind');
|
||||
var test = require('tape');
|
||||
var hasStrictMode = require('has-strict-mode')();
|
||||
var runTests = require('./tests');
|
||||
|
||||
test('as a function', function (t) {
|
||||
t.test('bad array/this value', { skip: !hasStrictMode }, function (st) {
|
||||
/* eslint no-useless-call: 0 */
|
||||
st['throws'](function () { implementation.call(undefined); }, TypeError, 'undefined is not an object');
|
||||
st['throws'](function () { implementation.call(null); }, TypeError, 'null is not an object');
|
||||
st.end();
|
||||
});
|
||||
|
||||
runTests(callBind(implementation), t);
|
||||
|
||||
t.end();
|
||||
});
|
||||
18
node_modules/array.prototype.findlast/test/index.js
generated
vendored
Normal file
18
node_modules/array.prototype.findlast/test/index.js
generated
vendored
Normal file
@@ -0,0 +1,18 @@
|
||||
'use strict';
|
||||
|
||||
var index = require('../');
|
||||
var callBind = require('call-bind');
|
||||
var test = require('tape');
|
||||
var runTests = require('./tests');
|
||||
|
||||
test('as a function', function (t) {
|
||||
t.test('bad array/this value', function (st) {
|
||||
st['throws'](callBind(index, null, undefined, function () {}), TypeError, 'undefined is not an object');
|
||||
st['throws'](callBind(index, null, null, function () {}), TypeError, 'null is not an object');
|
||||
st.end();
|
||||
});
|
||||
|
||||
runTests(index, t);
|
||||
|
||||
t.end();
|
||||
});
|
||||
47
node_modules/array.prototype.findlast/test/shimmed.js
generated
vendored
Normal file
47
node_modules/array.prototype.findlast/test/shimmed.js
generated
vendored
Normal file
@@ -0,0 +1,47 @@
|
||||
'use strict';
|
||||
|
||||
var orig = Array.prototype.findLast;
|
||||
|
||||
require('../auto');
|
||||
|
||||
var test = require('tape');
|
||||
var hasOwn = require('hasown');
|
||||
var defineProperties = require('define-properties');
|
||||
var callBind = require('call-bind');
|
||||
var isEnumerable = Object.prototype.propertyIsEnumerable;
|
||||
var functionsHaveNames = function f() {}.name === 'f';
|
||||
|
||||
var runTests = require('./tests');
|
||||
|
||||
test('shimmed', function (t) {
|
||||
t.comment('shimmed: ' + (orig === Array.prototype.findLast ? 'no' : 'yes'));
|
||||
|
||||
t.equal(Array.prototype.findLast.length, 1, 'Array#findLast has a length of 1');
|
||||
t.test('Function name', { skip: !functionsHaveNames }, function (st) {
|
||||
st.equal(Array.prototype.findLast.name, 'findLast', 'Array#findLast has name "findLast"');
|
||||
st.end();
|
||||
});
|
||||
|
||||
t.test('enumerability', { skip: !defineProperties.supportsDescriptors }, function (et) {
|
||||
et.equal(false, isEnumerable.call(Array.prototype, 'findLast'), 'Array#findLast is not enumerable');
|
||||
et.end();
|
||||
});
|
||||
|
||||
var supportsStrictMode = (function () { return typeof this === 'undefined'; }());
|
||||
|
||||
t.test('bad array/this value', { skip: !supportsStrictMode }, function (st) {
|
||||
st['throws'](function () { return Array.prototype.findLast.call(undefined, 'a'); }, TypeError, 'undefined is not an object');
|
||||
st['throws'](function () { return Array.prototype.findLast.call(null, 'a'); }, TypeError, 'null is not an object');
|
||||
st.end();
|
||||
});
|
||||
|
||||
t.test('Symbol.unscopables', { skip: typeof Symbol !== 'function' || typeof Symbol.unscopables !== 'symbol' }, function (st) {
|
||||
st.ok(hasOwn(Array.prototype[Symbol.unscopables], 'findLast'), 'Array.prototype[Symbol.unscopables] has own `findLast` property');
|
||||
st.equal(Array.prototype[Symbol.unscopables].findLast, true, 'Array.prototype[Symbol.unscopables].findLast is true');
|
||||
st.end();
|
||||
});
|
||||
|
||||
runTests(callBind(Array.prototype.findLast), t);
|
||||
|
||||
t.end();
|
||||
});
|
||||
246
node_modules/array.prototype.findlast/test/tests.js
generated
vendored
Normal file
246
node_modules/array.prototype.findlast/test/tests.js
generated
vendored
Normal file
@@ -0,0 +1,246 @@
|
||||
var hasStrictMode = require('has-strict-mode')();
|
||||
var v = require('es-value-fixtures');
|
||||
var forEach = require('for-each');
|
||||
var inspect = require('object-inspect');
|
||||
var maxSafeInteger = require('es-abstract/helpers/maxSafeInteger');
|
||||
var global = require('globalthis')();
|
||||
|
||||
var trueThunk = function () { return true; };
|
||||
var falseThunk = function () { return false; };
|
||||
|
||||
var canDistinguishSparseFromUndefined = 0 in [undefined]; // IE 6 - 8 have a bug where this returns false.
|
||||
var undefinedIfNoSparseBug = canDistinguishSparseFromUndefined ? undefined : { valueOf: function () { return 0; } };
|
||||
|
||||
var createArrayLikeFromArray = function createArrayLikeFromArray(arr) {
|
||||
var o = {};
|
||||
for (var i = 0; i < arr.length; i += 1) {
|
||||
if (i in arr) {
|
||||
o[i] = arr[i];
|
||||
}
|
||||
}
|
||||
o.length = arr.length;
|
||||
return o;
|
||||
};
|
||||
|
||||
var getTestArr = function () {
|
||||
var arr = [0, false, null, 'hej', true, undefinedIfNoSparseBug, 3, 2];
|
||||
delete arr[6];
|
||||
return arr;
|
||||
};
|
||||
|
||||
module.exports = function (findLast, t) {
|
||||
forEach(v.nonArrays, function (nonArray) {
|
||||
if (nonArray != null) { // eslint-disable-line eqeqeq
|
||||
t.equal(
|
||||
findLast(nonArray, function () { return true; }),
|
||||
nonArray.length > 0 ? nonArray[nonArray.length - 1] : undefined,
|
||||
inspect(nonArray) + ' is not an array'
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
t.test('throws on a non-callable predicate', function (st) {
|
||||
forEach(v.nonFunctions, function (nonFunction) {
|
||||
st['throws'](
|
||||
function () { findLast([], nonFunction); },
|
||||
TypeError,
|
||||
inspect(nonFunction) + ' is not a Function'
|
||||
);
|
||||
});
|
||||
|
||||
st.end();
|
||||
});
|
||||
|
||||
t.test('passes the correct values to the callback', function (st) {
|
||||
st.plan(5);
|
||||
|
||||
var expectedValue = {};
|
||||
var arr = [expectedValue];
|
||||
var context = {};
|
||||
findLast(arr, function (value, key, list) {
|
||||
st.equal(arguments.length, 3);
|
||||
st.equal(value, expectedValue, 'first argument is the value');
|
||||
st.equal(key, 0, 'second argument is the index');
|
||||
st.equal(list, arr, 'third argument is the array being iterated');
|
||||
st.equal(this, context, 'receiver is the expected value');
|
||||
return true;
|
||||
}, context);
|
||||
|
||||
st.end();
|
||||
});
|
||||
|
||||
t.test('does not visit elements added to the array after it has begun', function (st) {
|
||||
st.plan(2);
|
||||
|
||||
var arr = [1, 2, 3];
|
||||
var i = 0;
|
||||
findLast(arr, function (a) {
|
||||
i += 1;
|
||||
arr.push(a + 3);
|
||||
return i > 3;
|
||||
});
|
||||
st.deepEqual(arr, [1, 2, 3, 6, 5, 4], 'array has received 3 new elements');
|
||||
st.equal(i, 3, 'findLast callback only called thrice');
|
||||
|
||||
st.end();
|
||||
});
|
||||
|
||||
t.test('does not visit elements deleted from the array after it has begun', function (st) {
|
||||
var arr = [1, 2, 3];
|
||||
var actual = [];
|
||||
findLast(arr, function (x, i) {
|
||||
actual.push([i, x]);
|
||||
delete arr[1];
|
||||
return false;
|
||||
});
|
||||
st.deepEqual(actual, [[2, 3], [1, undefined], [0, 1]]);
|
||||
|
||||
st.end();
|
||||
});
|
||||
|
||||
t.test('sets the right context when given none', function (st) {
|
||||
var context;
|
||||
findLast([1], function () { context = this; });
|
||||
st.equal(context, global, 'receiver is global object in sloppy mode');
|
||||
|
||||
st.test('strict mode', { skip: !hasStrictMode }, function (sst) {
|
||||
findLast([1], function () {
|
||||
'use strict';
|
||||
|
||||
context = this;
|
||||
});
|
||||
sst.equal(context, undefined, 'receiver is undefined in strict mode');
|
||||
sst.end();
|
||||
});
|
||||
|
||||
st.end();
|
||||
});
|
||||
|
||||
t.test('empty array', function (st) {
|
||||
st.equal(findLast([], trueThunk), undefined, 'true thunk callback yields undefined');
|
||||
st.equal(findLast([], falseThunk), undefined, 'false thunk callback yields undefined');
|
||||
|
||||
var counter = 0;
|
||||
var callback = function () { counter += 1; };
|
||||
findLast([], callback);
|
||||
st.equal(counter, 0, 'counter is not incremented');
|
||||
|
||||
st.end();
|
||||
});
|
||||
|
||||
t.equal(findLast([1, 2, 3], trueThunk), 3, 'returns last item if findLast callback returns true');
|
||||
t.equal(findLast([1, 2, 3], falseThunk), undefined, 'returns undefined if no callback returns true');
|
||||
|
||||
t.test('stopping after N elements', function (st) {
|
||||
st.test('no context', function (sst) {
|
||||
var actual = {};
|
||||
var count = 0;
|
||||
findLast(getTestArr(), function (obj, index) {
|
||||
actual[index] = obj;
|
||||
count += 1;
|
||||
return count === 4;
|
||||
});
|
||||
sst.deepEqual(actual, { 4: true, 5: undefinedIfNoSparseBug, 6: undefined, 7: 2 });
|
||||
sst.end();
|
||||
});
|
||||
|
||||
st.test('with context', function (sst) {
|
||||
var actual = {};
|
||||
var context = { actual: actual };
|
||||
var count = 0;
|
||||
findLast(getTestArr(), function (obj, index) {
|
||||
this.actual[index] = obj;
|
||||
count += 1;
|
||||
return count === 4;
|
||||
}, context);
|
||||
sst.deepEqual(actual, { 4: true, 5: undefinedIfNoSparseBug, 6: undefined, 7: 2 });
|
||||
sst.end();
|
||||
});
|
||||
|
||||
st.test('arraylike, no context', function (sst) {
|
||||
var actual = {};
|
||||
var count = 0;
|
||||
findLast(createArrayLikeFromArray(getTestArr()), function (obj, index) {
|
||||
actual[index] = obj;
|
||||
count += 1;
|
||||
return count === 4;
|
||||
});
|
||||
sst.deepEqual(actual, { 4: true, 5: undefinedIfNoSparseBug, 6: undefined, 7: 2 });
|
||||
sst.end();
|
||||
});
|
||||
|
||||
st.test('arraylike, context', function (sst) {
|
||||
var actual = {};
|
||||
var count = 0;
|
||||
var context = { actual: actual };
|
||||
findLast(createArrayLikeFromArray(getTestArr()), function (obj, index) {
|
||||
this.actual[index] = obj;
|
||||
count += 1;
|
||||
return count === 4;
|
||||
}, context);
|
||||
sst.deepEqual(actual, { 4: true, 5: undefinedIfNoSparseBug, 6: undefined, 7: 2 });
|
||||
sst.end();
|
||||
});
|
||||
|
||||
st.end();
|
||||
});
|
||||
|
||||
t.test('list arg boxing', function (st) {
|
||||
st.plan(3);
|
||||
|
||||
findLast('bar', function (item, index, list) {
|
||||
st.equal(item, 'r', 'last letter matches');
|
||||
st.equal(typeof list, 'object', 'primitive list arg is boxed');
|
||||
st.equal(Object.prototype.toString.call(list), '[object String]', 'boxed list arg is a String');
|
||||
return true;
|
||||
});
|
||||
|
||||
st.end();
|
||||
});
|
||||
|
||||
t.test('array altered during loop', function (st) {
|
||||
var arr = ['Shoes', 'Car', 'Bike'];
|
||||
var results = [];
|
||||
|
||||
findLast(arr, function (kValue) {
|
||||
if (results.length === 0) {
|
||||
arr.splice(1, 1);
|
||||
}
|
||||
results.push(kValue);
|
||||
});
|
||||
|
||||
st.equal(results.length, 3, 'predicate called three times');
|
||||
st.deepEqual(results, ['Bike', 'Bike', 'Shoes']);
|
||||
|
||||
results = [];
|
||||
arr = ['Skateboard', 'Barefoot'];
|
||||
findLast(arr, function (kValue) {
|
||||
if (results.length === 0) {
|
||||
arr.push('Motorcycle');
|
||||
arr[0] = 'Magic Carpet';
|
||||
}
|
||||
|
||||
results.push(kValue);
|
||||
});
|
||||
|
||||
st.equal(results.length, 2, 'predicate called twice');
|
||||
st.deepEqual(results, ['Barefoot', 'Magic Carpet']);
|
||||
|
||||
st.end();
|
||||
});
|
||||
|
||||
t.test('maximum index', function (st) {
|
||||
// https://github.com/tc39/test262/pull/3775
|
||||
|
||||
var arrayLike = { length: Number.MAX_VALUE };
|
||||
var calledWithIndex = [];
|
||||
|
||||
findLast(arrayLike, function (_, index) {
|
||||
calledWithIndex.push(index);
|
||||
return true;
|
||||
});
|
||||
|
||||
st.deepEqual(calledWithIndex, [maxSafeInteger - 1], 'predicate invoked once');
|
||||
st.end();
|
||||
});
|
||||
};
|
||||
Reference in New Issue
Block a user