diff options
author | 2023-01-20 15:52:48 +0100 | |
---|---|---|
committer | 2023-01-20 15:52:48 +0100 | |
commit | fffcd3ca86426fa5a849677f6c25eab40e308283 (patch) | |
tree | 2853f533f009ed16d6152ba5af4c7d5344feccfd | |
parent | a8d3e79246605d252dcddad159e358e2d79bd624 (diff) | |
download | astro-fffcd3ca86426fa5a849677f6c25eab40e308283.tar.gz astro-fffcd3ca86426fa5a849677f6c25eab40e308283.tar.zst astro-fffcd3ca86426fa5a849677f6c25eab40e308283.zip |
chore(webapi): Remove unused file (#5916)
-rw-r--r-- | packages/webapi/src/lib/RelativeIndexingMethod.ts | 50 |
1 files changed, 0 insertions, 50 deletions
diff --git a/packages/webapi/src/lib/RelativeIndexingMethod.ts b/packages/webapi/src/lib/RelativeIndexingMethod.ts deleted file mode 100644 index d88349b80..000000000 --- a/packages/webapi/src/lib/RelativeIndexingMethod.ts +++ /dev/null @@ -1,50 +0,0 @@ -type TypedArray = - | Int8Array - | Uint8Array - | Uint8ClampedArray - | Int16Array - | Uint16Array - | Int32Array - | Uint32Array - | Float32Array - | Float64Array - | BigInt64Array - | BigUint64Array - -export const at = { - at<T extends Array<any> | string | TypedArray>(this: T, index: number) { - index = Math.trunc(index) || 0 - - if (index < 0) index += this.length - - if (index < 0 || index >= this.length) return undefined - - return this[index] - }, -}.at - -export const initRelativeIndexingMethod = ( - target: any, - exclude: Set<string> -) => { - if (exclude.has('at')) return - - const Classes = [] - - if (!exclude.has('TypedArray')) - Classes.push( - Object.getPrototypeOf(target.Int8Array || globalThis.Int8Array) - ) - if (!exclude.has('Array')) Classes.push(target.Array || globalThis.Array) - if (!exclude.has('String')) Classes.push(target.String || globalThis.String) - - for (const Class of Classes) { - if (!Class.prototype.at) - Object.defineProperty(Class.prototype, 'at', { - value: at, - writable: true, - enumerable: false, - configurable: true, - }) - } -} |