|
| 1 | +// deno-lint-ignore-file no-explicit-any |
1 | 2 | /*!
|
2 | 3 | * Copyright (c) 2024-2025 Nicholas Berlette. All rights reserved.
|
3 | 4 | * @license MIT (https://nick.mit-license.org/2024)
|
4 | 5 | * @see https://jsr.io/@nick/[email protected]/doc/primordials
|
5 | 6 | */
|
6 | 7 | import { $globalThis } from "./global_this.ts";
|
| 8 | +import type * as T from "./types.ts"; |
7 | 9 |
|
8 |
| -export const Array = $globalThis.Array; |
9 |
| -export const Object = $globalThis.Object; |
10 |
| -export const Function = $globalThis.Function; |
11 |
| -export const String = $globalThis.String; |
12 |
| -export const Number = $globalThis.Number; |
13 |
| -export const Boolean = $globalThis.Boolean; |
14 |
| -export const Date = $globalThis.Date; |
15 |
| -export const RegExp = $globalThis.RegExp; |
16 |
| -export const Error = $globalThis.Error; |
17 |
| -export const Symbol = $globalThis.Symbol; |
| 10 | +export const Array: ArrayConstructor = $globalThis.Array; |
| 11 | +export const String: StringConstructor = $globalThis.String; |
| 12 | +export const Number: NumberConstructor = $globalThis.Number; |
| 13 | +export const Boolean: BooleanConstructor = $globalThis.Boolean; |
| 14 | +export const Date: DateConstructor = $globalThis.Date; |
| 15 | +export const RegExp: RegExpConstructor = $globalThis.RegExp; |
| 16 | + |
| 17 | +export const Object: ObjectConstructor = $globalThis.Object; |
| 18 | +export const ObjectPrototype: Object = Object.prototype; |
| 19 | +export const ObjectKeys: <O>(o: O) => T.ObjectKeys<O> = Object.keys; |
| 20 | +export const ObjectValues: <O>(o: O) => T.ObjectValues<O> = Object.values; |
| 21 | +export const ObjectEntries: <O>(o: O) => T.ObjectEntries<O> = Object.entries; |
| 22 | +export const ObjectGetPrototypeOf: (o: any) => any = Object.getPrototypeOf; |
| 23 | +export const ObjectGetOwnPropertyDescriptor: <O, K extends keyof any>( |
| 24 | + o: O, |
| 25 | + k: K, |
| 26 | +) => |
| 27 | + | ( |
| 28 | + & TypedPropertyDescriptor<K extends keyof O ? O[K] : any> |
| 29 | + & ThisType<O> |
| 30 | + ) |
| 31 | + | undefined = Object.getOwnPropertyDescriptor; |
| 32 | + |
| 33 | +export const Symbol: SymbolConstructor = $globalThis.Symbol; |
18 | 34 | export const SymbolFor: typeof Symbol.for = Symbol.for;
|
19 | 35 | export const SymbolKeyFor: typeof Symbol.keyFor = Symbol.keyFor;
|
20 |
| -export const SymbolToStringTag: typeof Symbol.toStringTag = Symbol.toStringTag; |
21 |
| -export const SymbolIterator: typeof Symbol.iterator = Symbol.iterator; |
22 |
| -export const SymbolAsyncIterator: typeof Symbol.asyncIterator = |
23 |
| - Symbol.asyncIterator; |
24 |
| -export const SymbolHasInstance: typeof Symbol.hasInstance = Symbol.hasInstance; |
25 |
| -export const TypeError = $globalThis.TypeError; |
26 |
| -export const ReferenceError = $globalThis.ReferenceError; |
27 |
| -export const SyntaxError = $globalThis.SyntaxError; |
28 |
| -export const RangeError = $globalThis.RangeError; |
29 |
| -export const EvalError = $globalThis.EvalError; |
30 |
| -export const URIError = $globalThis.URIError; |
31 |
| -export const Proxy = $globalThis.Proxy; |
32 |
| -export const Reflect = $globalThis.Reflect; |
33 |
| -export const Set = $globalThis.Set; |
34 |
| -export const Map = $globalThis.Map; |
35 |
| -export const WeakMap = $globalThis.WeakMap; |
36 |
| -export const WeakSet = $globalThis.WeakSet; |
37 |
| -export const ArrayBuffer = $globalThis.ArrayBuffer; |
38 |
| -export const DataView = $globalThis.DataView; |
39 |
| -export const Int8Array = $globalThis.Int8Array; |
40 |
| -export const Uint8Array = $globalThis.Uint8Array; |
41 |
| -export const Uint8ClampedArray = $globalThis.Uint8ClampedArray; |
42 |
| -export const Int16Array = $globalThis.Int16Array; |
43 |
| -export const Uint16Array = $globalThis.Uint16Array; |
44 |
| -export const Int32Array = $globalThis.Int32Array; |
45 |
| -export const Uint32Array = $globalThis.Uint32Array; |
46 |
| -export const Float16Array = $globalThis.Float16Array; |
47 |
| -export const Float32Array = $globalThis.Float32Array; |
48 |
| -export const Float64Array = $globalThis.Float64Array; |
49 |
| -export const BigInt64Array = $globalThis.BigInt64Array; |
50 |
| -export const BigUint64Array = $globalThis.BigUint64Array; |
| 36 | +export const SymbolToStringTag: SymbolToStringTag = Symbol.toStringTag; |
| 37 | +export type SymbolToStringTag = typeof Symbol.toStringTag; |
| 38 | +export const SymbolIterator: SymbolIterator = Symbol.iterator; |
| 39 | +export type SymbolIterator = typeof Symbol.iterator; |
| 40 | +export const SymbolAsyncIterator: SymbolAsyncIterator = Symbol.asyncIterator; |
| 41 | +export type SymbolAsyncIterator = typeof Symbol.asyncIterator; |
| 42 | +export const SymbolHasInstance: SymbolHasInstance = Symbol.hasInstance; |
| 43 | +export type SymbolHasInstance = typeof Symbol.hasInstance; |
| 44 | +export const SymbolDispose: SymbolDispose = Symbol.dispose; |
| 45 | +export type SymbolDispose = typeof Symbol.dispose; |
| 46 | +export const SymbolAsyncDispose: SymbolAsyncDispose = Symbol.asyncDispose; |
| 47 | +export type SymbolAsyncDispose = typeof Symbol.asyncDispose; |
| 48 | +export const SymbolMetadata: SymbolMetadata = Symbol.metadata; |
| 49 | +export type SymbolMetadata = typeof Symbol.metadata; |
| 50 | +export const SymbolIsConcatSpreadable: SymbolIsConcatSpreadable = Symbol |
| 51 | + .isConcatSpreadable; |
| 52 | +export type SymbolIsConcatSpreadable = typeof Symbol.isConcatSpreadable; |
| 53 | + |
| 54 | +export const Function: FunctionConstructor = $globalThis.Function; |
| 55 | +export const FunctionPrototype: Function = Function.prototype; |
| 56 | +export type FunctionPrototype = typeof Function.prototype; |
| 57 | + |
| 58 | +export const { |
| 59 | + bind, |
| 60 | + call, |
| 61 | + apply, |
| 62 | + toString, |
| 63 | + [SymbolHasInstance]: hasInstance, |
| 64 | +} = FunctionPrototype; |
| 65 | + |
| 66 | +export const uncurryThis = bind.bind(call) as < |
| 67 | + T, |
| 68 | + const A extends readonly unknown[], |
| 69 | + R = unknown, |
| 70 | +>(fn: (this: T, ...args: A) => R) => (target: T, ...args: A) => R; |
| 71 | + |
| 72 | +export const FunctionPrototypeBind = uncurryThis( |
| 73 | + bind as CallableFunction["bind"], |
| 74 | +); |
| 75 | +export const FunctionPrototypeCall = uncurryThis( |
| 76 | + call as CallableFunction["call"], |
| 77 | +); |
| 78 | +export const FunctionPrototypeApply = uncurryThis( |
| 79 | + apply as CallableFunction["apply"], |
| 80 | +); |
| 81 | +export const FunctionPrototypeToString = uncurryThis( |
| 82 | + toString as CallableFunction["toString"], |
| 83 | +); |
| 84 | +export const FunctionPrototypeHasInstance = uncurryThis( |
| 85 | + hasInstance as CallableFunction[SymbolHasInstance], |
| 86 | +); |
| 87 | + |
| 88 | +export const Error: ErrorConstructor = $globalThis.Error; |
| 89 | +export const ErrorCaptureStackTrace: typeof Error.captureStackTrace = |
| 90 | + Error.captureStackTrace; |
| 91 | +export const TypeError: TypeErrorConstructor = $globalThis.TypeError; |
| 92 | +export const ReferenceError: ReferenceErrorConstructor = |
| 93 | + $globalThis.ReferenceError; |
| 94 | +export const SyntaxError: SyntaxErrorConstructor = $globalThis.SyntaxError; |
| 95 | +export const RangeError: RangeErrorConstructor = $globalThis.RangeError; |
| 96 | +export const EvalError: EvalErrorConstructor = $globalThis.EvalError; |
| 97 | +export const URIError: URIErrorConstructor = $globalThis.URIError; |
| 98 | + |
| 99 | +export const Reflect: typeof $globalThis.Reflect = $globalThis.Reflect; |
| 100 | +export const Atomics: typeof $globalThis.Atomics = $globalThis.Atomics; |
| 101 | + |
| 102 | +export const Proxy: ProxyConstructor = $globalThis.Proxy; |
| 103 | +export const Set: SetConstructor = $globalThis.Set; |
| 104 | +export const Map: MapConstructor = $globalThis.Map; |
| 105 | +export const WeakMap: WeakMapConstructor = $globalThis.WeakMap; |
| 106 | +export const WeakSet: WeakSetConstructor = $globalThis.WeakSet; |
| 107 | +export const WeakRef: WeakRefConstructor = $globalThis.WeakRef; |
| 108 | + |
| 109 | +export const ArrayBuffer: ArrayBufferConstructor = $globalThis.ArrayBuffer; |
| 110 | +export const SharedArrayBuffer: SharedArrayBufferConstructor = |
| 111 | + $globalThis.SharedArrayBuffer; |
| 112 | +export const DataView: DataViewConstructor = $globalThis.DataView; |
| 113 | +export const Int8Array: Int8ArrayConstructor = $globalThis.Int8Array; |
| 114 | +export const Int16Array: Int16ArrayConstructor = $globalThis.Int16Array; |
| 115 | +export const Int32Array: Int32ArrayConstructor = $globalThis.Int32Array; |
| 116 | +export const Uint8Array: Uint8ArrayConstructor = $globalThis.Uint8Array; |
| 117 | +export const Uint8ClampedArray: Uint8ClampedArrayConstructor = |
| 118 | + $globalThis.Uint8ClampedArray; |
| 119 | +export const Uint16Array: Uint16ArrayConstructor = $globalThis.Uint16Array; |
| 120 | +export const Uint32Array: Uint32ArrayConstructor = $globalThis.Uint32Array; |
| 121 | +export const Float16Array: Float16ArrayConstructor = $globalThis.Float16Array; |
| 122 | +export const Float32Array: Float32ArrayConstructor = $globalThis.Float32Array; |
| 123 | +export const Float64Array: Float64ArrayConstructor = $globalThis.Float64Array; |
| 124 | +export const BigInt64Array: BigInt64ArrayConstructor = |
| 125 | + $globalThis.BigInt64Array; |
| 126 | +export const BigUint64Array: BigUint64ArrayConstructor = |
| 127 | + $globalThis.BigUint64Array; |
0 commit comments