mirror of
https://github.com/react/react-native-devtools-frontend.git
synced 2026-09-28 21:24:26 +08:00
This is need to be able to move to flat config which I am handling in a separate CL. The overrides are there as these packages got update today, so we need to way, but they were last touched 3 years ago, so reviewing their changes upstream as well. Bug: none Change-Id: I61534f881fd4e747c716b42b773f8f7f3e9bc761 Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/6063618 Commit-Queue: Nikolay Vitkov <nvitkov@chromium.org> Reviewed-by: Danil Somsikov <dsv@chromium.org>
44 lines
1.8 KiB
JavaScript
44 lines
1.8 KiB
JavaScript
'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;
|
|
|
|
/** @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);
|