file.md
October 8, 2016 ยท View on GitHub
File based EZ streams
import * as ez from 'ez-streams'
reader = ez.devices.file.text.reader(path, encoding)
creates an EZ reader that reads from a text file.
encodingis optional. It defaults to'utf8'.writer = ez.devices.file.text.writer(path, encoding)
creates an EZ writer that writes to a text file.
encodingis optional. It defaults to'utf8'.reader = ez.devices.file.binary.reader(path)
creates an EZ reader that reads from a binary file.writer = ez.devices.file.binary.writer(path)
creates an EZ writer that writes to a binary file.reader = ez.devices.file.list(path, options)
reader = ez.devices.file.list(path, recurse, accept)
creates a reader that enumerates (recursively) directories and files.
Returns the entries as{ path: path, name: name, depth: depth, stat: stat }objects.
Twooptionsmay be specified:recurseandaccept.
Ifrecurseis falsy, only the entries immediately underpathare returned.
Ifrecurseis truthy, entries at all levels (including the root entry) are returned.
Ifrecurseis"postorder", directories are returned after their children.
acceptis an optional function which will be called asaccept(_, entry)and will control whether files or subdirectories will be included in the stream or not.