summaryrefslogtreecommitdiff
path: root/ext/webidl/00_webidl.js
diff options
context:
space:
mode:
authorLuca Casonato <hello@lcas.dev>2024-08-26 12:24:27 +0200
committerGitHub <noreply@github.com>2024-08-26 12:24:27 +0200
commite53678fd5841fe7b94f8f9e16d6521201a3d2993 (patch)
tree8954b7d1e04f3319c3c71b7b7f9ca16529a8edd5 /ext/webidl/00_webidl.js
parent675539c7ab503e5a5bdef1d17678afb7b8dc352b (diff)
Revert "feat(fetch): accept async iterables for body" (#25207)
Unfortunately this caused a regression: https://github.com/denoland/deno/issues/25203. Need to do some more upstream spec work to fix this before this can be re-landed. Reverts denoland/deno#24623
Diffstat (limited to 'ext/webidl/00_webidl.js')
-rw-r--r--ext/webidl/00_webidl.js126
1 files changed, 0 insertions, 126 deletions
diff --git a/ext/webidl/00_webidl.js b/ext/webidl/00_webidl.js
index 7440e47e7..9ea2200f3 100644
--- a/ext/webidl/00_webidl.js
+++ b/ext/webidl/00_webidl.js
@@ -26,7 +26,6 @@ const {
Float32Array,
Float64Array,
FunctionPrototypeBind,
- FunctionPrototypeCall,
Int16Array,
Int32Array,
Int8Array,
@@ -78,7 +77,6 @@ const {
StringPrototypeToWellFormed,
Symbol,
SymbolIterator,
- SymbolAsyncIterator,
SymbolToStringTag,
TypedArrayPrototypeGetBuffer,
TypedArrayPrototypeGetSymbolToStringTag,
@@ -921,127 +919,6 @@ function createSequenceConverter(converter) {
};
}
-function isAsyncIterator(obj) {
- if (obj[SymbolAsyncIterator] === undefined) {
- if (obj[SymbolIterator] === undefined) {
- return false;
- }
- }
-
- return true;
-}
-
-const AsyncIterable = Symbol("[[asyncIterable]]");
-
-function createAsyncIterableConverter(converter) {
- return function (
- V,
- prefix = undefined,
- context = undefined,
- opts = { __proto__: null },
- ) {
- if (type(V) !== "Object") {
- throw makeException(
- TypeError,
- "can not be converted to async iterable.",
- prefix,
- context,
- );
- }
-
- let isAsync = true;
- let method = V[SymbolAsyncIterator];
- if (method === undefined) {
- method = V[SymbolIterator];
-
- if (method === undefined) {
- throw makeException(
- TypeError,
- "is not iterable.",
- prefix,
- context,
- );
- }
-
- isAsync = false;
- }
-
- return {
- value: V,
- [AsyncIterable]: AsyncIterable,
- open(context) {
- const iter = FunctionPrototypeCall(method, V);
- if (type(iter) !== "Object") {
- throw new TypeError(
- `${context} could not be iterated because iterator method did not return object, but ${
- type(iter)
- }.`,
- );
- }
-
- let asyncIterator = iter;
-
- if (!isAsync) {
- asyncIterator = {
- // deno-lint-ignore require-await
- async next() {
- // deno-lint-ignore prefer-primordials
- return iter.next();
- },
- };
- }
-
- return {
- async next() {
- // deno-lint-ignore prefer-primordials
- const iterResult = await asyncIterator.next();
- if (type(iterResult) !== "Object") {
- throw TypeError(
- `${context} failed to iterate next value because the next() method did not return an object, but ${
- type(iterResult)
- }.`,
- );
- }
-
- if (iterResult.done) {
- return { done: true };
- }
-
- const iterValue = converter(
- iterResult.value,
- `${context} failed to iterate next value`,
- `The value returned from the next() method`,
- opts,
- );
-
- return { done: false, value: iterValue };
- },
- async return(reason) {
- if (asyncIterator.return === undefined) {
- return undefined;
- }
-
- // deno-lint-ignore prefer-primordials
- const returnPromiseResult = await asyncIterator.return(reason);
- if (type(returnPromiseResult) !== "Object") {
- throw TypeError(
- `${context} failed to close iterator because the return() method did not return an object, but ${
- type(returnPromiseResult)
- }.`,
- );
- }
-
- return undefined;
- },
- [SymbolAsyncIterator]() {
- return this;
- },
- };
- },
- };
- };
-}
-
function createRecordConverter(keyConverter, valueConverter) {
return (V, prefix, context, opts) => {
if (type(V) !== "Object") {
@@ -1410,11 +1287,9 @@ function setlike(obj, objPrototype, readonly) {
export {
assertBranded,
- AsyncIterable,
brand,
configureInterface,
converters,
- createAsyncIterableConverter,
createBranded,
createDictionaryConverter,
createEnumConverter,
@@ -1425,7 +1300,6 @@ export {
createSequenceConverter,
illegalConstructor,
invokeCallbackFunction,
- isAsyncIterator,
makeException,
mixinPairIterable,
requiredArguments,