mirror of
https://github.com/denoland/deno.git
synced 2025-09-27 04:39:10 +00:00

Ref https://github.com/denoland/deno/issues/28836 This PR replaces the _stream.mjs bundle with a file-by-file port instead. A codemod transpiles Node.js internals to ESM. The codemod performs three tasks: translating CJS to ESM, remapping internal dependencies, and hoisting lazy requires as imports. The process is fully automated through the `update_node_stream.ts` script, simplifying future internal updates. The script checks out Node.js from a specific tag defined in the `tests/node_compat/runner`. Additionally, the update enables new tests in our Node test runner and adds features (like compose()) that were missing from the outdated bundle. ## Performance There is a 140KB+ binary size increase on aarch64-apple-darwin and nop startup time stays the same.
46 lines
1.2 KiB
JavaScript
46 lines
1.2 KiB
JavaScript
// deno-fmt-ignore-file
|
|
// deno-lint-ignore-file
|
|
|
|
// Copyright Joyent and Node contributors. All rights reserved. MIT license.
|
|
// Taken from Node 23.9.0
|
|
// This file is automatically generated by `tests/node_compat/runner/setup.ts`. Do not modify this file manually.
|
|
|
|
'use strict';
|
|
const common = require('../common');
|
|
const net = require('net');
|
|
const assert = require('assert');
|
|
const socket = new net.Stream({ highWaterMark: 0 });
|
|
|
|
// Make sure that anything besides a buffer or a string throws.
|
|
socket.on('error', common.mustNotCall());
|
|
assert.throws(() => {
|
|
socket.write(null);
|
|
}, {
|
|
code: 'ERR_STREAM_NULL_VALUES',
|
|
name: 'TypeError',
|
|
message: 'May not write null values to stream'
|
|
});
|
|
|
|
[
|
|
true,
|
|
false,
|
|
undefined,
|
|
1,
|
|
1.0,
|
|
+Infinity,
|
|
-Infinity,
|
|
[],
|
|
{},
|
|
].forEach((value) => {
|
|
const socket = new net.Stream({ highWaterMark: 0 });
|
|
// We need to check the callback since 'error' will only
|
|
// be emitted once per instance.
|
|
assert.throws(() => {
|
|
socket.write(value);
|
|
}, {
|
|
code: 'ERR_INVALID_ARG_TYPE',
|
|
name: 'TypeError',
|
|
message: 'The "chunk" argument must be of type string or an instance of ' +
|
|
`Buffer, TypedArray, or DataView.${common.invalidArgTypeHelper(value)}`
|
|
});
|
|
});
|