mirror of
https://github.com/denoland/deno.git
synced 2025-03-03 17:34:47 -05:00
fix(core): Add Generator
and AsyncGenerator
to promordials (#17241)
This commit is contained in:
parent
d5634164cb
commit
1dc3609ff2
4 changed files with 179 additions and 93 deletions
|
@ -248,24 +248,6 @@
|
||||||
copyPrototype(original.prototype, primordials, `${name}Prototype`);
|
copyPrototype(original.prototype, primordials, `${name}Prototype`);
|
||||||
});
|
});
|
||||||
|
|
||||||
const {
|
|
||||||
ArrayPrototypeForEach,
|
|
||||||
ArrayPrototypeMap,
|
|
||||||
FunctionPrototypeCall,
|
|
||||||
Map,
|
|
||||||
ObjectDefineProperty,
|
|
||||||
ObjectFreeze,
|
|
||||||
ObjectPrototypeIsPrototypeOf,
|
|
||||||
ObjectSetPrototypeOf,
|
|
||||||
Promise,
|
|
||||||
PromisePrototype,
|
|
||||||
PromisePrototypeThen,
|
|
||||||
Set,
|
|
||||||
SymbolIterator,
|
|
||||||
WeakMap,
|
|
||||||
WeakSet,
|
|
||||||
} = primordials;
|
|
||||||
|
|
||||||
// Create copies of abstract intrinsic objects that are not directly exposed
|
// Create copies of abstract intrinsic objects that are not directly exposed
|
||||||
// on the global object.
|
// on the global object.
|
||||||
// Refs: https://tc39.es/ecma262/#sec-%typedarray%-intrinsic-object
|
// Refs: https://tc39.es/ecma262/#sec-%typedarray%-intrinsic-object
|
||||||
|
@ -295,6 +277,11 @@
|
||||||
prototype: Reflect.getPrototypeOf(String.prototype[Symbol.iterator]()),
|
prototype: Reflect.getPrototypeOf(String.prototype[Symbol.iterator]()),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
{ name: "Generator", original: Reflect.getPrototypeOf(function* () {}) },
|
||||||
|
{
|
||||||
|
name: "AsyncGenerator",
|
||||||
|
original: Reflect.getPrototypeOf(async function* () {}),
|
||||||
|
},
|
||||||
].forEach(({ name, original }) => {
|
].forEach(({ name, original }) => {
|
||||||
primordials[name] = original;
|
primordials[name] = original;
|
||||||
// The static %TypedArray% methods require a valid `this`, but can't be bound,
|
// The static %TypedArray% methods require a valid `this`, but can't be bound,
|
||||||
|
@ -303,6 +290,20 @@
|
||||||
copyPrototype(original.prototype, primordials, `${name}Prototype`);
|
copyPrototype(original.prototype, primordials, `${name}Prototype`);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const {
|
||||||
|
ArrayPrototypeForEach,
|
||||||
|
ArrayPrototypeMap,
|
||||||
|
FunctionPrototypeCall,
|
||||||
|
ObjectDefineProperty,
|
||||||
|
ObjectFreeze,
|
||||||
|
ObjectPrototypeIsPrototypeOf,
|
||||||
|
ObjectSetPrototypeOf,
|
||||||
|
Promise,
|
||||||
|
PromisePrototype,
|
||||||
|
PromisePrototypeThen,
|
||||||
|
SymbolIterator,
|
||||||
|
} = primordials;
|
||||||
|
|
||||||
// Because these functions are used by `makeSafe`, which is exposed
|
// Because these functions are used by `makeSafe`, which is exposed
|
||||||
// on the `primordials` object, it's important to use const references
|
// on the `primordials` object, it's important to use const references
|
||||||
// to the primordials that they use:
|
// to the primordials that they use:
|
||||||
|
|
214
core/internal.d.ts
vendored
214
core/internal.d.ts
vendored
|
@ -58,16 +58,48 @@ declare namespace __bootstrap {
|
||||||
export function uncurryThis<T extends (...args: unknown[]) => unknown>(
|
export function uncurryThis<T extends (...args: unknown[]) => unknown>(
|
||||||
fn: T,
|
fn: T,
|
||||||
): (self: ThisType<T>, ...args: Parameters<T>) => ReturnType<T>;
|
): (self: ThisType<T>, ...args: Parameters<T>) => ReturnType<T>;
|
||||||
|
export function applyBind<T extends (...args: unknown[]) => unknown>(
|
||||||
|
fn: T,
|
||||||
|
): (self: ThisType<T>, args: Parameters<T>) => ReturnType<T>;
|
||||||
|
|
||||||
|
// safe objects
|
||||||
export function makeSafe<T extends NewableFunction>(
|
export function makeSafe<T extends NewableFunction>(
|
||||||
unsafe: NewableFunction,
|
unsafe: NewableFunction,
|
||||||
safe: T,
|
safe: T,
|
||||||
): T;
|
): T;
|
||||||
|
export const SafeMap: typeof globalThis.Map;
|
||||||
|
export const SafeWeakMap: typeof globalThis.WeakMap;
|
||||||
|
export const SafeSet: typeof globalThis.Set;
|
||||||
|
export const SafeWeakSet: typeof globalThis.WeakSet;
|
||||||
|
export const SafeFinalizationRegistry:
|
||||||
|
typeof globalThis.FinalizationRegistry;
|
||||||
|
export const SafeWeakRef: typeof globalThis.WeakRef;
|
||||||
|
export const SafePromiseAll: typeof Promise.all;
|
||||||
|
export const SafePromisePrototypeFinally: UncurryThis<
|
||||||
|
Promise.prototype.finally
|
||||||
|
>;
|
||||||
|
|
||||||
|
// safe iterators
|
||||||
|
export const SafeArrayIterator: new <T>(array: T[]) => IterableIterator<T>;
|
||||||
|
export const SafeSetIterator: new <T>(set: Set<T>) => IterableIterator<T>;
|
||||||
|
export const SafeMapIterator: new <K, V>(
|
||||||
|
map: Map<K, V>,
|
||||||
|
) => IterableIterator<[K, V]>;
|
||||||
|
export const SafeStringIterator: new (
|
||||||
|
str: string,
|
||||||
|
) => IterableIterator<string>;
|
||||||
|
|
||||||
|
// intrinsic objects
|
||||||
|
export const indirectEval: typeof globalThis.eval;
|
||||||
export const isNaN: typeof globalThis.isNaN;
|
export const isNaN: typeof globalThis.isNaN;
|
||||||
export const decodeURI: typeof globalThis.decodeURI;
|
export const decodeURI: typeof globalThis.decodeURI;
|
||||||
export const decodeURIComponent: typeof globalThis.decodeURIComponent;
|
export const decodeURIComponent: typeof globalThis.decodeURIComponent;
|
||||||
export const encodeURI: typeof globalThis.encodeURI;
|
export const encodeURI: typeof globalThis.encodeURI;
|
||||||
export const encodeURIComponent: typeof globalThis.encodeURIComponent;
|
export const encodeURIComponent: typeof globalThis.encodeURIComponent;
|
||||||
|
export const queueMicrotask: typeof globalThis.queueMicrotask;
|
||||||
|
export const setQueueMicrotask: (
|
||||||
|
queueMicrotask: typeof globalThis.queueMicrotask,
|
||||||
|
) => void;
|
||||||
export const JSONParse: typeof JSON.parse;
|
export const JSONParse: typeof JSON.parse;
|
||||||
export const JSONStringify: typeof JSON.stringify;
|
export const JSONStringify: typeof JSON.stringify;
|
||||||
export const MathAbs: typeof Math.abs;
|
export const MathAbs: typeof Math.abs;
|
||||||
|
@ -88,6 +120,7 @@ declare namespace __bootstrap {
|
||||||
export const MathFloor: typeof Math.floor;
|
export const MathFloor: typeof Math.floor;
|
||||||
export const MathFround: typeof Math.fround;
|
export const MathFround: typeof Math.fround;
|
||||||
export const MathHypot: typeof Math.hypot;
|
export const MathHypot: typeof Math.hypot;
|
||||||
|
export const MathHypotApply: StaticApply<typeof Math.hypot>;
|
||||||
export const MathImul: typeof Math.imul;
|
export const MathImul: typeof Math.imul;
|
||||||
export const MathLog: typeof Math.log;
|
export const MathLog: typeof Math.log;
|
||||||
export const MathLog1p: typeof Math.log1p;
|
export const MathLog1p: typeof Math.log1p;
|
||||||
|
@ -96,6 +129,7 @@ declare namespace __bootstrap {
|
||||||
export const MathMax: typeof Math.max;
|
export const MathMax: typeof Math.max;
|
||||||
export const MathMaxApply: StaticApply<typeof Math.max>;
|
export const MathMaxApply: StaticApply<typeof Math.max>;
|
||||||
export const MathMin: typeof Math.min;
|
export const MathMin: typeof Math.min;
|
||||||
|
export const MathMinApply: StaticApply<typeof Math.min>;
|
||||||
export const MathPow: typeof Math.pow;
|
export const MathPow: typeof Math.pow;
|
||||||
export const MathRandom: typeof Math.random;
|
export const MathRandom: typeof Math.random;
|
||||||
export const MathRound: typeof Math.round;
|
export const MathRound: typeof Math.round;
|
||||||
|
@ -114,6 +148,10 @@ declare namespace __bootstrap {
|
||||||
export const MathPI: typeof Math.PI;
|
export const MathPI: typeof Math.PI;
|
||||||
export const MathSQRT1_2: typeof Math.SQRT1_2;
|
export const MathSQRT1_2: typeof Math.SQRT1_2;
|
||||||
export const MathSQRT2: typeof Math.SQRT2;
|
export const MathSQRT2: typeof Math.SQRT2;
|
||||||
|
export const Proxy: typeof globalThis.Proxy;
|
||||||
|
export const ProxyLength: typeof Proxy.length;
|
||||||
|
export const ProxyName: typeof Proxy.name;
|
||||||
|
export const ProxyRevocable: typeof Proxy.revocable;
|
||||||
export const ReflectDefineProperty: typeof Reflect.defineProperty;
|
export const ReflectDefineProperty: typeof Reflect.defineProperty;
|
||||||
export const ReflectDeleteProperty: typeof Reflect.deleteProperty;
|
export const ReflectDeleteProperty: typeof Reflect.deleteProperty;
|
||||||
export const ReflectApply: typeof Reflect.apply;
|
export const ReflectApply: typeof Reflect.apply;
|
||||||
|
@ -139,6 +177,8 @@ declare namespace __bootstrap {
|
||||||
export const ArrayIsArray: typeof Array.isArray;
|
export const ArrayIsArray: typeof Array.isArray;
|
||||||
export const ArrayFrom: typeof Array.from;
|
export const ArrayFrom: typeof Array.from;
|
||||||
export const ArrayOf: typeof Array.of;
|
export const ArrayOf: typeof Array.of;
|
||||||
|
export const ArrayOfApply: StaticApply<typeof Array.of>;
|
||||||
|
export const ArrayPrototypeAt: UncurryThis<typeof Array.prototype.at>;
|
||||||
export const ArrayPrototypeConcat: UncurryThis<
|
export const ArrayPrototypeConcat: UncurryThis<
|
||||||
typeof Array.prototype.concat
|
typeof Array.prototype.concat
|
||||||
>;
|
>;
|
||||||
|
@ -475,6 +515,17 @@ declare namespace __bootstrap {
|
||||||
export const EvalErrorLength: typeof EvalError.length;
|
export const EvalErrorLength: typeof EvalError.length;
|
||||||
export const EvalErrorName: typeof EvalError.name;
|
export const EvalErrorName: typeof EvalError.name;
|
||||||
export const EvalErrorPrototype: typeof EvalError.prototype;
|
export const EvalErrorPrototype: typeof EvalError.prototype;
|
||||||
|
export const FinalizationRegistry: typeof globalThis.FinalizationRegistry;
|
||||||
|
export const FinalizationRegistryLength: typeof FinalizationRegistry.length;
|
||||||
|
export const FinalizationRegistryName: typeof FinalizationRegistry.name;
|
||||||
|
export const FinalizationRegistryPrototype:
|
||||||
|
typeof FinalizationRegistry.prototype;
|
||||||
|
export const FinalizationRegistryPrototypeRegister: UncurryThis<
|
||||||
|
typeof FinalizationRegistry.prototype.registar
|
||||||
|
>;
|
||||||
|
export const FinalizationRegistryPrototypeUnregister: UncurryThis<
|
||||||
|
typeof FinalizationRegistry.prototype.unregister
|
||||||
|
>;
|
||||||
export const Float32Array: typeof globalThis.Float32Array;
|
export const Float32Array: typeof globalThis.Float32Array;
|
||||||
export const Float32ArrayLength: typeof Float32Array.length;
|
export const Float32ArrayLength: typeof Float32Array.length;
|
||||||
export const Float32ArrayName: typeof Float32Array.name;
|
export const Float32ArrayName: typeof Float32Array.name;
|
||||||
|
@ -627,7 +678,6 @@ declare namespace __bootstrap {
|
||||||
export const ObjectPrototypeToLocaleString: UncurryThis<
|
export const ObjectPrototypeToLocaleString: UncurryThis<
|
||||||
typeof Object.prototype.toLocaleString
|
typeof Object.prototype.toLocaleString
|
||||||
>;
|
>;
|
||||||
export const queueMicrotask: typeof globalThis.queueMicrotask;
|
|
||||||
export const RangeError: typeof globalThis.RangeError;
|
export const RangeError: typeof globalThis.RangeError;
|
||||||
export const RangeErrorLength: typeof RangeError.length;
|
export const RangeErrorLength: typeof RangeError.length;
|
||||||
export const RangeErrorName: typeof RangeError.name;
|
export const RangeErrorName: typeof RangeError.name;
|
||||||
|
@ -687,6 +737,9 @@ declare namespace __bootstrap {
|
||||||
export const StringPrototypeConcat: UncurryThis<
|
export const StringPrototypeConcat: UncurryThis<
|
||||||
typeof String.prototype.concat
|
typeof String.prototype.concat
|
||||||
>;
|
>;
|
||||||
|
export const StringPrototypeConcatApply: UncurryThisStaticApply<
|
||||||
|
typeof String.prototype.concat
|
||||||
|
>;
|
||||||
export const StringPrototypeEndsWith: UncurryThis<
|
export const StringPrototypeEndsWith: UncurryThis<
|
||||||
typeof String.prototype.endsWith
|
typeof String.prototype.endsWith
|
||||||
>;
|
>;
|
||||||
|
@ -829,6 +882,99 @@ declare namespace __bootstrap {
|
||||||
export const TypeErrorLength: typeof TypeError.length;
|
export const TypeErrorLength: typeof TypeError.length;
|
||||||
export const TypeErrorName: typeof TypeError.name;
|
export const TypeErrorName: typeof TypeError.name;
|
||||||
export const TypeErrorPrototype: typeof TypeError.prototype;
|
export const TypeErrorPrototype: typeof TypeError.prototype;
|
||||||
|
export const URIError: typeof globalThis.URIError;
|
||||||
|
export const URIErrorLength: typeof URIError.length;
|
||||||
|
export const URIErrorName: typeof URIError.name;
|
||||||
|
export const URIErrorPrototype: typeof URIError.prototype;
|
||||||
|
export const Uint16Array: typeof globalThis.Uint16Array;
|
||||||
|
export const Uint16ArrayLength: typeof Uint16Array.length;
|
||||||
|
export const Uint16ArrayName: typeof Uint16Array.name;
|
||||||
|
export const Uint16ArrayPrototype: typeof Uint16Array.prototype;
|
||||||
|
export const Uint16ArrayBYTES_PER_ELEMENT:
|
||||||
|
typeof Uint16Array.BYTES_PER_ELEMENT;
|
||||||
|
export const Uint32Array: typeof globalThis.Uint32Array;
|
||||||
|
export const Uint32ArrayLength: typeof Uint32Array.length;
|
||||||
|
export const Uint32ArrayName: typeof Uint32Array.name;
|
||||||
|
export const Uint32ArrayPrototype: typeof Uint32Array.prototype;
|
||||||
|
export const Uint32ArrayBYTES_PER_ELEMENT:
|
||||||
|
typeof Uint32Array.BYTES_PER_ELEMENT;
|
||||||
|
export const Uint8Array: typeof globalThis.Uint8Array;
|
||||||
|
export const Uint8ArrayLength: typeof Uint8Array.length;
|
||||||
|
export const Uint8ArrayName: typeof Uint8Array.name;
|
||||||
|
export const Uint8ArrayPrototype: typeof Uint8Array.prototype;
|
||||||
|
export const Uint8ArrayBYTES_PER_ELEMENT:
|
||||||
|
typeof Uint8Array.BYTES_PER_ELEMENT;
|
||||||
|
export const Uint8ClampedArray: typeof globalThis.Uint8ClampedArray;
|
||||||
|
export const Uint8ClampedArrayLength: typeof Uint8ClampedArray.length;
|
||||||
|
export const Uint8ClampedArrayName: typeof Uint8ClampedArray.name;
|
||||||
|
export const Uint8ClampedArrayPrototype: typeof Uint8ClampedArray.prototype;
|
||||||
|
export const Uint8ClampedArrayBYTES_PER_ELEMENT:
|
||||||
|
typeof Uint8ClampedArray.BYTES_PER_ELEMENT;
|
||||||
|
export const WeakMap: typeof globalThis.WeakMap;
|
||||||
|
export const WeakMapLength: typeof WeakMap.length;
|
||||||
|
export const WeakMapName: typeof WeakMap.name;
|
||||||
|
export const WeakMapPrototype: typeof WeakMap.prototype;
|
||||||
|
export const WeakMapPrototypeDelete: UncurryThis<
|
||||||
|
typeof WeakMap.prototype.delete
|
||||||
|
>;
|
||||||
|
export const WeakMapPrototypeGet: UncurryThis<typeof WeakMap.prototype.get>;
|
||||||
|
export const WeakMapPrototypeSet: UncurryThis<typeof WeakMap.prototype.set>;
|
||||||
|
export const WeakMapPrototypeHas: UncurryThis<typeof WeakMap.prototype.has>;
|
||||||
|
export const WeakRef: typeof globalThis.WeakRef;
|
||||||
|
export const WeakRefLength: typeof WeakRef.length;
|
||||||
|
export const WeakRefName: typeof WeakRef.name;
|
||||||
|
export const WeakRefPrototype: typeof WeakRef.prototype;
|
||||||
|
export const WeakRefPrototypeDeref: UncurryThis<
|
||||||
|
typeof WeakRef.prototype.deref
|
||||||
|
>;
|
||||||
|
export const WeakSet: typeof globalThis.WeakSet;
|
||||||
|
export const WeakSetLength: typeof WeakSet.length;
|
||||||
|
export const WeakSetName: typeof WeakSet.name;
|
||||||
|
export const WeakSetPrototype: typeof WeakSet.prototype;
|
||||||
|
export const WeakSetPrototypeDelete: UncurryThis<
|
||||||
|
typeof WeakSet.prototype.delete
|
||||||
|
>;
|
||||||
|
export const WeakSetPrototypeHas: UncurryThis<typeof WeakSet.prototype.has>;
|
||||||
|
export const WeakSetPrototypeAdd: UncurryThis<typeof WeakSet.prototype.add>;
|
||||||
|
export const Promise: typeof globalThis.Promise;
|
||||||
|
export const PromiseLength: typeof Promise.length;
|
||||||
|
export const PromiseName: typeof Promise.name;
|
||||||
|
export const PromisePrototype: typeof Promise.prototype;
|
||||||
|
export const PromiseAll: typeof Promise.all;
|
||||||
|
export const PromiseRace: typeof Promise.race;
|
||||||
|
export const PromiseResolve: typeof Promise.resolve;
|
||||||
|
export const PromiseReject: typeof Promise.reject;
|
||||||
|
export const PromiseAllSettled: typeof Promise.allSettled;
|
||||||
|
export const PromiseAny: typeof Promise.any;
|
||||||
|
export const PromisePrototypeThen: UncurryThis<
|
||||||
|
typeof Promise.prototype.then
|
||||||
|
>;
|
||||||
|
export const PromisePrototypeCatch: UncurryThis<
|
||||||
|
typeof Promise.prototype.catch
|
||||||
|
>;
|
||||||
|
export const PromisePrototypeFinally: UncurryThis<
|
||||||
|
typeof Promise.prototype.finally
|
||||||
|
>;
|
||||||
|
|
||||||
|
// abstract intrinsic objects
|
||||||
|
export const ArrayIteratorPrototypeNext: <T>(
|
||||||
|
iterator: IterableIterator<T>,
|
||||||
|
) => IteratorResult<T>;
|
||||||
|
export const SetIteratorPrototypeNext: <T>(
|
||||||
|
iterator: IterableIterator<T>,
|
||||||
|
) => IteratorResult<T>;
|
||||||
|
export const MapIteratorPrototypeNext: <T>(
|
||||||
|
iterator: IterableIterator<T>,
|
||||||
|
) => IteratorResult<T>;
|
||||||
|
export const StringIteratorPrototypeNext: <T>(
|
||||||
|
iterator: IterableIterator<T>,
|
||||||
|
) => IteratorResult<T>;
|
||||||
|
export const GeneratorPrototypeNext: <T>(
|
||||||
|
generator: Generator<T>,
|
||||||
|
) => IteratorResult<T>;
|
||||||
|
export const AsyncGeneratorPrototypeNext: <T>(
|
||||||
|
asyncGenerator: AsyncGenerator<T>,
|
||||||
|
) => Promise<IteratorResult<T>>;
|
||||||
export const TypedArrayFrom: (
|
export const TypedArrayFrom: (
|
||||||
constructor: Uint8ArrayConstructor,
|
constructor: Uint8ArrayConstructor,
|
||||||
arrayLike: ArrayLike<number>,
|
arrayLike: ArrayLike<number>,
|
||||||
|
@ -899,71 +1045,5 @@ declare namespace __bootstrap {
|
||||||
export const TypedArrayPrototypeValueOf: UncurryThis<
|
export const TypedArrayPrototypeValueOf: UncurryThis<
|
||||||
typeof Uint8Array.prototype.valueOf
|
typeof Uint8Array.prototype.valueOf
|
||||||
>;
|
>;
|
||||||
export const URIError: typeof globalThis.URIError;
|
|
||||||
export const URIErrorLength: typeof URIError.length;
|
|
||||||
export const URIErrorName: typeof URIError.name;
|
|
||||||
export const URIErrorPrototype: typeof URIError.prototype;
|
|
||||||
export const Uint16Array: typeof globalThis.Uint16Array;
|
|
||||||
export const Uint16ArrayLength: typeof Uint16Array.length;
|
|
||||||
export const Uint16ArrayName: typeof Uint16Array.name;
|
|
||||||
export const Uint16ArrayPrototype: typeof Uint16Array.prototype;
|
|
||||||
export const Uint16ArrayBYTES_PER_ELEMENT:
|
|
||||||
typeof Uint16Array.BYTES_PER_ELEMENT;
|
|
||||||
export const Uint32Array: typeof globalThis.Uint32Array;
|
|
||||||
export const Uint32ArrayLength: typeof Uint32Array.length;
|
|
||||||
export const Uint32ArrayName: typeof Uint32Array.name;
|
|
||||||
export const Uint32ArrayPrototype: typeof Uint32Array.prototype;
|
|
||||||
export const Uint32ArrayBYTES_PER_ELEMENT:
|
|
||||||
typeof Uint32Array.BYTES_PER_ELEMENT;
|
|
||||||
export const Uint8Array: typeof globalThis.Uint8Array;
|
|
||||||
export const Uint8ArrayLength: typeof Uint8Array.length;
|
|
||||||
export const Uint8ArrayName: typeof Uint8Array.name;
|
|
||||||
export const Uint8ArrayPrototype: typeof Uint8Array.prototype;
|
|
||||||
export const Uint8ArrayBYTES_PER_ELEMENT:
|
|
||||||
typeof Uint8Array.BYTES_PER_ELEMENT;
|
|
||||||
export const Uint8ClampedArray: typeof globalThis.Uint8ClampedArray;
|
|
||||||
export const Uint8ClampedArrayLength: typeof Uint8ClampedArray.length;
|
|
||||||
export const Uint8ClampedArrayName: typeof Uint8ClampedArray.name;
|
|
||||||
export const Uint8ClampedArrayPrototype: typeof Uint8ClampedArray.prototype;
|
|
||||||
export const Uint8ClampedArrayBYTES_PER_ELEMENT:
|
|
||||||
typeof Uint8ClampedArray.BYTES_PER_ELEMENT;
|
|
||||||
export const WeakMap: typeof globalThis.WeakMap;
|
|
||||||
export const WeakMapLength: typeof WeakMap.length;
|
|
||||||
export const WeakMapName: typeof WeakMap.name;
|
|
||||||
export const WeakMapPrototype: typeof WeakMap.prototype;
|
|
||||||
export const WeakMapPrototypeDelete: UncurryThis<
|
|
||||||
typeof WeakMap.prototype.delete
|
|
||||||
>;
|
|
||||||
export const WeakMapPrototypeGet: UncurryThis<typeof WeakMap.prototype.get>;
|
|
||||||
export const WeakMapPrototypeSet: UncurryThis<typeof WeakMap.prototype.set>;
|
|
||||||
export const WeakMapPrototypeHas: UncurryThis<typeof WeakMap.prototype.has>;
|
|
||||||
export const WeakSet: typeof globalThis.WeakSet;
|
|
||||||
export const WeakSetLength: typeof WeakSet.length;
|
|
||||||
export const WeakSetName: typeof WeakSet.name;
|
|
||||||
export const WeakSetPrototype: typeof WeakSet.prototype;
|
|
||||||
export const WeakSetPrototypeDelete: UncurryThis<
|
|
||||||
typeof WeakSet.prototype.delete
|
|
||||||
>;
|
|
||||||
export const WeakSetPrototypeHas: UncurryThis<typeof WeakSet.prototype.has>;
|
|
||||||
export const WeakSetPrototypeAdd: UncurryThis<typeof WeakSet.prototype.add>;
|
|
||||||
export const Promise: typeof globalThis.Promise;
|
|
||||||
export const PromiseLength: typeof Promise.length;
|
|
||||||
export const PromiseName: typeof Promise.name;
|
|
||||||
export const PromisePrototype: typeof Promise.prototype;
|
|
||||||
export const PromiseAll: typeof Promise.all;
|
|
||||||
export const PromiseRace: typeof Promise.race;
|
|
||||||
export const PromiseResolve: typeof Promise.resolve;
|
|
||||||
export const PromiseReject: typeof Promise.reject;
|
|
||||||
export const PromiseAllSettled: typeof Promise.allSettled;
|
|
||||||
export const PromiseAny: typeof Promise.any;
|
|
||||||
export const PromisePrototypeThen: UncurryThis<
|
|
||||||
typeof Promise.prototype.then
|
|
||||||
>;
|
|
||||||
export const PromisePrototypeCatch: UncurryThis<
|
|
||||||
typeof Promise.prototype.catch
|
|
||||||
>;
|
|
||||||
export const PromisePrototypeFinally: UncurryThis<
|
|
||||||
typeof Promise.prototype.finally
|
|
||||||
>;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,6 +19,7 @@
|
||||||
ArrayPrototypeMap,
|
ArrayPrototypeMap,
|
||||||
ArrayPrototypePush,
|
ArrayPrototypePush,
|
||||||
ArrayPrototypeShift,
|
ArrayPrototypeShift,
|
||||||
|
AsyncGeneratorPrototype,
|
||||||
BigInt64ArrayPrototype,
|
BigInt64ArrayPrototype,
|
||||||
BigUint64ArrayPrototype,
|
BigUint64ArrayPrototype,
|
||||||
DataView,
|
DataView,
|
||||||
|
@ -4439,9 +4440,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @type {AsyncIterator<unknown, unknown>} */
|
/** @type {AsyncIterator<unknown, unknown>} */
|
||||||
const asyncIteratorPrototype = ObjectGetPrototypeOf(
|
const asyncIteratorPrototype = ObjectGetPrototypeOf(AsyncGeneratorPrototype);
|
||||||
ObjectGetPrototypeOf(async function* () {}).prototype,
|
|
||||||
);
|
|
||||||
|
|
||||||
const _iteratorNext = Symbol("[[iteratorNext]]");
|
const _iteratorNext = Symbol("[[iteratorNext]]");
|
||||||
const _iteratorFinished = Symbol("[[iteratorFinished]]");
|
const _iteratorFinished = Symbol("[[iteratorFinished]]");
|
||||||
|
|
|
@ -20,6 +20,7 @@
|
||||||
ArrayBufferPrototypeSlice,
|
ArrayBufferPrototypeSlice,
|
||||||
ArrayBufferIsView,
|
ArrayBufferIsView,
|
||||||
ArrayPrototypePush,
|
ArrayPrototypePush,
|
||||||
|
AsyncGeneratorPrototypeNext,
|
||||||
Date,
|
Date,
|
||||||
DatePrototypeGetTime,
|
DatePrototypeGetTime,
|
||||||
MathMax,
|
MathMax,
|
||||||
|
@ -330,7 +331,9 @@
|
||||||
/** @param {ReadableByteStreamController} controller */
|
/** @param {ReadableByteStreamController} controller */
|
||||||
async pull(controller) {
|
async pull(controller) {
|
||||||
while (true) {
|
while (true) {
|
||||||
const { value, done } = await partIterator.next();
|
const { value, done } = await AsyncGeneratorPrototypeNext(
|
||||||
|
partIterator,
|
||||||
|
);
|
||||||
if (done) return controller.close();
|
if (done) return controller.close();
|
||||||
if (value.byteLength > 0) {
|
if (value.byteLength > 0) {
|
||||||
return controller.enqueue(value);
|
return controller.enqueue(value);
|
||||||
|
@ -354,11 +357,14 @@
|
||||||
const bytes = new Uint8Array(size);
|
const bytes = new Uint8Array(size);
|
||||||
const partIterator = toIterator(this[_parts]);
|
const partIterator = toIterator(this[_parts]);
|
||||||
let offset = 0;
|
let offset = 0;
|
||||||
// deno-lint-ignore prefer-primordials
|
while (true) {
|
||||||
for await (const chunk of partIterator) {
|
const { value, done } = await AsyncGeneratorPrototypeNext(
|
||||||
const byteLength = chunk.byteLength;
|
partIterator,
|
||||||
|
);
|
||||||
|
if (done) break;
|
||||||
|
const byteLength = value.byteLength;
|
||||||
if (byteLength > 0) {
|
if (byteLength > 0) {
|
||||||
TypedArrayPrototypeSet(bytes, chunk, offset);
|
TypedArrayPrototypeSet(bytes, value, offset);
|
||||||
offset += byteLength;
|
offset += byteLength;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue