Skip to content

Latest commit

 

History

History
25 lines (20 loc) · 971 Bytes

writer.md

File metadata and controls

25 lines (20 loc) · 971 Bytes

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 a write(_, data) method.
    You do not need to call this function if you create your readers with the ez.devices modules.
    Returns proto for convenience.

  • writer = writer.writeAll(_, val)
    writes val and 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 applies action(fn) before writing to the original writer.
    action may be any chainable action from the reader API: map, filter, transform, ...

  • stream = writer.nodify()
    converts the writer into a native node Writable stream.