file-emitter
A recursive file emitter
Stability: 3 - Stable
fileEmitter(folder, opt_options)
Create a new FileEmitter
object, extends events.EventEmitter
.
{string} folder
{?Object} opt_options
opt_options
{boolean} buffer
Load each file into a buffer before emitting, defaults tofalse
{number} maxBufferSize
The max size of a file buffer, defaults to10485760
(=10MiB){boolean} incremental
Whentrue
eachfile
event has to be acknowledged by callingfe.next()
{boolean} followSymLinks
..., defaults tofalse
{boolean} recursive
..., defaults totrue
{boolean} autorun
..., defaults totrue
{Array<string>} exclude
glob patterns applied afterreadir
{Array<string>} include
glob patterns applied afterstat
{Object} minimatchOptions
Seeminimatch
README, defaults to{matchBase: true}
{Function} File
A custom constructor for file objects, has to extendFile
Example
var fileEmitter = ;var fe = ; fe; fe; // everything but EMFILEfe;
fe.run()
Manually start scanning the folder & emitting files when autostart=false
.
fe.next()
When the emitter runs with incremental = true
a call to next()
is required after each file
event to acknowledge that the file has been processed.
Used to process files asynchronously while preventing allocation of large queues & file buffers.
fileEmitter.list(folder, opt_options, callback)
Convenience method to retrieve a list of files.
opt_options
- all options of
fileEmitter()
except forincremental
&autorun
{function(File, File)} compare
A compare function passed toArray.sort()
Example
fileEmitter;
Tests
npm testfirefox coverage/lcov-report/index.html
Coverage
Statements : 94.05% ( 174/185 )
Branches : 89.90% ( 89/99 )
Functions : 100% ( 21/21 )