save code
This commit is contained in:
+15
@@ -0,0 +1,15 @@
|
||||
{
|
||||
"root": true,
|
||||
|
||||
"extends": "@ljharb",
|
||||
|
||||
"rules": {
|
||||
"id-length": "off",
|
||||
"max-lines-per-function": "off",
|
||||
"new-cap": ["error", {
|
||||
"capIsNewExceptions": [
|
||||
"GetIntrinsic",
|
||||
],
|
||||
}],
|
||||
},
|
||||
}
|
||||
+13
@@ -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"
|
||||
]
|
||||
}
|
||||
+21
@@ -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.
|
||||
+43
@@ -0,0 +1,43 @@
|
||||
'use strict';
|
||||
|
||||
var GetIntrinsic = require('get-intrinsic');
|
||||
var $concat = GetIntrinsic('%Array.prototype.concat%');
|
||||
|
||||
var callBind = require('call-bind');
|
||||
|
||||
var callBound = require('call-bound');
|
||||
var $slice = callBound('Array.prototype.slice');
|
||||
|
||||
var hasSymbols = require('has-symbols/shams')();
|
||||
var isConcatSpreadable = hasSymbols && Symbol.isConcatSpreadable;
|
||||
|
||||
/** @type {never[]} */ var empty = [];
|
||||
var $concatApply = isConcatSpreadable ? callBind.apply($concat, empty) : null;
|
||||
|
||||
// eslint-disable-next-line no-extra-parens
|
||||
var isArray = isConcatSpreadable ? /** @type {(value: unknown) => value is unknown[]} */ (require('isarray')) : null;
|
||||
|
||||
/** @type {import('.')} */
|
||||
module.exports = isConcatSpreadable
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
? function safeArrayConcat(item) {
|
||||
for (var i = 0; i < arguments.length; i += 1) {
|
||||
/** @type {typeof item} */ var arg = arguments[i];
|
||||
// @ts-expect-error ts(2538) see https://github.com/microsoft/TypeScript/issues/9998#issuecomment-1890787975; works if `const`
|
||||
if (arg && typeof arg === 'object' && typeof arg[isConcatSpreadable] === 'boolean') {
|
||||
// @ts-expect-error ts(7015) TS doesn't yet support Symbol indexing
|
||||
if (!empty[isConcatSpreadable]) {
|
||||
// @ts-expect-error ts(7015) TS doesn't yet support Symbol indexing
|
||||
empty[isConcatSpreadable] = true;
|
||||
}
|
||||
// @ts-expect-error ts(2721) ts(18047) not sure why TS can't figure out this can't be null
|
||||
var arr = isArray(arg) ? $slice(arg) : [arg];
|
||||
// @ts-expect-error ts(7015) TS can't handle expandos on an array
|
||||
arr[isConcatSpreadable] = true; // shadow the property. TODO: use [[Define]]
|
||||
arguments[i] = arr;
|
||||
}
|
||||
}
|
||||
// @ts-expect-error ts(2345) https://github.com/microsoft/TypeScript/issues/57164 TS doesn't understand that apply can take an arguments object
|
||||
return $concatApply(arguments);
|
||||
}
|
||||
: callBind($concat, empty);
|
||||
Reference in New Issue
Block a user