Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
transform (chunk, encoding, callback) {
let pos = 0
if (remainingLength === 0) {
pos = chunk.indexOf(SEPARATOR_CODE)
remainingLength = parseInt(chunk.slice(0, pos).toString(), 10)
pos += 1
}
const remainingData = chunk.slice(pos, pos + remainingLength)
currentBuffer = Buffer.concat([currentBuffer, remainingData])
remainingLength -= remainingData.length
pos += remainingData.length
if (remainingLength === 0) {
this.push(jsonParse(currentBuffer.toString()))
currentBuffer = Buffer.alloc(0)
}
if (pos < chunk.length) {
return this._transform(chunk.slice(pos), encoding, callback)
}
callback()
}
})