MCPcopy
hub / github.com/PokemonGoF/PokemonGo-Bot / BufferList

Function BufferList

map-chat/javascript/browserMqtt.js:2037–2070  ·  view source on GitHub ↗
(callback)

Source from the content-addressed store, hash-verified

2035 , util = require('util')
2036
2037function BufferList (callback) {
2038 if (!(this instanceof BufferList))
2039 return new BufferList(callback)
2040
2041 this._bufs = []
2042 this.length = 0
2043
2044 if (typeof callback == 'function') {
2045 this._callback = callback
2046
2047 var piper = function (err) {
2048 if (this._callback) {
2049 this._callback(err)
2050 this._callback = null
2051 }
2052 }.bind(this)
2053
2054 this.on('pipe', function (src) {
2055 src.on('error', piper)
2056 })
2057 this.on('unpipe', function (src) {
2058 src.removeListener('error', piper)
2059 })
2060 }
2061 else if (Buffer.isBuffer(callback))
2062 this.append(callback)
2063 else if (Array.isArray(callback)) {
2064 callback.forEach(function (b) {
2065 Buffer.isBuffer(b) && this.append(b)
2066 }.bind(this))
2067 }
2068
2069 DuplexStream.call(this)
2070}
2071
2072util.inherits(BufferList, DuplexStream)
2073

Callers

nothing calls this directly

Calls 1

callMethod · 0.80

Tested by

no test coverage detected