javascript - `stream.Transform.unshift()` in Node.js -


consider simple example:

stream = require 'stream' util = require 'util'  class testtransform extends stream.transform     _transform: (chunk, encoding, callback) ->         if not @nomore             @nomore = true             @unshift chunk # handle later         else             @push " <#{chunk.tostring().touppercase()}>"         callback()  mt = new testtransform() mt.write 'first' mt.write 'second' mt.on 'data', (chunk) -> console.log "data: #{util.inspect chunk.tostring()}" 
$ coffee test.coffee data: 'first <second>' 

this transform stream tries push it's first chunk read queue, handled in next _transform call.

but reason, unshifting in transform causes data go output without getting _transform again (and hence not uppercased). intentionally or missing something?

unshift readable method. means when call on transform, you're pushing stuff output-side buffer, not input-side.

don't this. since have no way of knowing how in output-side buffer, pushes data in non-deterministic order.


Comments

Popular posts from this blog

javascript - RequestAnimationFrame not working when exiting fullscreen switching space on Safari -

jsf - How to ajax update an item in the footer of a PrimeFaces dataTable? -

django - CSRF verification failed. Request aborted. CSRF cookie not set -