writer.md
October 8, 2016 ยท View on GitHub
EZ Streams core writer API
import * as ez from 'ez-streams'
-
ez.writer.decorate(proto)
Adds the EZ streams writer API to an object. Usually the object is a prototype but it may be any object with awrite(_, data)method.
You do not need to call this function if you create your readers with theez.devicesmodules.
Returnsprotofor convenience. -
writer = writer.writeAll(_, val)
writesvaland ends the writer -
writer = writer.stop(_, err)
stops the writer.
by default err is silently ignored -
writer = writer.end()
ends the writer - compatiblity call (errors won't be thrown to caller) -
writer = writer.pre.action(fn)
returns another writer which appliesaction(fn)before writing to the original writer.
actionmay be any chainable action from the reader API:map,filter,transform, ... -
stream = writer.nodify()
converts the writer into a native node Writable stream.