mirror of
https://github.com/oven-sh/bun
synced 2026-02-03 23:48:52 +00:00
Compare commits
6 Commits
dylan/byte
...
nektro-pat
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3508555029 | ||
|
|
c547be09c1 | ||
|
|
1fc6f46bfb | ||
|
|
e166ea9d55 | ||
|
|
a32b17ce1f | ||
|
|
08ef34ca62 |
@@ -113,7 +113,7 @@ const { values: options, positionals: filters } = parseArgs({
|
||||
},
|
||||
["retries"]: {
|
||||
type: "string",
|
||||
default: isCI ? "4" : "0", // N retries = N+1 attempts
|
||||
default: isCI ? "3" : "0", // N retries = N+1 attempts
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
@@ -2118,14 +2118,14 @@ function SQL(o, e = {}) {
|
||||
}
|
||||
};
|
||||
// begin is not allowed on a transaction we need to use savepoint() instead
|
||||
transaction_sql.begin = function () {
|
||||
transaction_sql.begin = function begin() {
|
||||
if (distributed) {
|
||||
throw $ERR_POSTGRES_INVALID_TRANSACTION_STATE("cannot call begin inside a distributed transaction");
|
||||
}
|
||||
throw $ERR_POSTGRES_INVALID_TRANSACTION_STATE("cannot call begin inside a transaction use savepoint() instead");
|
||||
};
|
||||
|
||||
transaction_sql.beginDistributed = function () {
|
||||
transaction_sql.beginDistributed = function beginDistributed() {
|
||||
if (distributed) {
|
||||
throw $ERR_POSTGRES_INVALID_TRANSACTION_STATE("cannot call beginDistributed inside a distributed transaction");
|
||||
}
|
||||
@@ -2134,7 +2134,7 @@ function SQL(o, e = {}) {
|
||||
);
|
||||
};
|
||||
|
||||
transaction_sql.flush = function () {
|
||||
transaction_sql.flush = function flush() {
|
||||
if (state.connectionState & ReservedConnectionState.closed) {
|
||||
throw connectionClosedError();
|
||||
}
|
||||
|
||||
@@ -25,19 +25,19 @@ function Worker(options) {
|
||||
}
|
||||
$toClass(Worker, "Worker", EventEmitter);
|
||||
|
||||
Worker.prototype.kill = function () {
|
||||
Worker.prototype.kill = function kill() {
|
||||
this.destroy.$apply(this, arguments);
|
||||
};
|
||||
|
||||
Worker.prototype.send = function () {
|
||||
Worker.prototype.send = function send() {
|
||||
return this.process.send.$apply(this.process, arguments);
|
||||
};
|
||||
|
||||
Worker.prototype.isDead = function () {
|
||||
Worker.prototype.isDead = function isDead() {
|
||||
return this.process.exitCode != null || this.process.signalCode != null;
|
||||
};
|
||||
|
||||
Worker.prototype.isConnected = function () {
|
||||
Worker.prototype.isConnected = function isConnected() {
|
||||
return this.process.connected;
|
||||
};
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@ cluster.isPrimary = false;
|
||||
cluster.worker = null;
|
||||
cluster.Worker = Worker;
|
||||
|
||||
cluster._setupWorker = function () {
|
||||
cluster._setupWorker = function _setupWorker() {
|
||||
const worker = new Worker({
|
||||
id: +process.env.NODE_UNIQUE_ID | 0,
|
||||
process: process,
|
||||
@@ -54,7 +54,7 @@ cluster._setupWorker = function () {
|
||||
};
|
||||
|
||||
// `obj` is a net#Server or a dgram#Socket object.
|
||||
cluster._getServer = function (obj, options, cb) {
|
||||
cluster._getServer = function _getServer(obj, options, cb) {
|
||||
let address = options.address;
|
||||
|
||||
// Resolve unix socket paths to absolute paths
|
||||
@@ -127,7 +127,7 @@ function shared(message, { handle, indexesKey, index }, cb) {
|
||||
// closed. Avoids resource leaks when the handle is short-lived.
|
||||
const close = handle.close;
|
||||
|
||||
handle.close = function () {
|
||||
handle.close = function close() {
|
||||
send({ act: "close", key });
|
||||
handles.delete(key);
|
||||
removeIndexesKey(indexesKey, index);
|
||||
@@ -227,7 +227,7 @@ function send(message, cb?) {
|
||||
}
|
||||
|
||||
// Extend generic Worker with methods specific to worker processes.
|
||||
Worker.prototype.disconnect = function () {
|
||||
Worker.prototype.disconnect = function disconnect() {
|
||||
if (this.state !== "disconnecting" && this.state !== "destroying") {
|
||||
this.state = "disconnecting";
|
||||
this._disconnect();
|
||||
@@ -236,7 +236,7 @@ Worker.prototype.disconnect = function () {
|
||||
return this;
|
||||
};
|
||||
|
||||
Worker.prototype._disconnect = function (this: typeof Worker, primaryInitiated?) {
|
||||
Worker.prototype._disconnect = function _disconnect(this: typeof Worker, primaryInitiated?) {
|
||||
this.exitedAfterDisconnect = true;
|
||||
let waitingCount = 1;
|
||||
|
||||
@@ -267,7 +267,7 @@ Worker.prototype._disconnect = function (this: typeof Worker, primaryInitiated?)
|
||||
checkWaitingCount();
|
||||
};
|
||||
|
||||
Worker.prototype.destroy = function () {
|
||||
Worker.prototype.destroy = function destroy() {
|
||||
if (this.state === "destroying") return;
|
||||
|
||||
this.exitedAfterDisconnect = true;
|
||||
|
||||
@@ -47,7 +47,7 @@ else if (process.platform === "win32") {
|
||||
} else schedulingPolicy = SCHED_RR;
|
||||
cluster.schedulingPolicy = schedulingPolicy;
|
||||
|
||||
cluster.setupPrimary = function (options) {
|
||||
cluster.setupPrimary = function setupPrimary(options) {
|
||||
const settings = {
|
||||
args: ArrayPrototypeSlice.$call(process.argv, 2),
|
||||
exec: process.argv[1],
|
||||
@@ -119,7 +119,7 @@ function removeHandlesForWorker(worker) {
|
||||
});
|
||||
}
|
||||
|
||||
cluster.fork = function (env) {
|
||||
cluster.fork = function fork(env) {
|
||||
cluster.setupPrimary();
|
||||
const id = ++ids;
|
||||
const workerProcess = createWorkerProcess(id, env);
|
||||
@@ -183,7 +183,7 @@ function emitForkNT(worker) {
|
||||
cluster.emit("fork", worker);
|
||||
}
|
||||
|
||||
cluster.disconnect = function (cb) {
|
||||
cluster.disconnect = function disconnect(cb) {
|
||||
const workers = ObjectKeys(cluster.workers);
|
||||
|
||||
if (workers.length === 0) {
|
||||
@@ -304,7 +304,7 @@ function send(worker, message, handle?, cb?) {
|
||||
}
|
||||
|
||||
// Extend generic Worker with methods specific to the primary process.
|
||||
Worker.prototype.disconnect = function () {
|
||||
Worker.prototype.disconnect = function disconnect() {
|
||||
this.exitedAfterDisconnect = true;
|
||||
send(this, { act: "disconnect" });
|
||||
this.process.disconnect();
|
||||
@@ -313,7 +313,7 @@ Worker.prototype.disconnect = function () {
|
||||
return this;
|
||||
};
|
||||
|
||||
Worker.prototype.destroy = function (signo) {
|
||||
Worker.prototype.destroy = function destroy(signo) {
|
||||
const proc = this.process;
|
||||
const signal = signo || "SIGTERM";
|
||||
|
||||
|
||||
@@ -62,7 +62,7 @@ const fileHandleStreamFs = (fh: FileHandle) => ({
|
||||
read:
|
||||
fh.read === fileHandlePrototypeRead
|
||||
? read
|
||||
: function (fd, buf, offset, length, pos, cb) {
|
||||
: function read(fd, buf, offset, length, pos, cb) {
|
||||
return fh.read(buf, offset, length, pos).then(
|
||||
({ bytesRead, buffer }) => cb(null, bytesRead, buffer),
|
||||
err => cb(err, 0, buf),
|
||||
@@ -71,7 +71,7 @@ const fileHandleStreamFs = (fh: FileHandle) => ({
|
||||
write:
|
||||
fh.write === fileHandlePrototypeWrite
|
||||
? write
|
||||
: function (fd, buffer, offset, length, position, cb) {
|
||||
: function write(fd, buffer, offset, length, position, cb) {
|
||||
return fh.write(buffer, offset, length, position).then(
|
||||
({ bytesWritten, buffer }) => cb(null, bytesWritten, buffer),
|
||||
err => cb(err, 0, buffer),
|
||||
@@ -81,7 +81,7 @@ const fileHandleStreamFs = (fh: FileHandle) => ({
|
||||
fsync:
|
||||
fh.sync === fileHandlePrototypeFsync
|
||||
? fsync
|
||||
: function (fd, cb) {
|
||||
: function sync(fd, cb) {
|
||||
return fh.sync().then(() => cb(), cb);
|
||||
},
|
||||
close: streamFileHandleClose.bind(fh),
|
||||
@@ -248,7 +248,7 @@ function streamConstruct(this: FSStream, callback: (e?: any) => void) {
|
||||
|
||||
// Backwards compat for monkey patching open().
|
||||
const orgEmit: any = this.emit;
|
||||
this.emit = function (...args) {
|
||||
this.emit = function emit(...args) {
|
||||
if (args[0] === "open") {
|
||||
this.emit = orgEmit;
|
||||
callback();
|
||||
@@ -299,7 +299,7 @@ readStreamPrototype.open = streamNoop;
|
||||
|
||||
readStreamPrototype._construct = streamConstruct;
|
||||
|
||||
readStreamPrototype._read = function (n) {
|
||||
readStreamPrototype._read = function _read(n) {
|
||||
n = this.pos !== undefined ? $min(this.end - this.pos + 1, n) : $min(this.end - this.bytesRead + 1, n);
|
||||
|
||||
if (n <= 0) {
|
||||
@@ -335,7 +335,7 @@ readStreamPrototype._read = function (n) {
|
||||
});
|
||||
};
|
||||
|
||||
readStreamPrototype._destroy = function (this: FSStream, err, cb) {
|
||||
readStreamPrototype._destroy = function _destroy(this: FSStream, err, cb) {
|
||||
// Usually for async IO it is safe to close a file descriptor
|
||||
// even when there are pending operations. However, due to platform
|
||||
// differences file IO is implemented using synchronous operations
|
||||
@@ -349,7 +349,7 @@ readStreamPrototype._destroy = function (this: FSStream, err, cb) {
|
||||
}
|
||||
};
|
||||
|
||||
readStreamPrototype.close = function (cb) {
|
||||
readStreamPrototype.close = function close(cb) {
|
||||
if (typeof cb === "function") finished(this, cb);
|
||||
this.destroy();
|
||||
};
|
||||
@@ -390,7 +390,7 @@ function closeAfterSync(stream, err, cb) {
|
||||
stream.fd = null;
|
||||
}
|
||||
|
||||
ReadStream.prototype.pipe = function (this: FSStream, dest, pipeOpts) {
|
||||
ReadStream.prototype.pipe = function pipe(this: FSStream, dest, pipeOpts) {
|
||||
// Fast path for streaming files:
|
||||
// if (this[kReadStreamFastPath]) {
|
||||
// }
|
||||
@@ -660,7 +660,7 @@ function writeFast(this: FSStream, data: any, encoding: any, cb: any) {
|
||||
}
|
||||
}
|
||||
|
||||
writeStreamPrototype._writev = function (data, cb) {
|
||||
writeStreamPrototype._writev = function _writev(data, cb) {
|
||||
const len = data.length;
|
||||
const chunks = new Array(len);
|
||||
let size = 0;
|
||||
@@ -700,7 +700,7 @@ writeStreamPrototype._writev = function (data, cb) {
|
||||
}
|
||||
};
|
||||
|
||||
writeStreamPrototype._destroy = function (err, cb) {
|
||||
writeStreamPrototype._destroy = function _destroy(err, cb) {
|
||||
const sink = this[kWriteStreamFastPath];
|
||||
if (sink && sink !== true) {
|
||||
const end = sink.end(err);
|
||||
@@ -712,7 +712,7 @@ writeStreamPrototype._destroy = function (err, cb) {
|
||||
close(this, err, cb);
|
||||
};
|
||||
|
||||
writeStreamPrototype.close = function (this: FSStream, cb) {
|
||||
writeStreamPrototype.close = function close(this: FSStream, cb) {
|
||||
if (cb) {
|
||||
if (this.closed) {
|
||||
process.nextTick(cb);
|
||||
|
||||
@@ -90,7 +90,7 @@ export default function compose(...streams) {
|
||||
|
||||
if (writable) {
|
||||
if (isNodeStream(head)) {
|
||||
d._write = function (chunk, encoding, callback) {
|
||||
d._write = function _write(chunk, encoding, callback) {
|
||||
if (head.write(chunk, encoding)) {
|
||||
callback();
|
||||
} else {
|
||||
@@ -98,7 +98,7 @@ export default function compose(...streams) {
|
||||
}
|
||||
};
|
||||
|
||||
d._final = function (callback) {
|
||||
d._final = function _final(callback) {
|
||||
head.end();
|
||||
onfinish = callback;
|
||||
};
|
||||
@@ -114,7 +114,7 @@ export default function compose(...streams) {
|
||||
const writable = isTransformStream(head) ? head.writable : head;
|
||||
const writer = writable.getWriter();
|
||||
|
||||
d._write = async function (chunk, encoding, callback) {
|
||||
d._write = async function _write(chunk, encoding, callback) {
|
||||
try {
|
||||
await writer.ready;
|
||||
writer.write(chunk).catch(() => {});
|
||||
@@ -124,7 +124,7 @@ export default function compose(...streams) {
|
||||
}
|
||||
};
|
||||
|
||||
d._final = async function (callback) {
|
||||
d._final = async function _final(callback) {
|
||||
try {
|
||||
await writer.ready;
|
||||
writer.close().catch(() => {});
|
||||
@@ -160,7 +160,7 @@ export default function compose(...streams) {
|
||||
d.push(null);
|
||||
});
|
||||
|
||||
d._read = function () {
|
||||
d._read = function _read() {
|
||||
while (true) {
|
||||
const buf = tail.read();
|
||||
if (buf === null) {
|
||||
@@ -176,7 +176,7 @@ export default function compose(...streams) {
|
||||
} else if (isWebStream(tail)) {
|
||||
const readable = isTransformStream(tail) ? tail.readable : tail;
|
||||
const reader = readable.getReader();
|
||||
d._read = async function () {
|
||||
d._read = async function _read() {
|
||||
while (true) {
|
||||
try {
|
||||
const { value, done } = await reader.read();
|
||||
@@ -197,7 +197,7 @@ export default function compose(...streams) {
|
||||
}
|
||||
}
|
||||
|
||||
d._destroy = function (err, callback) {
|
||||
d._destroy = function _destroy(err, callback) {
|
||||
if (!err && onclose !== null) {
|
||||
err = $makeAbortError();
|
||||
}
|
||||
|
||||
@@ -136,16 +136,16 @@ function lazyWebStreams() {
|
||||
return webStreamsAdapters;
|
||||
}
|
||||
|
||||
Duplex.fromWeb = function (pair, options) {
|
||||
Duplex.fromWeb = function fromWeb(pair, options) {
|
||||
return lazyWebStreams().newStreamDuplexFromReadableWritablePair(pair, options);
|
||||
};
|
||||
|
||||
Duplex.toWeb = function (duplex) {
|
||||
Duplex.toWeb = function toWeb(duplex) {
|
||||
return lazyWebStreams().newReadableWritablePairFromDuplex(duplex);
|
||||
};
|
||||
|
||||
let duplexify;
|
||||
Duplex.from = function (body) {
|
||||
Duplex.from = function from(body) {
|
||||
duplexify ??= require("internal/streams/duplexify");
|
||||
return duplexify(body, "body");
|
||||
};
|
||||
|
||||
@@ -278,7 +278,7 @@ function _duplexify(pair) {
|
||||
onfinished(err);
|
||||
});
|
||||
|
||||
d._write = function (chunk, encoding, callback) {
|
||||
d._write = function _write(chunk, encoding, callback) {
|
||||
if (w.write(chunk, encoding)) {
|
||||
callback();
|
||||
} else {
|
||||
@@ -286,7 +286,7 @@ function _duplexify(pair) {
|
||||
}
|
||||
};
|
||||
|
||||
d._final = function (callback) {
|
||||
d._final = function _final(callback) {
|
||||
w.end();
|
||||
onfinish = callback;
|
||||
};
|
||||
@@ -329,7 +329,7 @@ function _duplexify(pair) {
|
||||
d.push(null);
|
||||
});
|
||||
|
||||
d._read = function () {
|
||||
d._read = function _read() {
|
||||
while (true) {
|
||||
const buf = r.read();
|
||||
|
||||
@@ -345,7 +345,7 @@ function _duplexify(pair) {
|
||||
};
|
||||
}
|
||||
|
||||
d._destroy = function (err, callback) {
|
||||
d._destroy = function _destroy(err, callback) {
|
||||
if (!err && onclose !== null) {
|
||||
err = $makeAbortError();
|
||||
}
|
||||
|
||||
@@ -42,7 +42,7 @@ function from(Readable, iterable, opts) {
|
||||
let reading = false;
|
||||
let isAsyncValues = false;
|
||||
|
||||
readable._read = function () {
|
||||
readable._read = function _read() {
|
||||
if (!reading) {
|
||||
reading = true;
|
||||
|
||||
@@ -56,7 +56,7 @@ function from(Readable, iterable, opts) {
|
||||
}
|
||||
};
|
||||
|
||||
readable._destroy = function (error, cb) {
|
||||
readable._destroy = function _destroy(error, cb) {
|
||||
PromisePrototypeThen.$call(
|
||||
close(error),
|
||||
() => process.nextTick(cb, error), // nextTick is here in case cb throws
|
||||
|
||||
@@ -10,7 +10,7 @@ function Stream(opts) {
|
||||
}
|
||||
$toClass(Stream, "Stream", EE);
|
||||
|
||||
Stream.prototype.pipe = function (dest, options) {
|
||||
Stream.prototype.pipe = function pipe(dest, options) {
|
||||
const source = this;
|
||||
|
||||
function ondata(chunk) {
|
||||
|
||||
@@ -13,7 +13,7 @@ function PassThrough(options) {
|
||||
}
|
||||
$toClass(PassThrough, "PassThrough", Transform);
|
||||
|
||||
PassThrough.prototype._transform = function (chunk, encoding, cb) {
|
||||
PassThrough.prototype._transform = function _transform(chunk, encoding, cb) {
|
||||
cb(null, chunk);
|
||||
};
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@ const {
|
||||
const { aggregateTwoErrors } = require("internal/errors");
|
||||
const { validateObject } = require("internal/validators");
|
||||
const { StringDecoder } = require("node:string_decoder");
|
||||
const from = require("internal/streams/from");
|
||||
const from_ = require("internal/streams/from");
|
||||
const { SafeSet } = require("internal/primordials");
|
||||
const { kAutoDestroyed } = require("internal/shared");
|
||||
|
||||
@@ -304,7 +304,7 @@ Readable.ReadableState = ReadableState;
|
||||
|
||||
Readable.prototype.destroy = destroyImpl.destroy;
|
||||
Readable.prototype._undestroy = destroyImpl.undestroy;
|
||||
Readable.prototype._destroy = function (err, cb) {
|
||||
Readable.prototype._destroy = function _destroy(err, cb) {
|
||||
cb(err);
|
||||
};
|
||||
|
||||
@@ -325,7 +325,7 @@ Readable.prototype[SymbolAsyncDispose] = function () {
|
||||
// This returns true if the highWaterMark has not been hit yet,
|
||||
// similar to how Writable.write() returns true if you should
|
||||
// write() some more.
|
||||
Readable.prototype.push = function (chunk, encoding) {
|
||||
Readable.prototype.push = function push(chunk, encoding) {
|
||||
$debug("push", chunk);
|
||||
|
||||
const state = this._readableState;
|
||||
@@ -335,7 +335,7 @@ Readable.prototype.push = function (chunk, encoding) {
|
||||
};
|
||||
|
||||
// Unshift should *always* be something directly out of read().
|
||||
Readable.prototype.unshift = function (chunk, encoding) {
|
||||
Readable.prototype.unshift = function unshift(chunk, encoding) {
|
||||
$debug("unshift", chunk);
|
||||
const state = this._readableState;
|
||||
return (state[kState] & kObjectMode) === 0
|
||||
@@ -510,13 +510,13 @@ function addChunk(stream, state, chunk, addToFront) {
|
||||
maybeReadMore(stream, state);
|
||||
}
|
||||
|
||||
Readable.prototype.isPaused = function () {
|
||||
Readable.prototype.isPaused = function isPaused() {
|
||||
const state = this._readableState;
|
||||
return (state[kState] & kPaused) !== 0 || (state[kState] & (kHasFlowing | kFlowing)) === kHasFlowing;
|
||||
};
|
||||
|
||||
// Backwards compatibility.
|
||||
Readable.prototype.setEncoding = function (enc) {
|
||||
Readable.prototype.setEncoding = function setEncoding(enc) {
|
||||
const state = this._readableState;
|
||||
|
||||
const decoder = new StringDecoder(enc);
|
||||
@@ -571,7 +571,7 @@ function howMuchToRead(n, state) {
|
||||
}
|
||||
|
||||
// You can override either this method, or the async _read(n) below.
|
||||
Readable.prototype.read = function (n) {
|
||||
Readable.prototype.read = function read(n) {
|
||||
$debug("read", n);
|
||||
// Same as parseInt(undefined, 10), however V8 7.3 performance regressed
|
||||
// in this scenario, so we are doing it manually.
|
||||
@@ -817,11 +817,11 @@ function maybeReadMore_(stream, state) {
|
||||
// call cb(er, data) where data is <= n in length.
|
||||
// for virtual (non-string, non-buffer) streams, "length" is somewhat
|
||||
// arbitrary, and perhaps not very meaningful.
|
||||
Readable.prototype._read = function (n) {
|
||||
Readable.prototype._read = function _read(n) {
|
||||
throw $ERR_METHOD_NOT_IMPLEMENTED("_read()");
|
||||
};
|
||||
|
||||
Readable.prototype.pipe = function (dest, pipeOpts) {
|
||||
Readable.prototype.pipe = function pipe(dest, pipeOpts) {
|
||||
const src = this;
|
||||
const state = this._readableState;
|
||||
|
||||
@@ -994,7 +994,7 @@ function pipeOnDrain(src, dest) {
|
||||
};
|
||||
}
|
||||
|
||||
Readable.prototype.unpipe = function (dest) {
|
||||
Readable.prototype.unpipe = function unpipe(dest) {
|
||||
const state = this._readableState;
|
||||
const unpipeInfo = { hasUnpiped: false };
|
||||
|
||||
@@ -1025,7 +1025,7 @@ Readable.prototype.unpipe = function (dest) {
|
||||
|
||||
// Set up data events if they are asked for
|
||||
// Ensure readable listeners eventually get something.
|
||||
Readable.prototype.on = function (ev, fn) {
|
||||
Readable.prototype.on = function on(ev, fn) {
|
||||
const res = Stream.prototype.on.$call(this, ev, fn);
|
||||
const state = this._readableState;
|
||||
|
||||
@@ -1057,7 +1057,7 @@ Readable.prototype.on = function (ev, fn) {
|
||||
};
|
||||
Readable.prototype.addListener = Readable.prototype.on;
|
||||
|
||||
Readable.prototype.removeListener = function (ev, fn) {
|
||||
Readable.prototype.removeListener = function removeListener(ev, fn) {
|
||||
const state = this._readableState;
|
||||
|
||||
const res = Stream.prototype.removeListener.$call(this, ev, fn);
|
||||
@@ -1078,7 +1078,7 @@ Readable.prototype.removeListener = function (ev, fn) {
|
||||
};
|
||||
Readable.prototype.off = Readable.prototype.removeListener;
|
||||
|
||||
Readable.prototype.removeAllListeners = function (ev) {
|
||||
Readable.prototype.removeAllListeners = function removeAllListeners(ev) {
|
||||
const res = Stream.prototype.removeAllListeners.$apply(this, arguments);
|
||||
|
||||
if (ev === "readable" || ev === undefined) {
|
||||
@@ -1123,7 +1123,7 @@ function nReadingNextTick(self) {
|
||||
|
||||
// pause() and resume() are remnants of the legacy readable stream API
|
||||
// If the user uses them, then switch into old mode.
|
||||
Readable.prototype.resume = function () {
|
||||
Readable.prototype.resume = function resume() {
|
||||
const state = this._readableState;
|
||||
if ((state[kState] & kFlowing) === 0) {
|
||||
$debug("resume");
|
||||
@@ -1136,21 +1136,21 @@ Readable.prototype.resume = function () {
|
||||
} else {
|
||||
state[kState] &= ~kFlowing;
|
||||
}
|
||||
resume(this, state);
|
||||
resume2(this, state);
|
||||
}
|
||||
state[kState] |= kHasPaused;
|
||||
state[kState] &= ~kPaused;
|
||||
return this;
|
||||
};
|
||||
|
||||
function resume(stream, state) {
|
||||
function resume2(stream, state) {
|
||||
if ((state[kState] & kResumeScheduled) === 0) {
|
||||
state[kState] |= kResumeScheduled;
|
||||
process.nextTick(resume_, stream, state);
|
||||
process.nextTick(resume3, stream, state);
|
||||
}
|
||||
}
|
||||
|
||||
function resume_(stream, state) {
|
||||
function resume3(stream, state) {
|
||||
$debug("resume", (state[kState] & kReading) !== 0);
|
||||
if ((state[kState] & kReading) === 0) {
|
||||
stream.read(0);
|
||||
@@ -1162,7 +1162,7 @@ function resume_(stream, state) {
|
||||
if ((state[kState] & (kFlowing | kReading)) === kFlowing) stream.read(0);
|
||||
}
|
||||
|
||||
Readable.prototype.pause = function () {
|
||||
Readable.prototype.pause = function pause() {
|
||||
const state = this._readableState;
|
||||
$debug("call pause");
|
||||
if ((state[kState] & (kHasFlowing | kFlowing)) !== kHasFlowing) {
|
||||
@@ -1184,7 +1184,7 @@ function flow(stream) {
|
||||
// Wrap an old-style stream as the async data source.
|
||||
// This is *not* part of the readable stream interface.
|
||||
// It is an ugly unfortunate mess of history.
|
||||
Readable.prototype.wrap = function (stream) {
|
||||
Readable.prototype.wrap = function wrap(stream) {
|
||||
let paused = false;
|
||||
|
||||
// TODO (ronag): Should this.destroy(err) emit
|
||||
@@ -1237,7 +1237,7 @@ Readable.prototype[SymbolAsyncIterator] = function () {
|
||||
return streamToAsyncIterator(this);
|
||||
};
|
||||
|
||||
Readable.prototype.iterator = function (options) {
|
||||
Readable.prototype.iterator = function iterator(options) {
|
||||
if (options !== undefined) {
|
||||
validateObject(options, "options");
|
||||
}
|
||||
@@ -1617,8 +1617,8 @@ function endWritableNT(stream) {
|
||||
}
|
||||
}
|
||||
|
||||
Readable.from = function (iterable, opts) {
|
||||
return from(Readable, iterable, opts);
|
||||
Readable.from = function from(iterable, opts) {
|
||||
return from_(Readable, iterable, opts);
|
||||
};
|
||||
|
||||
// Lazy to avoid circular references
|
||||
@@ -1628,15 +1628,15 @@ function lazyWebStreams() {
|
||||
return webStreamsAdapters;
|
||||
}
|
||||
|
||||
Readable.fromWeb = function (readableStream, options) {
|
||||
Readable.fromWeb = function fromWeb(readableStream, options) {
|
||||
return lazyWebStreams().newStreamReadableFromReadableStream(readableStream, options);
|
||||
};
|
||||
|
||||
Readable.toWeb = function (streamReadable, options) {
|
||||
Readable.toWeb = function toWeb(streamReadable, options) {
|
||||
return lazyWebStreams().newReadableStreamFromStreamReadable(streamReadable, options);
|
||||
};
|
||||
|
||||
Readable.wrap = function (src, options) {
|
||||
Readable.wrap = function wrap(src, options) {
|
||||
return new Readable({
|
||||
objectMode: src.readableObjectMode ?? src.objectMode ?? true,
|
||||
...options,
|
||||
|
||||
@@ -125,11 +125,11 @@ function prefinish() {
|
||||
|
||||
Transform.prototype._final = final;
|
||||
|
||||
Transform.prototype._transform = function (chunk, encoding, callback) {
|
||||
Transform.prototype._transform = function _transform(chunk, encoding, callback) {
|
||||
throw $ERR_METHOD_NOT_IMPLEMENTED("_transform()");
|
||||
};
|
||||
|
||||
Transform.prototype._write = function (chunk, encoding, callback) {
|
||||
Transform.prototype._write = function _write(chunk, encoding, callback) {
|
||||
const rState = this._readableState;
|
||||
const wState = this._writableState;
|
||||
const length = rState.length;
|
||||
@@ -161,7 +161,7 @@ Transform.prototype._write = function (chunk, encoding, callback) {
|
||||
});
|
||||
};
|
||||
|
||||
Transform.prototype._read = function () {
|
||||
Transform.prototype._read = function _read() {
|
||||
if (this[kCallback]) {
|
||||
const callback = this[kCallback];
|
||||
this[kCallback] = null;
|
||||
|
||||
@@ -409,7 +409,7 @@ ObjectDefineProperty(Writable, SymbolHasInstance, {
|
||||
});
|
||||
|
||||
// Otherwise people can pipe Writable streams, which is just wrong.
|
||||
Writable.prototype.pipe = function () {
|
||||
Writable.prototype.pipe = function pipe() {
|
||||
errorOrDestroy(this, $ERR_STREAM_CANNOT_PIPE());
|
||||
};
|
||||
|
||||
@@ -463,7 +463,7 @@ function _write(stream, chunk, encoding, cb?) {
|
||||
return writeOrBuffer(stream, state, chunk, encoding, cb);
|
||||
}
|
||||
|
||||
Writable.prototype.write = function (chunk, encoding, cb) {
|
||||
Writable.prototype.write = function write(chunk, encoding, cb) {
|
||||
if (encoding != null && typeof encoding === "function") {
|
||||
cb = encoding;
|
||||
encoding = null;
|
||||
@@ -472,14 +472,14 @@ Writable.prototype.write = function (chunk, encoding, cb) {
|
||||
return _write(this, chunk, encoding, cb) === true;
|
||||
};
|
||||
|
||||
Writable.prototype.cork = function () {
|
||||
Writable.prototype.cork = function cork() {
|
||||
const state = this._writableState;
|
||||
|
||||
state[kState] |= kCorked;
|
||||
state.corked++;
|
||||
};
|
||||
|
||||
Writable.prototype.uncork = function () {
|
||||
Writable.prototype.uncork = function uncork() {
|
||||
const state = this._writableState;
|
||||
|
||||
if (state.corked) {
|
||||
@@ -753,7 +753,7 @@ function clearBuffer(stream, state) {
|
||||
state[kState] &= ~kBufferProcessing;
|
||||
}
|
||||
|
||||
Writable.prototype._write = function (chunk, encoding, cb) {
|
||||
Writable.prototype._write = function _write(chunk, encoding, cb) {
|
||||
if (this._writev) {
|
||||
this._writev([{ chunk, encoding }], cb);
|
||||
} else {
|
||||
@@ -763,7 +763,7 @@ Writable.prototype._write = function (chunk, encoding, cb) {
|
||||
|
||||
Writable.prototype._writev = null;
|
||||
|
||||
Writable.prototype.end = function (chunk, encoding, cb) {
|
||||
Writable.prototype.end = function end(chunk, encoding, cb) {
|
||||
const state = this._writableState;
|
||||
|
||||
if (typeof chunk === "function") {
|
||||
@@ -1072,8 +1072,8 @@ ObjectDefineProperties(Writable.prototype, {
|
||||
},
|
||||
});
|
||||
|
||||
const destroy = destroyImpl.destroy;
|
||||
Writable.prototype.destroy = function (err, cb) {
|
||||
const destroy_ = destroyImpl.destroy;
|
||||
Writable.prototype.destroy = function destroy(err, cb) {
|
||||
const state = this._writableState;
|
||||
|
||||
// Invoke pending callbacks.
|
||||
@@ -1081,12 +1081,12 @@ Writable.prototype.destroy = function (err, cb) {
|
||||
process.nextTick(errorBuffer, state);
|
||||
}
|
||||
|
||||
destroy.$call(this, err, cb);
|
||||
destroy_.$call(this, err, cb);
|
||||
return this;
|
||||
};
|
||||
|
||||
Writable.prototype._undestroy = destroyImpl.undestroy;
|
||||
Writable.prototype._destroy = function (err, cb) {
|
||||
Writable.prototype._destroy = function _destroy(err, cb) {
|
||||
cb(err);
|
||||
};
|
||||
|
||||
@@ -1101,11 +1101,11 @@ function lazyWebStreams() {
|
||||
return webStreamsAdapters;
|
||||
}
|
||||
|
||||
Writable.fromWeb = function (writableStream, options) {
|
||||
Writable.fromWeb = function fromWeb(writableStream, options) {
|
||||
return lazyWebStreams().newStreamWritableFromWritableStream(writableStream, options);
|
||||
};
|
||||
|
||||
Writable.toWeb = function (streamWritable) {
|
||||
Writable.toWeb = function toWeb(streamWritable) {
|
||||
return lazyWebStreams().newWritableStreamFromStreamWritable(streamWritable);
|
||||
};
|
||||
|
||||
|
||||
@@ -217,7 +217,7 @@ function bufferSize(self, size, buffer) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
Socket.prototype.bind = function (port_, address_ /* , callback */) {
|
||||
Socket.prototype.bind = function bind(port_, address_ /* , callback */) {
|
||||
let port = port_;
|
||||
|
||||
const state = this[kStateSymbol];
|
||||
@@ -365,7 +365,7 @@ Socket.prototype.bind = function (port_, address_ /* , callback */) {
|
||||
return this;
|
||||
};
|
||||
|
||||
Socket.prototype.connect = function (port, address, callback) {
|
||||
Socket.prototype.connect = function connect(port, address, callback) {
|
||||
port = validatePort(port, "Port", false);
|
||||
if (typeof address === "function") {
|
||||
callback = address;
|
||||
@@ -434,7 +434,7 @@ function doConnect(ex, self, ip, address, port, callback) {
|
||||
|
||||
const disconnectFn = $newZigFunction("udp_socket.zig", "UDPSocket.jsDisconnect", 0);
|
||||
|
||||
Socket.prototype.disconnect = function () {
|
||||
Socket.prototype.disconnect = function disconnect() {
|
||||
const state = this[kStateSymbol];
|
||||
if (state.connectState !== CONNECT_STATE_CONNECTED) throw $ERR_SOCKET_DGRAM_NOT_CONNECTED();
|
||||
|
||||
@@ -443,7 +443,7 @@ Socket.prototype.disconnect = function () {
|
||||
};
|
||||
|
||||
// Thin wrapper around `send`, here for compatibility with dgram_legacy.js
|
||||
Socket.prototype.sendto = function (buffer, offset, length, port, address, callback) {
|
||||
Socket.prototype.sendto = function sendto(buffer, offset, length, port, address, callback) {
|
||||
validateNumber(offset, "offset");
|
||||
validateNumber(length, "length");
|
||||
validateNumber(port, "port");
|
||||
@@ -532,7 +532,7 @@ function clearQueue() {
|
||||
// send(buffer, offset, length)
|
||||
// send(bufferOrList, callback)
|
||||
// send(bufferOrList)
|
||||
Socket.prototype.send = function (buffer, offset, length, port, address, callback) {
|
||||
Socket.prototype.send = function send(buffer, offset, length, port, address, callback) {
|
||||
let list;
|
||||
const state = this[kStateSymbol];
|
||||
const connected = state.connectState === CONNECT_STATE_CONNECTED;
|
||||
@@ -696,7 +696,7 @@ function afterSend(err, sent) {
|
||||
}
|
||||
*/
|
||||
|
||||
Socket.prototype.close = function (callback) {
|
||||
Socket.prototype.close = function close(callback) {
|
||||
const state = this[kStateSymbol];
|
||||
const queue = state.queue;
|
||||
|
||||
@@ -735,13 +735,13 @@ function socketCloseNT(self) {
|
||||
self.emit("close");
|
||||
}
|
||||
|
||||
Socket.prototype.address = function () {
|
||||
Socket.prototype.address = function address() {
|
||||
const addr = this[kStateSymbol].handle.socket?.address;
|
||||
if (!addr) throw $ERR_SOCKET_DGRAM_NOT_RUNNING();
|
||||
return addr;
|
||||
};
|
||||
|
||||
Socket.prototype.remoteAddress = function () {
|
||||
Socket.prototype.remoteAddress = function remoteAddress() {
|
||||
const state = this[kStateSymbol];
|
||||
const socket = state.handle.socket;
|
||||
|
||||
@@ -754,7 +754,7 @@ Socket.prototype.remoteAddress = function () {
|
||||
return socket.remoteAddress;
|
||||
};
|
||||
|
||||
Socket.prototype.setBroadcast = function (arg) {
|
||||
Socket.prototype.setBroadcast = function setBroadcast(arg) {
|
||||
const handle = this[kStateSymbol].handle;
|
||||
if (!handle?.socket) {
|
||||
throw new Error("setBroadcast EBADF");
|
||||
@@ -762,7 +762,7 @@ Socket.prototype.setBroadcast = function (arg) {
|
||||
return handle.socket.setBroadcast(arg);
|
||||
};
|
||||
|
||||
Socket.prototype.setTTL = function (ttl) {
|
||||
Socket.prototype.setTTL = function setTTL(ttl) {
|
||||
if (typeof ttl !== "number") {
|
||||
throw $ERR_INVALID_ARG_TYPE("ttl", "number", ttl);
|
||||
}
|
||||
@@ -774,7 +774,7 @@ Socket.prototype.setTTL = function (ttl) {
|
||||
return handle.socket.setTTL(ttl);
|
||||
};
|
||||
|
||||
Socket.prototype.setMulticastTTL = function (ttl) {
|
||||
Socket.prototype.setMulticastTTL = function setMulticastTTL(ttl) {
|
||||
if (typeof ttl !== "number") {
|
||||
throw $ERR_INVALID_ARG_TYPE("ttl", "number", ttl);
|
||||
}
|
||||
@@ -786,7 +786,7 @@ Socket.prototype.setMulticastTTL = function (ttl) {
|
||||
return handle.socket.setMulticastTTL(ttl);
|
||||
};
|
||||
|
||||
Socket.prototype.setMulticastLoopback = function (arg) {
|
||||
Socket.prototype.setMulticastLoopback = function setMulticastLoopback(arg) {
|
||||
const handle = this[kStateSymbol].handle;
|
||||
if (!handle?.socket) {
|
||||
throw new Error("setMulticastLoopback EBADF");
|
||||
@@ -794,7 +794,7 @@ Socket.prototype.setMulticastLoopback = function (arg) {
|
||||
return handle.socket.setMulticastLoopback(arg);
|
||||
};
|
||||
|
||||
Socket.prototype.setMulticastInterface = function (interfaceAddress) {
|
||||
Socket.prototype.setMulticastInterface = function setMulticastInterface(interfaceAddress) {
|
||||
validateString(interfaceAddress, "interfaceAddress");
|
||||
const handle = this[kStateSymbol].handle;
|
||||
if (!handle?.socket) {
|
||||
@@ -805,7 +805,7 @@ Socket.prototype.setMulticastInterface = function (interfaceAddress) {
|
||||
}
|
||||
};
|
||||
|
||||
Socket.prototype.addMembership = function (multicastAddress, interfaceAddress) {
|
||||
Socket.prototype.addMembership = function addMembership(multicastAddress, interfaceAddress) {
|
||||
if (!multicastAddress) {
|
||||
throw $ERR_MISSING_ARGS("multicastAddress");
|
||||
}
|
||||
@@ -826,7 +826,7 @@ Socket.prototype.addMembership = function (multicastAddress, interfaceAddress) {
|
||||
return handle.socket.addMembership(multicastAddress, interfaceAddress);
|
||||
};
|
||||
|
||||
Socket.prototype.dropMembership = function (multicastAddress, interfaceAddress) {
|
||||
Socket.prototype.dropMembership = function dropMembership(multicastAddress, interfaceAddress) {
|
||||
if (!multicastAddress) {
|
||||
throw $ERR_MISSING_ARGS("multicastAddress");
|
||||
}
|
||||
@@ -844,7 +844,11 @@ Socket.prototype.dropMembership = function (multicastAddress, interfaceAddress)
|
||||
return handle.socket.dropMembership(multicastAddress, interfaceAddress);
|
||||
};
|
||||
|
||||
Socket.prototype.addSourceSpecificMembership = function (sourceAddress, groupAddress, interfaceAddress) {
|
||||
Socket.prototype.addSourceSpecificMembership = function addSourceSpecificMembership(
|
||||
sourceAddress,
|
||||
groupAddress,
|
||||
interfaceAddress,
|
||||
) {
|
||||
validateString(sourceAddress, "sourceAddress");
|
||||
validateString(groupAddress, "groupAddress");
|
||||
if (typeof interfaceAddress !== "undefined") {
|
||||
@@ -864,7 +868,11 @@ Socket.prototype.addSourceSpecificMembership = function (sourceAddress, groupAdd
|
||||
return handle.socket.addSourceSpecificMembership(sourceAddress, groupAddress, interfaceAddress);
|
||||
};
|
||||
|
||||
Socket.prototype.dropSourceSpecificMembership = function (sourceAddress, groupAddress, interfaceAddress) {
|
||||
Socket.prototype.dropSourceSpecificMembership = function dropSourceSpecificMembership(
|
||||
sourceAddress,
|
||||
groupAddress,
|
||||
interfaceAddress,
|
||||
) {
|
||||
validateString(sourceAddress, "sourceAddress");
|
||||
validateString(groupAddress, "groupAddress");
|
||||
if (typeof interfaceAddress !== "undefined") {
|
||||
@@ -884,7 +892,7 @@ Socket.prototype.dropSourceSpecificMembership = function (sourceAddress, groupAd
|
||||
return handle.socket.dropSourceSpecificMembership(sourceAddress, groupAddress, interfaceAddress);
|
||||
};
|
||||
|
||||
Socket.prototype.ref = function () {
|
||||
Socket.prototype.ref = function ref() {
|
||||
const socket = this[kStateSymbol].handle?.socket;
|
||||
|
||||
if (socket) socket.ref();
|
||||
@@ -892,7 +900,7 @@ Socket.prototype.ref = function () {
|
||||
return this;
|
||||
};
|
||||
|
||||
Socket.prototype.unref = function () {
|
||||
Socket.prototype.unref = function unref() {
|
||||
const socket = this[kStateSymbol].handle?.socket;
|
||||
|
||||
if (socket) {
|
||||
@@ -904,28 +912,28 @@ Socket.prototype.unref = function () {
|
||||
return this;
|
||||
};
|
||||
|
||||
Socket.prototype.setRecvBufferSize = function (size) {
|
||||
Socket.prototype.setRecvBufferSize = function setRecvBufferSize(size) {
|
||||
bufferSize(this, size, RECV_BUFFER);
|
||||
};
|
||||
|
||||
Socket.prototype.setSendBufferSize = function (size) {
|
||||
Socket.prototype.setSendBufferSize = function setSendBufferSize(size) {
|
||||
bufferSize(this, size, SEND_BUFFER);
|
||||
};
|
||||
|
||||
Socket.prototype.getRecvBufferSize = function () {
|
||||
Socket.prototype.getRecvBufferSize = function getRecvBufferSize() {
|
||||
return bufferSize(this, 0, RECV_BUFFER);
|
||||
};
|
||||
|
||||
Socket.prototype.getSendBufferSize = function () {
|
||||
Socket.prototype.getSendBufferSize = function getSendBufferSize() {
|
||||
return bufferSize(this, 0, SEND_BUFFER);
|
||||
};
|
||||
|
||||
Socket.prototype.getSendQueueSize = function () {
|
||||
Socket.prototype.getSendQueueSize = function getSendQueueSize() {
|
||||
return 0;
|
||||
// return this[kStateSymbol].handle.getSendQueueSize();
|
||||
};
|
||||
|
||||
Socket.prototype.getSendQueueCount = function () {
|
||||
Socket.prototype.getSendQueueCount = function getSendQueueCount() {
|
||||
return 0;
|
||||
// return this[kStateSymbol].handle.getSendQueueCount();
|
||||
};
|
||||
|
||||
@@ -5,7 +5,7 @@ const ObjectDefineProperty = Object.defineProperty;
|
||||
|
||||
// Export Domain
|
||||
var domain: any = {};
|
||||
domain.createDomain = domain.create = function () {
|
||||
domain.createDomain = domain.create = function create() {
|
||||
if (!EventEmitter) {
|
||||
EventEmitter = require("node:events");
|
||||
}
|
||||
@@ -27,13 +27,13 @@ domain.createDomain = domain.create = function () {
|
||||
d.emit("error", e);
|
||||
}
|
||||
|
||||
d.add = function (emitter) {
|
||||
d.add = function add(emitter) {
|
||||
emitter.on("error", emitError);
|
||||
};
|
||||
d.remove = function (emitter) {
|
||||
d.remove = function remove(emitter) {
|
||||
emitter.removeListener("error", emitError);
|
||||
};
|
||||
d.bind = function (fn) {
|
||||
d.bind = function bind(fn) {
|
||||
return function () {
|
||||
var args = Array.prototype.slice.$call(arguments);
|
||||
try {
|
||||
@@ -43,7 +43,7 @@ domain.createDomain = domain.create = function () {
|
||||
}
|
||||
};
|
||||
};
|
||||
d.intercept = function (fn) {
|
||||
d.intercept = function intercept(fn) {
|
||||
return function (err) {
|
||||
if (err) {
|
||||
emitError(err);
|
||||
@@ -57,7 +57,7 @@ domain.createDomain = domain.create = function () {
|
||||
}
|
||||
};
|
||||
};
|
||||
d.run = function (fn) {
|
||||
d.run = function run(fn) {
|
||||
try {
|
||||
fn();
|
||||
} catch (err) {
|
||||
@@ -65,11 +65,14 @@ domain.createDomain = domain.create = function () {
|
||||
}
|
||||
return this;
|
||||
};
|
||||
d.dispose = function () {
|
||||
d.dispose = function dispose() {
|
||||
this.removeAllListeners();
|
||||
return this;
|
||||
};
|
||||
d.enter = d.exit = function () {
|
||||
d.enter = function enter() {
|
||||
return this;
|
||||
};
|
||||
d.exit = function exit() {
|
||||
return this;
|
||||
};
|
||||
return d;
|
||||
|
||||
@@ -8,8 +8,8 @@ const { urlToHttpOptions } = require("internal/url");
|
||||
const { validateFunction, checkIsHttpToken } = require("internal/validators");
|
||||
|
||||
const {
|
||||
getHeader,
|
||||
setHeader,
|
||||
getHeader: getHeader_,
|
||||
setHeader: setHeader_,
|
||||
assignHeaders: assignHeadersFast,
|
||||
assignEventCallback,
|
||||
setRequestTimeout,
|
||||
@@ -289,12 +289,12 @@ ObjectDefineProperty(Agent, "defaultMaxSockets", {
|
||||
},
|
||||
});
|
||||
|
||||
Agent.prototype.createConnection = function () {
|
||||
Agent.prototype.createConnection = function createConnection() {
|
||||
$debug(`${NODE_HTTP_WARNING}\n`, "WARN: Agent.createConnection is a no-op, returns fake socket");
|
||||
return (this[kfakeSocket] ??= new FakeSocket());
|
||||
};
|
||||
|
||||
Agent.prototype.getName = function (options = kEmptyObject) {
|
||||
Agent.prototype.getName = function getName(options = kEmptyObject) {
|
||||
let name = `http:${options.host || "localhost"}:`;
|
||||
if (options.port) name += options.port;
|
||||
name += ":";
|
||||
@@ -306,29 +306,29 @@ Agent.prototype.getName = function (options = kEmptyObject) {
|
||||
return name;
|
||||
};
|
||||
|
||||
Agent.prototype.addRequest = function () {
|
||||
Agent.prototype.addRequest = function addRequest() {
|
||||
$debug(`${NODE_HTTP_WARNING}\n`, "WARN: Agent.addRequest is a no-op");
|
||||
};
|
||||
|
||||
Agent.prototype.createSocket = function (req, options, cb) {
|
||||
Agent.prototype.createSocket = function createSocket(req, options, cb) {
|
||||
$debug(`${NODE_HTTP_WARNING}\n`, "WARN: Agent.createSocket returns fake socket");
|
||||
cb(null, (this[kfakeSocket] ??= new FakeSocket()));
|
||||
};
|
||||
|
||||
Agent.prototype.removeSocket = function () {
|
||||
Agent.prototype.removeSocket = function removeSocket() {
|
||||
$debug(`${NODE_HTTP_WARNING}\n`, "WARN: Agent.removeSocket is a no-op");
|
||||
};
|
||||
|
||||
Agent.prototype.keepSocketAlive = function () {
|
||||
Agent.prototype.keepSocketAlive = function keepSocketAlive() {
|
||||
$debug(`${NODE_HTTP_WARNING}\n`, "WARN: Agent.keepSocketAlive is a no-op");
|
||||
return true;
|
||||
};
|
||||
|
||||
Agent.prototype.reuseSocket = function () {
|
||||
Agent.prototype.reuseSocket = function reuseSocket() {
|
||||
$debug(`${NODE_HTTP_WARNING}\n`, "WARN: Agent.reuseSocket is a no-op");
|
||||
};
|
||||
|
||||
Agent.prototype.destroy = function () {
|
||||
Agent.prototype.destroy = function destroy() {
|
||||
$debug(`${NODE_HTTP_WARNING}\n`, "WARN: Agent.destroy is a no-op");
|
||||
};
|
||||
|
||||
@@ -647,11 +647,11 @@ Server.prototype = {
|
||||
if (rejectFunction) rejectFunction(err);
|
||||
};
|
||||
|
||||
var reply = function (resp) {
|
||||
function reply(resp) {
|
||||
if (pendingResponse) return;
|
||||
pendingResponse = resp;
|
||||
if (resolveFunction) resolveFunction(resp);
|
||||
};
|
||||
}
|
||||
|
||||
const prevIsNextIncomingMessageHTTPS = isNextIncomingMessageHTTPS;
|
||||
isNextIncomingMessageHTTPS = isHTTPS;
|
||||
@@ -1021,9 +1021,9 @@ OutgoingMessage.prototype.constructor = OutgoingMessage; // Re-add constructor w
|
||||
$setPrototypeDirect.$call(OutgoingMessage, Writable);
|
||||
|
||||
// Express "compress" package uses this
|
||||
OutgoingMessage.prototype._implicitHeader = function () {};
|
||||
OutgoingMessage.prototype._implicitHeader = function _implicitHeader() {};
|
||||
|
||||
OutgoingMessage.prototype.appendHeader = function (name, value) {
|
||||
OutgoingMessage.prototype.appendHeader = function appendHeader(name, value) {
|
||||
var headers = (this[headersSymbol] ??= new Headers());
|
||||
if (typeof value === "number") {
|
||||
value = String(value);
|
||||
@@ -1031,29 +1031,29 @@ OutgoingMessage.prototype.appendHeader = function (name, value) {
|
||||
headers.append(name, value);
|
||||
};
|
||||
|
||||
OutgoingMessage.prototype.flushHeaders = function () {};
|
||||
OutgoingMessage.prototype.flushHeaders = function flushHeaders() {};
|
||||
|
||||
OutgoingMessage.prototype.getHeader = function (name) {
|
||||
return getHeader(this[headersSymbol], name);
|
||||
OutgoingMessage.prototype.getHeader = function getHeader(name) {
|
||||
return getHeader_(this[headersSymbol], name);
|
||||
};
|
||||
|
||||
OutgoingMessage.prototype.getHeaders = function () {
|
||||
OutgoingMessage.prototype.getHeaders = function getHeaders() {
|
||||
if (!this[headersSymbol]) return kEmptyObject;
|
||||
return this[headersSymbol].toJSON();
|
||||
};
|
||||
|
||||
OutgoingMessage.prototype.getHeaderNames = function () {
|
||||
OutgoingMessage.prototype.getHeaderNames = function getHeaderNames() {
|
||||
var headers = this[headersSymbol];
|
||||
if (!headers) return [];
|
||||
return Array.from(headers.keys());
|
||||
};
|
||||
|
||||
OutgoingMessage.prototype.removeHeader = function (name) {
|
||||
OutgoingMessage.prototype.removeHeader = function removeHeader(name) {
|
||||
if (!this[headersSymbol]) return;
|
||||
this[headersSymbol].delete(name);
|
||||
};
|
||||
|
||||
OutgoingMessage.prototype.setHeader = function (name, value) {
|
||||
OutgoingMessage.prototype.setHeader = function setHeader(name, value) {
|
||||
this[headersSymbol] = this[headersSymbol] ?? new Headers();
|
||||
var headers = this[headersSymbol];
|
||||
if (typeof value === "number") {
|
||||
@@ -1063,12 +1063,12 @@ OutgoingMessage.prototype.setHeader = function (name, value) {
|
||||
return this;
|
||||
};
|
||||
|
||||
OutgoingMessage.prototype.hasHeader = function (name) {
|
||||
OutgoingMessage.prototype.hasHeader = function hasHeader(name) {
|
||||
if (!this[headersSymbol]) return false;
|
||||
return this[headersSymbol].has(name);
|
||||
};
|
||||
|
||||
OutgoingMessage.prototype.addTrailers = function (headers) {
|
||||
OutgoingMessage.prototype.addTrailers = function addTrailers(headers) {
|
||||
throw new Error("not implemented");
|
||||
};
|
||||
|
||||
@@ -1078,7 +1078,7 @@ function onTimeout() {
|
||||
this.emit("timeout");
|
||||
}
|
||||
|
||||
OutgoingMessage.prototype.setTimeout = function (msecs, callback) {
|
||||
OutgoingMessage.prototype.setTimeout = function setTimeout(msecs, callback) {
|
||||
if (this.destroyed) return this;
|
||||
|
||||
this.timeout = msecs = validateMsecs(msecs, "msecs");
|
||||
@@ -1245,12 +1245,12 @@ ServerResponse.prototype.constructor = ServerResponse; // Re-add constructor whi
|
||||
$setPrototypeDirect.$call(ServerResponse, OutgoingMessage);
|
||||
|
||||
// Express "compress" package uses this
|
||||
ServerResponse.prototype._implicitHeader = function () {
|
||||
ServerResponse.prototype._implicitHeader = function _implicitHeader() {
|
||||
// @ts-ignore
|
||||
this.writeHead(this.statusCode);
|
||||
};
|
||||
|
||||
ServerResponse.prototype._write = function (chunk, encoding, callback) {
|
||||
ServerResponse.prototype._write = function _write(chunk, encoding, callback) {
|
||||
if (this[firstWriteSymbol] === undefined && !this.headersSent) {
|
||||
this[firstWriteSymbol] = chunk;
|
||||
callback();
|
||||
@@ -1263,7 +1263,7 @@ ServerResponse.prototype._write = function (chunk, encoding, callback) {
|
||||
});
|
||||
};
|
||||
|
||||
ServerResponse.prototype._writev = function (chunks, callback) {
|
||||
ServerResponse.prototype._writev = function _writev(chunks, callback) {
|
||||
if (chunks.length === 1 && !this.headersSent && this[firstWriteSymbol] === undefined) {
|
||||
this[firstWriteSymbol] = chunks[0].chunk;
|
||||
callback();
|
||||
@@ -1318,7 +1318,7 @@ function drainHeadersIfObservable() {
|
||||
this._implicitHeader();
|
||||
}
|
||||
|
||||
ServerResponse.prototype._final = function (callback) {
|
||||
ServerResponse.prototype._final = function _final(callback) {
|
||||
const req = this.req;
|
||||
const shouldEmitClose = req && req.emit && !this[finishedSymbol];
|
||||
|
||||
@@ -1359,15 +1359,15 @@ ServerResponse.prototype._final = function (callback) {
|
||||
});
|
||||
};
|
||||
|
||||
ServerResponse.prototype.writeProcessing = function () {
|
||||
ServerResponse.prototype.writeProcessing = function writeProcessing() {
|
||||
throw new Error("not implemented");
|
||||
};
|
||||
|
||||
ServerResponse.prototype.addTrailers = function (headers) {
|
||||
ServerResponse.prototype.addTrailers = function addTrailers(headers) {
|
||||
throw new Error("not implemented");
|
||||
};
|
||||
|
||||
ServerResponse.prototype.assignSocket = function (socket) {
|
||||
ServerResponse.prototype.assignSocket = function assignSocket(socket) {
|
||||
if (socket._httpMessage) {
|
||||
throw ERR_HTTP_SOCKET_ASSIGNED();
|
||||
}
|
||||
@@ -1378,20 +1378,20 @@ ServerResponse.prototype.assignSocket = function (socket) {
|
||||
this.emit("socket", socket);
|
||||
};
|
||||
|
||||
ServerResponse.prototype.detachSocket = function (socket) {
|
||||
ServerResponse.prototype.detachSocket = function detachSocket(socket) {
|
||||
throw new Error("not implemented");
|
||||
};
|
||||
|
||||
ServerResponse.prototype.writeContinue = function (callback) {
|
||||
ServerResponse.prototype.writeContinue = function writeContinue(callback) {
|
||||
throw new Error("not implemented");
|
||||
};
|
||||
|
||||
ServerResponse.prototype.setTimeout = function (msecs, callback) {
|
||||
ServerResponse.prototype.setTimeout = function setTimeout(msecs, callback) {
|
||||
// TODO:
|
||||
return this;
|
||||
};
|
||||
|
||||
ServerResponse.prototype.appendHeader = function (name, value) {
|
||||
ServerResponse.prototype.appendHeader = function appendHeader(name, value) {
|
||||
this[headersSymbol] = this[headersSymbol] ?? new Headers();
|
||||
const headers = this[headersSymbol];
|
||||
if (typeof value === "number") {
|
||||
@@ -1400,45 +1400,45 @@ ServerResponse.prototype.appendHeader = function (name, value) {
|
||||
headers.append(name, value);
|
||||
};
|
||||
|
||||
ServerResponse.prototype.flushHeaders = function () {};
|
||||
ServerResponse.prototype.flushHeaders = function flushHeaders() {};
|
||||
|
||||
ServerResponse.prototype.getHeader = function (name) {
|
||||
return getHeader(this[headersSymbol], name);
|
||||
ServerResponse.prototype.getHeader = function getHeader(name) {
|
||||
return getHeader_(this[headersSymbol], name);
|
||||
};
|
||||
|
||||
ServerResponse.prototype.getHeaders = function () {
|
||||
ServerResponse.prototype.getHeaders = function getHeaders() {
|
||||
const headers = this[headersSymbol];
|
||||
if (!headers) return kEmptyObject;
|
||||
return headers.toJSON();
|
||||
};
|
||||
|
||||
ServerResponse.prototype.getHeaderNames = function () {
|
||||
ServerResponse.prototype.getHeaderNames = function getHeaderNames() {
|
||||
const headers = this[headersSymbol];
|
||||
if (!headers) return [];
|
||||
return Array.from(headers.keys());
|
||||
};
|
||||
|
||||
ServerResponse.prototype.removeHeader = function (name) {
|
||||
ServerResponse.prototype.removeHeader = function removeHeader(name) {
|
||||
if (!this[headersSymbol]) return;
|
||||
this[headersSymbol].delete(name);
|
||||
};
|
||||
|
||||
ServerResponse.prototype.setHeader = function (name, value) {
|
||||
ServerResponse.prototype.setHeader = function setHeader(name, value) {
|
||||
this[headersSymbol] = this[headersSymbol] ?? new Headers();
|
||||
const headers = this[headersSymbol];
|
||||
if (typeof value === "number") {
|
||||
value = String(value);
|
||||
}
|
||||
setHeader(headers, name, value);
|
||||
setHeader_(headers, name, value);
|
||||
return this;
|
||||
};
|
||||
|
||||
ServerResponse.prototype.hasHeader = function (name) {
|
||||
ServerResponse.prototype.hasHeader = function hasHeader(name) {
|
||||
if (!this[headersSymbol]) return false;
|
||||
return this[headersSymbol].has(name);
|
||||
};
|
||||
|
||||
ServerResponse.prototype.writeHead = function (statusCode, statusMessage, headers) {
|
||||
ServerResponse.prototype.writeHead = function writeHead(statusCode, statusMessage, headers) {
|
||||
_writeHead(statusCode, statusMessage, headers, this);
|
||||
|
||||
return this;
|
||||
|
||||
@@ -126,7 +126,7 @@ const ucs2encode = codePoints => String.fromCodePoint(...codePoints);
|
||||
* representing integers) in the range `0` to `base - 1`, or `base` if
|
||||
* the code point does not represent a value.
|
||||
*/
|
||||
const basicToDigit = function (codePoint) {
|
||||
function basicToDigit(codePoint) {
|
||||
if (codePoint >= 0x30 && codePoint < 0x3a) {
|
||||
return 26 + (codePoint - 0x30);
|
||||
}
|
||||
@@ -137,7 +137,7 @@ const basicToDigit = function (codePoint) {
|
||||
return codePoint - 0x61;
|
||||
}
|
||||
return base;
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts a digit/integer into a basic code point.
|
||||
@@ -150,18 +150,18 @@ const basicToDigit = function (codePoint) {
|
||||
* used; else, the lowercase form is used. The behavior is undefined
|
||||
* if `flag` is non-zero and `digit` has no uppercase form.
|
||||
*/
|
||||
const digitToBasic = function (digit, flag) {
|
||||
function digitToBasic(digit, flag) {
|
||||
// 0..25 map to ASCII a..z or A..Z
|
||||
// 26..35 map to ASCII 0..9
|
||||
return digit + 22 + 75 * (digit < 26) - ((flag != 0) << 5);
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Bias adaptation function as per section 3.4 of RFC 3492.
|
||||
* https://tools.ietf.org/html/rfc3492#section-3.4
|
||||
* @private
|
||||
*/
|
||||
const adapt = function (delta, numPoints, firstTime) {
|
||||
function adapt(delta, numPoints, firstTime) {
|
||||
let k = 0;
|
||||
delta = firstTime ? floor(delta / damp) : delta >> 1;
|
||||
delta += floor(delta / numPoints);
|
||||
@@ -169,7 +169,7 @@ const adapt = function (delta, numPoints, firstTime) {
|
||||
delta = floor(delta / baseMinusTMin);
|
||||
}
|
||||
return floor(k + ((baseMinusTMin + 1) * delta) / (delta + skew));
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts a Punycode string of ASCII-only symbols to a string of Unicode
|
||||
@@ -178,7 +178,7 @@ const adapt = function (delta, numPoints, firstTime) {
|
||||
* @param {String} input The Punycode string of ASCII-only symbols.
|
||||
* @returns {String} The resulting string of Unicode symbols.
|
||||
*/
|
||||
const decode = function (input: string) {
|
||||
function decode(input: string) {
|
||||
// Don't use UCS-2.
|
||||
const output: number[] = [];
|
||||
const inputLength = input.length;
|
||||
@@ -259,7 +259,7 @@ const decode = function (input: string) {
|
||||
}
|
||||
|
||||
return String.fromCodePoint(...output);
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts a string of Unicode symbols (e.g. a domain name label) to a
|
||||
@@ -268,7 +268,7 @@ const decode = function (input: string) {
|
||||
* @param {String} input The string of Unicode symbols.
|
||||
* @returns {String} The resulting Punycode string of ASCII-only symbols.
|
||||
*/
|
||||
const encode = function (input_: string) {
|
||||
function encode(input_: string) {
|
||||
const output: string[] = [];
|
||||
|
||||
// Convert the input in UCS-2 to an array of Unicode code points.
|
||||
@@ -350,7 +350,7 @@ const encode = function (input_: string) {
|
||||
++n;
|
||||
}
|
||||
return output.join("");
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts a Punycode string representing a domain name or an email address
|
||||
@@ -363,11 +363,11 @@ const encode = function (input_: string) {
|
||||
* @returns {String} The Unicode representation of the given Punycode
|
||||
* string.
|
||||
*/
|
||||
const toUnicode = function (input) {
|
||||
function toUnicode(input) {
|
||||
return mapDomain(input, function (string) {
|
||||
return regexPunycode.test(string) ? decode(string.slice(4).toLowerCase()) : string;
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts a Unicode string representing a domain name or an email address to
|
||||
@@ -380,11 +380,11 @@ const toUnicode = function (input) {
|
||||
* @returns {String} The Punycode representation of the given domain name or
|
||||
* email address.
|
||||
*/
|
||||
const toASCII = function (input) {
|
||||
function toASCII(input) {
|
||||
return mapDomain(input, function (string) {
|
||||
return regexNonASCII.test(string) ? "xn--" + encode(string) : string;
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
/*--------------------------------------------------------------------------*/
|
||||
|
||||
|
||||
@@ -2598,7 +2598,7 @@ Interface.prototype._addHistory = _Interface.prototype[kAddHistory];
|
||||
Interface.prototype._refreshLine = _Interface.prototype[kRefreshLine];
|
||||
Interface.prototype._normalWrite = _Interface.prototype[kNormalWrite];
|
||||
Interface.prototype._insertString = _Interface.prototype[kInsertString];
|
||||
Interface.prototype._tabComplete = function (lastKeypressWasTab) {
|
||||
Interface.prototype._tabComplete = function _tabComplete(lastKeypressWasTab) {
|
||||
// Overriding parent method because `this.completer` in the legacy
|
||||
// implementation takes a callback instead of being an async function.
|
||||
this.pause();
|
||||
|
||||
@@ -518,7 +518,7 @@ function Server(options, secureConnectionListener): void {
|
||||
|
||||
let contexts: Map<string, typeof InternalSecureContext> | null = null;
|
||||
|
||||
this.addContext = function (hostname, context) {
|
||||
this.addContext = function addContext(hostname, context) {
|
||||
if (typeof hostname !== "string") {
|
||||
throw new TypeError("hostname must be a string");
|
||||
}
|
||||
@@ -533,7 +533,7 @@ function Server(options, secureConnectionListener): void {
|
||||
}
|
||||
};
|
||||
|
||||
this.setSecureContext = function (options) {
|
||||
this.setSecureContext = function setSecureContext(options) {
|
||||
if (options instanceof InternalSecureContext) {
|
||||
options = options.context;
|
||||
}
|
||||
@@ -604,11 +604,11 @@ function Server(options, secureConnectionListener): void {
|
||||
}
|
||||
};
|
||||
|
||||
Server.prototype.getTicketKeys = function () {
|
||||
Server.prototype.getTicketKeys = function getTicketKeys() {
|
||||
throw Error("Not implented in Bun yet");
|
||||
};
|
||||
|
||||
Server.prototype.setTicketKeys = function () {
|
||||
Server.prototype.setTicketKeys = function setTicketKeys() {
|
||||
throw Error("Not implented in Bun yet");
|
||||
};
|
||||
|
||||
|
||||
@@ -21,7 +21,7 @@ Object.defineProperty(ReadStream, "prototype", {
|
||||
get() {
|
||||
const Prototype = Object.create(require("node:fs").ReadStream.prototype);
|
||||
|
||||
Prototype.setRawMode = function (flag) {
|
||||
Prototype.setRawMode = function setRawMode(flag) {
|
||||
flag = !!flag;
|
||||
|
||||
// On windows, this goes through the stream handle itself, as it must call
|
||||
@@ -101,7 +101,7 @@ Object.defineProperty(WriteStream, "prototype", {
|
||||
const Real = require("node:fs").WriteStream.prototype;
|
||||
Object.defineProperty(WriteStream, "prototype", { value: Real });
|
||||
|
||||
WriteStream.prototype._refreshSize = function () {
|
||||
WriteStream.prototype._refreshSize = function _refreshSize() {
|
||||
const oldCols = this.columns;
|
||||
const oldRows = this.rows;
|
||||
const windowSizeArray = [0, 0];
|
||||
@@ -114,30 +114,30 @@ Object.defineProperty(WriteStream, "prototype", {
|
||||
}
|
||||
};
|
||||
|
||||
WriteStream.prototype.clearLine = function (dir, cb) {
|
||||
WriteStream.prototype.clearLine = function clearLine(dir, cb) {
|
||||
return require("node:readline").clearLine(this, dir, cb);
|
||||
};
|
||||
|
||||
WriteStream.prototype.clearScreenDown = function (cb) {
|
||||
WriteStream.prototype.clearScreenDown = function clearScreenDown(cb) {
|
||||
return require("node:readline").clearScreenDown(this, cb);
|
||||
};
|
||||
|
||||
WriteStream.prototype.cursorTo = function (x, y, cb) {
|
||||
WriteStream.prototype.cursorTo = function cursorTo(x, y, cb) {
|
||||
return require("node:readline").cursorTo(this, x, y, cb);
|
||||
};
|
||||
|
||||
// The `getColorDepth` API got inspired by multiple sources such as
|
||||
// https://github.com/chalk/supports-color,
|
||||
// https://github.com/isaacs/color-support.
|
||||
WriteStream.prototype.getColorDepth = function (env = process.env) {
|
||||
WriteStream.prototype.getColorDepth = function getColorDepth(env = process.env) {
|
||||
return require("internal/tty").getColorDepth(env);
|
||||
};
|
||||
|
||||
WriteStream.prototype.getWindowSize = function () {
|
||||
WriteStream.prototype.getWindowSize = function getWindowSize() {
|
||||
return [this.columns, this.rows];
|
||||
};
|
||||
|
||||
WriteStream.prototype.hasColors = function (count, env) {
|
||||
WriteStream.prototype.hasColors = function hasColors(count, env) {
|
||||
if (env === undefined && (count === undefined || (typeof count === "object" && count !== null))) {
|
||||
env = count;
|
||||
count = 16;
|
||||
@@ -148,7 +148,7 @@ Object.defineProperty(WriteStream, "prototype", {
|
||||
return count <= 2 ** this.getColorDepth(env);
|
||||
};
|
||||
|
||||
WriteStream.prototype.moveCursor = function (dx, dy, cb) {
|
||||
WriteStream.prototype.moveCursor = function moveCursor(dx, dy, cb) {
|
||||
return require("node:readline").moveCursor(this, dx, dy, cb);
|
||||
};
|
||||
|
||||
|
||||
@@ -174,7 +174,7 @@ var inherits = function inherits(ctor, superCtor) {
|
||||
});
|
||||
Object.setPrototypeOf(ctor.prototype, superCtor.prototype);
|
||||
};
|
||||
var _extend = function (origin, add) {
|
||||
function _extend(origin, add) {
|
||||
if (!add || !isObject(add)) return origin;
|
||||
var keys = Object.keys(add);
|
||||
var i = keys.length;
|
||||
@@ -182,7 +182,7 @@ var _extend = function (origin, add) {
|
||||
origin[keys[i]] = add[keys[i]];
|
||||
}
|
||||
return origin;
|
||||
};
|
||||
}
|
||||
|
||||
function callbackifyOnRejected(reason, cb) {
|
||||
if (!reason) {
|
||||
|
||||
@@ -46,13 +46,13 @@ function injectFakeEmitter(Class) {
|
||||
}
|
||||
}
|
||||
|
||||
Class.prototype.on = function (event, listener) {
|
||||
Class.prototype.on = function on(event, listener) {
|
||||
this.addEventListener(event, functionForEventType(event, listener));
|
||||
|
||||
return this;
|
||||
};
|
||||
|
||||
Class.prototype.off = function (event, listener) {
|
||||
Class.prototype.off = function off(event, listener) {
|
||||
if (listener) {
|
||||
this.removeEventListener(event, listener[wrappedListener] || listener);
|
||||
} else {
|
||||
@@ -62,7 +62,7 @@ function injectFakeEmitter(Class) {
|
||||
return this;
|
||||
};
|
||||
|
||||
Class.prototype.once = function (event, listener) {
|
||||
Class.prototype.once = function once(event, listener) {
|
||||
this.addEventListener(event, functionForEventType(event, listener), { once: true });
|
||||
|
||||
return this;
|
||||
@@ -76,7 +76,7 @@ function injectFakeEmitter(Class) {
|
||||
return MessageEvent;
|
||||
}
|
||||
|
||||
Class.prototype.emit = function (event, ...args) {
|
||||
Class.prototype.emit = function emit(event, ...args) {
|
||||
this.dispatchEvent(new (EventClass(event))(event, ...args));
|
||||
|
||||
return this;
|
||||
|
||||
@@ -223,18 +223,18 @@ ObjectDefineProperty(ZlibBase.prototype, "bytesRead", {
|
||||
},
|
||||
});
|
||||
|
||||
ZlibBase.prototype.reset = function () {
|
||||
ZlibBase.prototype.reset = function reset() {
|
||||
assert(this._handle, "zlib binding closed");
|
||||
return this._handle.reset();
|
||||
};
|
||||
|
||||
// This is the _flush function called by the transform class, internally, when the last chunk has been written.
|
||||
ZlibBase.prototype._flush = function (callback) {
|
||||
ZlibBase.prototype._flush = function _flush(callback) {
|
||||
this._transform(Buffer.alloc(0), "", callback);
|
||||
};
|
||||
|
||||
// Force Transform compat behavior.
|
||||
ZlibBase.prototype._final = function (callback) {
|
||||
ZlibBase.prototype._final = function _final(callback) {
|
||||
callback();
|
||||
};
|
||||
|
||||
@@ -264,7 +264,7 @@ const kFlushBuffers: (typeof Buffer)[] = [];
|
||||
}
|
||||
}
|
||||
|
||||
ZlibBase.prototype.flush = function (kind, callback) {
|
||||
ZlibBase.prototype.flush = function flush(kind, callback) {
|
||||
if (typeof kind === "function" || (kind === undefined && !callback)) {
|
||||
callback = kind;
|
||||
kind = this._defaultFullFlushFlag;
|
||||
@@ -278,17 +278,17 @@ ZlibBase.prototype.flush = function (kind, callback) {
|
||||
}
|
||||
};
|
||||
|
||||
ZlibBase.prototype.close = function (callback) {
|
||||
ZlibBase.prototype.close = function close(callback) {
|
||||
if (callback) finished(this, callback);
|
||||
this.destroy();
|
||||
};
|
||||
|
||||
ZlibBase.prototype._destroy = function (err, callback) {
|
||||
ZlibBase.prototype._destroy = function _destroy(err, callback) {
|
||||
_close(this);
|
||||
callback(err);
|
||||
};
|
||||
|
||||
ZlibBase.prototype._transform = function (chunk, encoding, cb) {
|
||||
ZlibBase.prototype._transform = function _transform(chunk, encoding, cb) {
|
||||
let flushFlag = this._defaultFlushFlag;
|
||||
// We use a 'fake' zero-length chunk to carry information about flushes from the public API to the actual stream implementation.
|
||||
if (typeof chunk[kFlushFlag] === "number") {
|
||||
@@ -302,7 +302,7 @@ ZlibBase.prototype._transform = function (chunk, encoding, cb) {
|
||||
processChunk(this, chunk, flushFlag, cb);
|
||||
};
|
||||
|
||||
ZlibBase.prototype._processChunk = function (chunk, flushFlag, cb) {
|
||||
ZlibBase.prototype._processChunk = function _processChunk(chunk, flushFlag, cb) {
|
||||
// _processChunk() is left for backwards compatibility
|
||||
if (typeof cb === "function") processChunk(this, chunk, flushFlag, cb);
|
||||
else return processChunkSync(this, chunk, flushFlag);
|
||||
|
||||
Reference in New Issue
Block a user