mirror of
https://github.com/denoland/deno.git
synced 2025-03-09 21:57:40 -04:00
fix(ext/node): fix stream/promises export (#19820)
This commit is contained in:
parent
690e02268d
commit
efda7fa5eb
3 changed files with 29 additions and 1 deletions
|
@ -73,6 +73,7 @@ util::unit_test_factory!(
|
||||||
process_test,
|
process_test,
|
||||||
querystring_test,
|
querystring_test,
|
||||||
readline_test,
|
readline_test,
|
||||||
|
stream_test,
|
||||||
string_decoder_test,
|
string_decoder_test,
|
||||||
timers_test,
|
timers_test,
|
||||||
tls_test,
|
tls_test,
|
||||||
|
|
25
cli/tests/unit_node/stream_test.ts
Normal file
25
cli/tests/unit_node/stream_test.ts
Normal file
|
@ -0,0 +1,25 @@
|
||||||
|
// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
|
||||||
|
|
||||||
|
import { assert } from "../../../test_util/std/testing/asserts.ts";
|
||||||
|
import { fromFileUrl, relative } from "../../../test_util/std/path/mod.ts";
|
||||||
|
import { pipeline } from "node:stream/promises";
|
||||||
|
import { createReadStream, createWriteStream } from "node:fs";
|
||||||
|
|
||||||
|
Deno.test("stream/promises pipeline", async () => {
|
||||||
|
const filePath = relative(
|
||||||
|
Deno.cwd(),
|
||||||
|
fromFileUrl(new URL("./testdata/lorem_ipsum.txt", import.meta.url)),
|
||||||
|
);
|
||||||
|
const input = createReadStream(filePath);
|
||||||
|
const output = createWriteStream("lorem_ipsum.txt.copy");
|
||||||
|
|
||||||
|
await pipeline(input, output);
|
||||||
|
|
||||||
|
const content = Deno.readTextFileSync("lorem_ipsum.txt.copy");
|
||||||
|
assert(content.startsWith("Lorem ipsum dolor sit amet"));
|
||||||
|
try {
|
||||||
|
Deno.removeSync("lorem_ipsum.txt.copy");
|
||||||
|
} catch {
|
||||||
|
// pass
|
||||||
|
}
|
||||||
|
});
|
|
@ -1,7 +1,9 @@
|
||||||
// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
|
// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
|
||||||
// Copyright Joyent and Node contributors. All rights reserved. MIT license.
|
// Copyright Joyent and Node contributors. All rights reserved. MIT license.
|
||||||
|
|
||||||
import { finished, pipeline } from "ext:deno_node/_stream.mjs";
|
import { Stream } from "ext:deno_node/_stream.mjs";
|
||||||
|
|
||||||
|
const { finished, pipeline } = Stream.promises;
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
finished,
|
finished,
|
||||||
|
|
Loading…
Add table
Reference in a new issue