diff options
-rw-r--r-- | cli/tests/unit/streams_deprecated.ts | 16 | ||||
-rw-r--r-- | cli/tests/unit/unit_tests.ts | 1 | ||||
-rw-r--r-- | op_crates/fetch/11_streams.js | 10 | ||||
-rw-r--r-- | op_crates/fetch/lib.deno_fetch.d.ts | 6 |
4 files changed, 32 insertions, 1 deletions
diff --git a/cli/tests/unit/streams_deprecated.ts b/cli/tests/unit/streams_deprecated.ts new file mode 100644 index 000000000..77750072c --- /dev/null +++ b/cli/tests/unit/streams_deprecated.ts @@ -0,0 +1,16 @@ +// Copyright 2018-2021 the Deno authors. All rights reserved. MIT license. +import { assertEquals, unitTest } from "./test_util.ts"; + +unitTest(async function symlinkSyncPerm() { + const rs = new ReadableStream<string>({ + start(controller) { + controller.enqueue("hello "); + controller.enqueue("deno"); + controller.close(); + }, + }); + + for await (const chunk of rs.getIterator()) { + assertEquals(typeof chunk, "string"); + } +}); diff --git a/cli/tests/unit/unit_tests.ts b/cli/tests/unit/unit_tests.ts index 69eaac3ed..8af28c1bb 100644 --- a/cli/tests/unit/unit_tests.ts +++ b/cli/tests/unit/unit_tests.ts @@ -57,6 +57,7 @@ import "./response_test.ts"; import "./signal_test.ts"; import "./stat_test.ts"; import "./stdio_test.ts"; +import "./streams_deprecated.ts"; import "./symlink_test.ts"; import "./sync_test.ts"; import "./text_encoding_test.ts"; diff --git a/op_crates/fetch/11_streams.js b/op_crates/fetch/11_streams.js index 6031fa3ef..827f8c232 100644 --- a/op_crates/fetch/11_streams.js +++ b/op_crates/fetch/11_streams.js @@ -1152,7 +1152,6 @@ // 3.5.6.8 Otherwise, support BYOB Reader /** @type {Deferred<void>} */ const closedPromise = reader[_closedPromise]; - console.log("closedPromise rejected"); closedPromise.reject(e); setPromiseIsHandledToTrue(closedPromise.promise); } @@ -3098,6 +3097,15 @@ } /** + * @deprecated TODO(@kitsonk): Remove in Deno 1.8 + * @param {ReadableStreamIteratorOptions=} options + * @returns {AsyncIterableIterator<R>} + */ + getIterator(options = {}) { + return this[Symbol.asyncIterator](options); + } + + /** * @param {ReadableStreamGetReaderOptions=} options * @returns {ReadableStreamDefaultReader<R>} */ diff --git a/op_crates/fetch/lib.deno_fetch.d.ts b/op_crates/fetch/lib.deno_fetch.d.ts index 83739f2ec..f18dbe359 100644 --- a/op_crates/fetch/lib.deno_fetch.d.ts +++ b/op_crates/fetch/lib.deno_fetch.d.ts @@ -150,6 +150,12 @@ declare class ByteLengthQueuingStrategy interface ReadableStream<R = any> { readonly locked: boolean; cancel(reason?: any): Promise<void>; + /** + * @deprecated This is no longer part of the Streams standard and the async + * iterable should be obtained by just using the stream as an + * async iterator. + */ + getIterator(options?: { preventCancel?: boolean }): AsyncIterableIterator<R>; getReader(): ReadableStreamDefaultReader<R>; pipeThrough<T>( { writable, readable }: { |