This commit is contained in:
2023-11-02 02:38:40 +04:00
parent ad418f41e6
commit 82846fc0bb
9778 changed files with 1191953 additions and 52 deletions

15
lab3/node_modules/safe-array-concat/.eslintrc generated vendored Normal file
View File

@@ -0,0 +1,15 @@
{
"root": true,
"extends": "@ljharb",
"rules": {
"id-length": "off",
"max-lines-per-function": "off",
"new-cap": ["error", {
"capIsNewExceptions": [
"GetIntrinsic",
],
}],
},
}

View 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-array-concat
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
lab3/node_modules/safe-array-concat/.nycrc generated vendored Normal file
View 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"
]
}

26
lab3/node_modules/safe-array-concat/CHANGELOG.md generated vendored Normal file
View File

@@ -0,0 +1,26 @@
# 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.1](https://github.com/ljharb/safe-array-concat/compare/v1.0.0...v1.0.1) - 2023-09-05
### Fixed
- [Perf] set `Symbol.isConcatSpreadable` only when required [`#2`](https://github.com/ljharb/safe-array-concat/issues/2)
### Commits
- [Dev Deps] update `@ljharb/eslint-config`, `aud`, `tape` [`c0791b0`](https://github.com/ljharb/safe-array-concat/commit/c0791b00b74e70113921c32d4d1fd494b7e8f555)
- [Deps] update `get-intrinsic` [`7d07ae6`](https://github.com/ljharb/safe-array-concat/commit/7d07ae69d512bb3b6fb2131f1c824b5ffd85af9f)
## v1.0.0 - 2023-04-20
### Commits
- Initial implementation, tests, readme [`31b8e70`](https://github.com/ljharb/safe-array-concat/commit/31b8e709bbba4b01ebc51cc15cdcc7012fe58341)
- Initial commit [`83d38c6`](https://github.com/ljharb/safe-array-concat/commit/83d38c6f4cde453063393482d9129b134d403d0a)
- npm init [`516fdc2`](https://github.com/ljharb/safe-array-concat/commit/516fdc2bef306ec13f98b1f1b49c929b5308907f)
- Only apps should have lockfiles [`9cfa07b`](https://github.com/ljharb/safe-array-concat/commit/9cfa07b9112107b5ba22c74baca8cb80934a09f2)

21
lab3/node_modules/safe-array-concat/LICENSE generated vendored Normal file
View File

@@ -0,0 +1,21 @@
MIT License
Copyright (c) 2023 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.

53
lab3/node_modules/safe-array-concat/README.md generated vendored Normal file
View File

@@ -0,0 +1,53 @@
# safe-array-concat <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]
`Array.prototype.concat`, but made safe by ignoring Symbol.isConcatSpreadable
## Getting started
```sh
npm install --save safe-array-concat
```
## Usage/Examples
```js
var safeConcat = require('safe-array-concat');
var assert = require('assert');
assert.deepEqual([].concat([1, 2], 3, [[4]]), [1, 2, 3, [4]], 'arrays spread as expected with normal concat');
assert.deepEqual(safeConcat([1, 2], 3, [[4]]), [1, 2, 3, [4]], 'arrays spread as expected with safe concat');
String.prototype[Symbol.isConcatSpreadable] = true;
assert.deepEqual([].concat('foo', Object('bar')), ['foo', 'b', 'a', 'r'], 'spreadable String objects are spread with normal concat!!!');
assert.deepEqual(safeConcat('foo', Object('bar')), ['foo', Object('bar')], 'spreadable String objects are not spread with safe concat');
Array.prototype[Symbol.isConcatSpreadable] = false;
assert.deepEqual([].concat([1, 2], 3, [[4]]), [[], [1, 2], 3, [[4]]], 'non-concat-spreadable arrays do not spread with normal concat!!!');
assert.deepEqual(safeConcat([1, 2], 3, [[4]]), [1, 2, 3, [4]], 'non-concat-spreadable arrays still spread with safe concat');
```
## Tests
Simply clone the repo, `npm install`, and run `npm test`
[package-url]: https://npmjs.org/package/safe-array-concat
[npm-version-svg]: https://versionbadg.es/ljharb/safe-array-concat.svg
[deps-svg]: https://david-dm.org/ljharb/safe-array-concat.svg
[deps-url]: https://david-dm.org/ljharb/safe-array-concat
[dev-deps-svg]: https://david-dm.org/ljharb/safe-array-concat/dev-status.svg
[dev-deps-url]: https://david-dm.org/ljharb/safe-array-concat#info=devDependencies
[npm-badge-png]: https://nodei.co/npm/safe-array-concat.png?downloads=true&stars=true
[license-image]: https://img.shields.io/npm/l/safe-array-concat.svg
[license-url]: LICENSE
[downloads-image]: https://img.shields.io/npm/dm/safe-array-concat.svg
[downloads-url]: https://npm-stat.com/charts.html?package=safe-array-concat
[codecov-image]: https://codecov.io/gh/ljharb/safe-array-concat/branch/main/graphs/badge.svg
[codecov-url]: https://app.codecov.io/gh/ljharb/safe-array-concat/
[actions-image]: https://img.shields.io/endpoint?url=https://github-actions-badge-u3jn4tfpocch.runkit.sh/ljharb/safe-array-concat
[actions-url]: https://github.com/ljharb/safe-array-concat/actions

36
lab3/node_modules/safe-array-concat/index.js generated vendored Normal file
View File

@@ -0,0 +1,36 @@
'use strict';
var GetIntrinsic = require('get-intrinsic');
var $concat = GetIntrinsic('%Array.prototype.concat%');
var callBind = require('call-bind');
var callBound = require('call-bind/callBound');
var $slice = callBound('Array.prototype.slice');
var hasSymbols = require('has-symbols/shams')();
var isConcatSpreadable = hasSymbols && Symbol.isConcatSpreadable;
var empty = [];
var $concatApply = isConcatSpreadable ? callBind.apply($concat, empty) : null;
var $concatCall = isConcatSpreadable ? null : callBind($concat, empty);
var isArray = isConcatSpreadable ? require('isarray') : null;
module.exports = isConcatSpreadable
// eslint-disable-next-line no-unused-vars
? function safeArrayConcat(item) {
for (var i = 0; i < arguments.length; i += 1) {
var arg = arguments[i];
if (arg && typeof arg === 'object' && typeof arg[isConcatSpreadable] === 'boolean') {
if (!empty[isConcatSpreadable]) {
empty[isConcatSpreadable] = true;
}
var arr = isArray(arg) ? $slice(arg) : [arg];
arr[isConcatSpreadable] = true; // shadow the property. TODO: use [[Define]]
arguments[i] = arr;
}
}
return $concatApply(arguments);
}
: $concatCall;

78
lab3/node_modules/safe-array-concat/package.json generated vendored Normal file
View File

@@ -0,0 +1,78 @@
{
"name": "safe-array-concat",
"version": "1.0.1",
"description": "`Array.prototype.concat`, but made safe by ignoring Symbol.isConcatSpreadable",
"main": "index.js",
"exports": {
".": "./index.js",
"./package.json": "./package.json"
},
"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)\")\"",
"lint": "eslint --ext=js,mjs .",
"postlint": "evalmd README.md",
"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": "aud --production"
},
"keywords": [
"safe",
"Array",
"concat",
"push",
"isConcatSpreadable"
],
"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-array-concat.git"
},
"bugs": {
"url": "https://github.com/ljharb/safe-array-concat/issues"
},
"homepage": "https://github.com/ljharb/safe-array-concat#readme",
"devDependencies": {
"@ljharb/eslint-config": "^21.1.0",
"aud": "^2.0.3",
"auto-changelog": "^2.4.0",
"eslint": "=8.8.0",
"evalmd": "^0.0.19",
"in-publish": "^2.0.1",
"mock-property": "^1.0.0",
"npmignore": "^0.3.0",
"nyc": "^10.3.2",
"safe-publish-latest": "^2.0.0",
"tape": "^5.6.6"
},
"dependencies": {
"call-bind": "^1.0.2",
"get-intrinsic": "^1.2.1",
"has-symbols": "^1.0.3",
"isarray": "^2.0.5"
},
"auto-changelog": {
"output": "CHANGELOG.md",
"template": "keepachangelog",
"unreleased": false,
"commitLimit": false,
"backfillLimit": false,
"hideCredit": true
},
"publishConfig": {
"ignore": [
".github/workflows"
]
},
"engines": {
"node": ">=0.4"
}
}

89
lab3/node_modules/safe-array-concat/test/index.js generated vendored Normal file
View File

@@ -0,0 +1,89 @@
'use strict';
var test = require('tape');
var mockProperty = require('mock-property');
var hasSymbols = require('has-symbols/shams')();
var isConcatSpreadable = hasSymbols && Symbol.isConcatSpreadable;
var species = hasSymbols && Symbol.species;
var boundFnsHaveConfigurableLengths = Object.getOwnPropertyDescriptor && Object.getOwnPropertyDescriptor(function () {}.bind(), 'length').configurable;
var safeConcat = require('../');
test('safe-array-concat', function (t) {
t.equal(typeof safeConcat, 'function', 'is a function');
t.equal(
safeConcat.length,
boundFnsHaveConfigurableLengths ? 1 : 0,
'has a length of ' + (boundFnsHaveConfigurableLengths ? 1 : '0 (function lengths are not configurable)'),
'length is as expected'
);
t.deepEqual(
safeConcat([1, 2], [3, 4], 'foo', 5, 6, [[7]]),
[1, 2, 3, 4, 'foo', 5, 6, [7]],
'works with flat and nested arrays'
);
t.deepEqual(
safeConcat(undefined, 1, 2),
[undefined, 1, 2],
'first item as undefined is not the concat receiver, which would throw via ToObject'
);
t.deepEqual(
safeConcat(null, 1, 2),
[null, 1, 2],
'first item as null is not the concat receiver, which would throw via ToObject'
);
var arr = [1, 2];
arr.constructor = function C() {
return { args: arguments };
};
t.deepEqual(
safeConcat(arr, 3, 4),
[1, 2, 3, 4],
'first item as an array with a nonArray .constructor; ignores constructor'
);
t.test('has Symbol.species', { skip: !species }, function (st) {
var speciesArr = [1, 2];
speciesArr.constructor = {};
speciesArr.constructor[species] = function Species() {
return { args: arguments };
};
st.deepEqual(
safeConcat(speciesArr, 3, 4),
[1, 2, 3, 4],
'first item as an array with a .constructor object with a Symbol.species; ignores constructor and species'
);
st.end();
});
t.test('has isConcatSpreadable', { skip: !isConcatSpreadable }, function (st) {
st.teardown(mockProperty(String.prototype, isConcatSpreadable, { value: true }));
var nonSpreadable = [1, 2];
nonSpreadable[isConcatSpreadable] = false;
st.deepEqual(
safeConcat(nonSpreadable, 3, 4, 'foo', Object('bar')),
[1, 2, 3, 4, 'foo', Object('bar')],
'a non-concat-spreadable array is spreaded, and a concat-spreadable String is not spreaded'
);
st.teardown(mockProperty(Array.prototype, isConcatSpreadable, { value: false }));
st.deepEqual(
safeConcat([1, 2], 3, 4, 'foo', Object('bar')),
[1, 2, 3, 4, 'foo', Object('bar')],
'all arrays marked non-concat-spreadable are still spreaded, and a concat-spreadable String is not spreaded'
);
st.end();
});
t.end();
});