1
0
forked from dyf/APP

增加mqtt

This commit is contained in:
微微一笑
2025-07-16 11:16:19 +08:00
parent e42d4af3b2
commit 6257f9d84b
1550 changed files with 5264 additions and 116701 deletions

View File

@ -1,51 +0,0 @@
'use strict'
var Writable = require('readable-stream').Writable
var inherits = require('inherits')
function CallbackStream (options, callback) {
if (!(this instanceof CallbackStream)) {
return new CallbackStream(options, callback)
}
if (typeof options === 'function') {
callback = options
options = {}
}
Writable.call(this, options)
this.results = []
this.callback = callback
this.on('finish', deliversCallback)
this.once('pipe', handlePipe)
}
function deliversCallback () {
this.callback(null, this.results)
}
function handlePipe (source) {
source.on('error', this.callback)
}
inherits(CallbackStream, Writable)
CallbackStream.prototype._write = function (data, encoding, done) {
this.results.push(data)
done()
}
CallbackStream.obj = function (options, callback) {
if (typeof options === 'function') {
callback = options
options = {}
}
options.objectMode = true
return new CallbackStream(options, callback)
}
module.exports = CallbackStream