diff --git a/lib/internal/streams/fast-utf8-stream.js b/lib/internal/streams/fast-utf8-stream.js index cb86f245302620..68601cf5c388c7 100644 --- a/lib/internal/streams/fast-utf8-stream.js +++ b/lib/internal/streams/fast-utf8-stream.js @@ -6,15 +6,12 @@ const { ArrayPrototypePush, - AtomicsWait, - Int32Array, MathMax, - Number, SymbolDispose, } = primordials; const { - constructSharedArrayBuffer, + sleep, } = require('internal/util'); const { @@ -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;