Initial Save
This commit is contained in:
15
node_modules/safe-push-apply/.eslintrc
generated
vendored
Normal file
15
node_modules/safe-push-apply/.eslintrc
generated
vendored
Normal file
@@ -0,0 +1,15 @@
|
||||
{
|
||||
"root": true,
|
||||
|
||||
"extends": "@ljharb",
|
||||
|
||||
"rules": {
|
||||
"id-length": "off",
|
||||
"max-lines-per-function": "off",
|
||||
"new-cap": ["error", {
|
||||
"capIsNewExceptions": [
|
||||
"GetIntrinsic",
|
||||
],
|
||||
}],
|
||||
},
|
||||
}
|
||||
12
node_modules/safe-push-apply/.github/FUNDING.yml
generated
vendored
Normal file
12
node_modules/safe-push-apply/.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/safe-push-apply
|
||||
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']
|
||||
13
node_modules/safe-push-apply/.nycrc
generated
vendored
Normal file
13
node_modules/safe-push-apply/.nycrc
generated
vendored
Normal file
@@ -0,0 +1,13 @@
|
||||
{
|
||||
"all": true,
|
||||
"check-coverage": false,
|
||||
"reporter": ["text-summary", "text", "html", "json"],
|
||||
"lines": 86,
|
||||
"statements": 85.93,
|
||||
"functions": 82.43,
|
||||
"branches": 76.06,
|
||||
"exclude": [
|
||||
"coverage",
|
||||
"test"
|
||||
]
|
||||
}
|
||||
15
node_modules/safe-push-apply/CHANGELOG.md
generated
vendored
Normal file
15
node_modules/safe-push-apply/CHANGELOG.md
generated
vendored
Normal file
@@ -0,0 +1,15 @@
|
||||
# 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.0.0 - 2024-12-28
|
||||
|
||||
### Commits
|
||||
|
||||
- Initial implementation, tests, readme, types [`6e85f82`](https://github.com/ljharb/safe-push-apply/commit/6e85f82b116286503ff377e15708cd1584531c5f)
|
||||
- Initial commit [`93928d9`](https://github.com/ljharb/safe-push-apply/commit/93928d9a1304ccc25b799528a4bbca8615f7614e)
|
||||
- npm init [`5da39da`](https://github.com/ljharb/safe-push-apply/commit/5da39da33bb096e633d1e631a9374cfa0d7dc06b)
|
||||
- Only apps should have lockfiles [`83fc8b4`](https://github.com/ljharb/safe-push-apply/commit/83fc8b4be29d680a27225329cc1ef5505626effa)
|
||||
21
node_modules/safe-push-apply/LICENSE
generated
vendored
Normal file
21
node_modules/safe-push-apply/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2024 Jordan Harband
|
||||
|
||||
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.
|
||||
59
node_modules/safe-push-apply/README.md
generated
vendored
Normal file
59
node_modules/safe-push-apply/README.md
generated
vendored
Normal file
@@ -0,0 +1,59 @@
|
||||
# safe-push-apply <sup>[![Version Badge][npm-version-svg]][package-url]</sup>
|
||||
|
||||
[![github actions][actions-image]][actions-url]
|
||||
[![coverage][codecov-image]][codecov-url]
|
||||
[![License][license-image]][license-url]
|
||||
[![Downloads][downloads-image]][downloads-url]
|
||||
|
||||
[![npm badge][npm-badge-png]][package-url]
|
||||
|
||||
Push an array of items into an array, while being robust against prototype modification.
|
||||
|
||||
## Getting started
|
||||
|
||||
```sh
|
||||
npm install --save safe-push-apply
|
||||
```
|
||||
|
||||
## Usage/Examples
|
||||
|
||||
```js
|
||||
var safePushApply = require('safe-push-apply');
|
||||
var assert = require('assert');
|
||||
|
||||
var arr = [1, 2, 3];
|
||||
|
||||
var orig = Array.prototype[Symbol.iterator];
|
||||
delete Array.prototype[Symbol.iterator];
|
||||
assert.throws(() => {
|
||||
try {
|
||||
arr.push(...[3, 4, 5]);
|
||||
} finally {
|
||||
Array.prototype[Symbol.iterator] = orig;
|
||||
}
|
||||
}, 'array is not iterable anymore');
|
||||
|
||||
delete Array.prototype.push;
|
||||
safePushApply(arr, [3, 4, 5]);
|
||||
|
||||
assert.deepEqual(arr, [1, 2, 3, 3, 4, 5]);
|
||||
```
|
||||
|
||||
## Tests
|
||||
Simply clone the repo, `npm install`, and run `npm test`
|
||||
|
||||
[package-url]: https://npmjs.org/package/safe-push-apply
|
||||
[npm-version-svg]: https://versionbadg.es/ljharb/safe-push-apply.svg
|
||||
[deps-svg]: https://david-dm.org/ljharb/safe-push-apply.svg
|
||||
[deps-url]: https://david-dm.org/ljharb/safe-push-apply
|
||||
[dev-deps-svg]: https://david-dm.org/ljharb/safe-push-apply/dev-status.svg
|
||||
[dev-deps-url]: https://david-dm.org/ljharb/safe-push-apply#info=devDependencies
|
||||
[npm-badge-png]: https://nodei.co/npm/safe-push-apply.png?downloads=true&stars=true
|
||||
[license-image]: https://img.shields.io/npm/l/safe-push-apply.svg
|
||||
[license-url]: LICENSE
|
||||
[downloads-image]: https://img.shields.io/npm/dm/safe-push-apply.svg
|
||||
[downloads-url]: https://npm-stat.com/charts.html?package=safe-push-apply
|
||||
[codecov-image]: https://codecov.io/gh/ljharb/safe-push-apply/branch/main/graphs/badge.svg
|
||||
[codecov-url]: https://app.codecov.io/gh/ljharb/safe-push-apply/
|
||||
[actions-image]: https://img.shields.io/endpoint?url=https://github-actions-badge-u3jn4tfpocch.runkit.sh/ljharb/safe-push-apply
|
||||
[actions-url]: https://github.com/ljharb/safe-push-apply/actions
|
||||
6
node_modules/safe-push-apply/index.d.ts
generated
vendored
Normal file
6
node_modules/safe-push-apply/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
declare function safePushApply<T, S extends T>(
|
||||
target: T[],
|
||||
source: ArrayLike<S>,
|
||||
): void;
|
||||
|
||||
export = safePushApply;
|
||||
15
node_modules/safe-push-apply/index.js
generated
vendored
Normal file
15
node_modules/safe-push-apply/index.js
generated
vendored
Normal file
@@ -0,0 +1,15 @@
|
||||
'use strict';
|
||||
|
||||
var $TypeError = require('es-errors/type');
|
||||
|
||||
var isArray = require('isarray');
|
||||
|
||||
/** @type {import('.')} */
|
||||
module.exports = function safePushApply(target, source) {
|
||||
if (!isArray(target)) {
|
||||
throw new $TypeError('target must be an array');
|
||||
}
|
||||
for (var i = 0; i < source.length; i++) {
|
||||
target[target.length] = source[i]; // eslint-disable-line no-param-reassign
|
||||
}
|
||||
};
|
||||
82
node_modules/safe-push-apply/package.json
generated
vendored
Normal file
82
node_modules/safe-push-apply/package.json
generated
vendored
Normal file
@@ -0,0 +1,82 @@
|
||||
{
|
||||
"name": "safe-push-apply",
|
||||
"version": "1.0.0",
|
||||
"description": "Push an array of items into an array, while being robust against prototype modification",
|
||||
"main": "index.js",
|
||||
"exports": {
|
||||
".": "./index.js",
|
||||
"./package.json": "./package.json"
|
||||
},
|
||||
"sideEffects": false,
|
||||
"scripts": {
|
||||
"prepack": "npmignore --auto --commentLines=autogenerated",
|
||||
"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)\")\"",
|
||||
"prelint": "evalmd README.md",
|
||||
"lint": "eslint --ext=js,mjs .",
|
||||
"postlint": "tsc && attw -P",
|
||||
"prepublish": "not-in-publish || npm run prepublishOnly",
|
||||
"prepublishOnly": "safe-publish-latest",
|
||||
"pretest": "npm run lint",
|
||||
"tests-only": "nyc tape test",
|
||||
"test": "npm run tests-only",
|
||||
"posttest": "npx npm@'>= 10.2' audit --production"
|
||||
},
|
||||
"keywords": [
|
||||
"array",
|
||||
"push",
|
||||
"apply",
|
||||
"pushApply",
|
||||
"safe"
|
||||
],
|
||||
"author": "Jordan Harband <ljharb@gmail.com>",
|
||||
"funding": {
|
||||
"url": "https://github.com/sponsors/ljharb"
|
||||
},
|
||||
"license": "MIT",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/ljharb/safe-push-apply.git"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/ljharb/safe-push-apply/issues"
|
||||
},
|
||||
"homepage": "https://github.com/ljharb/safe-push-apply#readme",
|
||||
"dependencies": {
|
||||
"es-errors": "^1.3.0",
|
||||
"isarray": "^2.0.5"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@arethetypeswrong/cli": "^0.17.1",
|
||||
"@ljharb/eslint-config": "^21.1.1",
|
||||
"@ljharb/tsconfig": "^0.2.2",
|
||||
"@types/isarray": "^2.0.3",
|
||||
"@types/tape": "^5.6.5",
|
||||
"auto-changelog": "^2.5.0",
|
||||
"encoding": "^0.1.13",
|
||||
"eslint": "=8.8.0",
|
||||
"evalmd": "^0.0.19",
|
||||
"in-publish": "^2.0.1",
|
||||
"npmignore": "^0.3.1",
|
||||
"nyc": "^10.3.2",
|
||||
"safe-publish-latest": "^2.0.0",
|
||||
"tape": "^5.9.0",
|
||||
"typescript": "next"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 0.4"
|
||||
},
|
||||
"auto-changelog": {
|
||||
"output": "CHANGELOG.md",
|
||||
"template": "keepachangelog",
|
||||
"unreleased": false,
|
||||
"commitLimit": false,
|
||||
"backfillLimit": false,
|
||||
"hideCredit": true
|
||||
},
|
||||
"publishConfig": {
|
||||
"ignore": [
|
||||
".github/workflows"
|
||||
]
|
||||
}
|
||||
}
|
||||
30
node_modules/safe-push-apply/test/index.js
generated
vendored
Normal file
30
node_modules/safe-push-apply/test/index.js
generated
vendored
Normal file
@@ -0,0 +1,30 @@
|
||||
'use strict';
|
||||
|
||||
var test = require('tape');
|
||||
|
||||
var safePushApply = require('../');
|
||||
|
||||
test('safe-push-apply', function (t) {
|
||||
t.equal(typeof safePushApply, 'function', 'is a function');
|
||||
t.equal(safePushApply.length, 2, 'has a length of 2');
|
||||
|
||||
t['throws'](
|
||||
// @ts-expect-error
|
||||
function () { safePushApply({}, []); },
|
||||
TypeError,
|
||||
'throws if target is not an array'
|
||||
);
|
||||
|
||||
var a = [1, 2];
|
||||
var b = [3, 4];
|
||||
safePushApply(a, b);
|
||||
t.deepEqual(a, [1, 2, 3, 4], 'b is pushed into a');
|
||||
t.deepEqual(b, [3, 4], 'b is not modified');
|
||||
|
||||
var c = '567';
|
||||
// @ts-expect-error TS ArrayLike doesn't accept strings for some reason
|
||||
safePushApply(a, c);
|
||||
t.deepEqual(a, [1, 2, 3, 4, '5', '6', '7'], 'works with arraylike source');
|
||||
|
||||
t.end();
|
||||
});
|
||||
9
node_modules/safe-push-apply/tsconfig.json
generated
vendored
Normal file
9
node_modules/safe-push-apply/tsconfig.json
generated
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"extends": "@ljharb/tsconfig",
|
||||
"compilerOptions": {
|
||||
"target": "es2021",
|
||||
},
|
||||
"exclude": [
|
||||
"coverage",
|
||||
],
|
||||
}
|
||||
Reference in New Issue
Block a user