J'ai juste update le cutie.js, CONNARD
Ah oui, j'ai aussi add le info.js, qui est merdique d'ailleurs
This commit is contained in:
Syxpi
2025-10-11 22:06:46 +02:00
parent 14d4df5a40
commit b5cba1c318
283 changed files with 15040 additions and 12924 deletions

View File

@@ -271,30 +271,67 @@ class Query extends Command {
}
stream(options) {
options = options || {};
options = options || Object.create(null);
options.objectMode = true;
const stream = new Readable(options);
stream._read = () => {
this._connection && this._connection.resume();
};
this.on('result', (row, resultSetIndex) => {
if (!stream.push(row)) {
this._connection.pause();
const stream = new Readable({
...options,
emitClose: true,
autoDestroy: true,
read: () => {
this._connection && this._connection.resume();
},
});
// Prevent a breaking change for users that rely on `end` event
stream.once('close', () => {
if (!stream.readableEnded) {
stream.emit('end');
}
stream.emit('result', row, resultSetIndex); // replicate old emitter
});
this.on('error', (err) => {
stream.emit('error', err); // Pass on any errors
});
this.on('end', () => {
stream.push(null); // pushing null, indicating EOF
});
this.on('fields', (fields) => {
const onResult = (row, index) => {
if (stream.destroyed) return;
if (!stream.push(row)) {
this._connection && this._connection.pause();
}
stream.emit('result', row, index); // replicate old emitter
};
const onFields = (fields) => {
if (stream.destroyed) return;
stream.emit('fields', fields); // replicate old emitter
});
stream.on('end', () => {
stream.emit('close');
});
};
const onEnd = () => {
if (stream.destroyed) return;
stream.push(null); // pushing null, indicating EOF
};
const onError = (err) => {
stream.destroy(err);
};
stream._destroy = (err, cb) => {
this._connection && this._connection.resume();
this.removeListener('result', onResult);
this.removeListener('fields', onFields);
this.removeListener('end', onEnd);
this.removeListener('error', onError);
cb(err); // Pass on any errors
};
this.on('result', onResult);
this.on('fields', onFields);
this.on('end', onEnd);
this.on('error', onError);
return stream;
}