Files
NapCatQQ/.pnpm-store/v3/files/32/7a4d25679bd416b03e1426889eb7db6c32481a5143f90966cf270ade21386a4b49e75a7649eb39b08ccee8d6a6e0c435b4f6a8e9b58bb3ac54083d0e2208fe
TanTan e311ca3275
Build NapCat Artifacts / Windows Loader Test (push) Canceled after 0s
Build NapCat Artifacts / Type Check & Test (push) Canceled after 0s
Build NapCat Artifacts / Build NapCat.Framework (push) Canceled after 0s
Build NapCat Artifacts / Build NapCat.Shell (push) Canceled after 0s
docs: 仓库链接指向本镜像仓库
2026-11-13 09:25:58 +08:00

42 lines
1.3 KiB
Plaintext

/*
* FlushWritable
* Copyright 2014 Tom Frost
*/
var EventEmitter = require('events').EventEmitter,
Writable = require('stream').Writable,
util = require('util');
/**
* FlushWritable is a drop-in replacement for stream.Writable that implements
* the Transform stream's _flush() method. FlushWritable is meant to be
* extended, just like stream.Writable. However, in the child class's
* prototype, a method called _flush(cb) can be defined that will halt the
* firing of the 'finish' event until the callback is called. If the callback
* if called with a truthy first argument, 'error' is emitted instead.
* @param {Object} [opts] Options to configure this Writable stream. See the
* Node.js docs for stream.Writable.
* @constructor
*/
function FlushWritable(opts) {
Writable.call(this, opts);
}
util.inherits(FlushWritable, Writable);
FlushWritable.prototype.emit = function(evt) {
if (evt === 'finish' && this._flush && !Writable.prototype._flush) {
this._flush(function(err) {
if (err)
EventEmitter.prototype.emit.call(this, 'error', err);
else
EventEmitter.prototype.emit.call(this, 'finish');
}.bind(this));
}
else {
var args = Array.prototype.slice.call(arguments);
EventEmitter.prototype.emit.apply(this, args);
}
};
module.exports = FlushWritable;