Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 1 addition & 20 deletions lib/internal/streams/fast-utf8-stream.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,12 @@

const {
ArrayPrototypePush,
AtomicsWait,
Int32Array,
MathMax,
Number,
SymbolDispose,
} = primordials;

const {
constructSharedArrayBuffer,
sleep,
} = require('internal/util');

const {
Expand Down Expand Up @@ -50,22 +47,6 @@ const {
const BUSY_WRITE_TIMEOUT = 100;
const kEmptyBuffer = Buffer.allocUnsafe(0);

const kNil = new Int32Array(constructSharedArrayBuffer(4));

function sleep(ms) {
// Also filters out NaN, non-number types, including empty strings, but allows bigints
const valid = ms > 0 && ms < Infinity;
if (valid === false) {
if (typeof ms !== 'number' && typeof ms !== 'bigint') {
throw new ERR_INVALID_ARG_TYPE('ms', ['number', 'bigint'], ms);
}
throw new ERR_INVALID_ARG_VALUE.RangeError('ms', ms,
'must be a number greater than 0 and less than Infinity');
}

AtomicsWait(kNil, 0, 0, Number(ms));
}

// 16 KB. Don't write more than docker buffer size.
// https://github.com/moby/moby/blob/513ec73831269947d38a644c278ce3cac36783b2/daemon/logger/copier.go#L13
const kMaxWrite = 16 * 1024;
Expand Down
Loading