mirror of
https://github.com/denoland/deno.git
synced 2024-11-28 16:20:57 -05:00
49e3ee010c
This commit adds: - `addAbortListener` in `node:events` - `aborted` in `node:util` - `execPath` and `execvArgs` named export from `node:process` - `getDefaultHighWaterMark` from `node:stream` The `execPath` is very hacky - because module namespaces can not have real getters, `execPath` is an object with a `toString()` method that on call returns the actual `execPath`, and replaces the `execPath` binding with the string. This is done so that we don't require the `execPath` permission on startup.
32 lines
1.1 KiB
TypeScript
32 lines
1.1 KiB
TypeScript
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
|
|
|
|
import { assert, assertEquals } from "@std/assert";
|
|
import { fromFileUrl, relative } from "@std/path";
|
|
import { pipeline } from "node:stream/promises";
|
|
// @ts-expect-error: @types/node is outdated
|
|
import { getDefaultHighWaterMark } from "node:stream";
|
|
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
|
|
}
|
|
});
|
|
|
|
Deno.test("stream getDefaultHighWaterMark", () => {
|
|
assertEquals(getDefaultHighWaterMark(false), 16 * 1024);
|
|
assertEquals(getDefaultHighWaterMark(true), 16);
|
|
});
|