new ResourceReader()
Object that joins the functionality of module:glob.Glob, module:fs.ReadStream
and module:mime-magic. It is meant to allow for matching many files, then detect the
mime-type of each one, and then read each one asynchronously through parallel streams.
There is a maximum amount for glob, stream, and mime-magic objects. If any call would exceed
these amounts, it is queued until the current number objects of their respective type is
complete. This class is also a module:events.EventEmitter, and each event emitted by a ResourceReader
object is specified in the namespace ResourceReader.event
- Since:
- 1.0
- Source:
- ResourceReader.js, line 353
Fires:
- ResourceReader.event.event:GLOB_END
- ResourceReader.event.event:GLOB_ERROR
- ResourceReader.event.event:GLOB_END
- ResourceReader.event.event:GLOB_ERROR
- ResourceReader.event.event:MIME_MAGIC_END
- ResourceReader.event.event:MIME_MAGIC_ERROR
- ResourceReader.event.event:READ_STREAM_START
- ResourceReader.event.event:READ_STREAM_DATA
- ResourceReader.event.event:READ_STREAM_END
- ResourceReader.event.event:READ_STREAM_ERROR
- ResourceReader.event.event:READ_STREAM_CLOSE
- ResourceReader.event.event:END
Extends
- module:events.EventEmitter
Namespaces
Members
-
<static, constant> DEFAULT_MIMETYPE :string
-
- Since:
- 1.0
- Default Value:
- "application/octet-stream"
- Source:
- ResourceReader.js, line 588
-
<static, constant> RECURSIVE_PATTERN :string
-
- Since:
- 1.0
- Default Value:
- "** / *" (Without the spaces)
- Source:
- ResourceReader.js, line 595
-
<static, readonly> statCache :Object
-
This object is used by every instance of module:glob.Glob created after invoking ResourceReader#read.
- Since:
- 1.0
- Default Value:
- new Object()
- Source:
- ResourceReader.js, line 604
-
filterFileBeforeRead :Function
-
- Since:
- 1.0
- Source:
- ResourceReader.js, line 425
-
<readonly> globQueue :Queue
-
- Since:
- 1.0
- Default Value:
- new Queue()
- Source:
- ResourceReader.js, line 391
-
maxNumOfGlobs :uint
-
- Since:
- 1.0
- Default Value:
- 8
- Source:
- ResourceReader.js, line 431
-
maxNumOfMimeMagics :uint
-
- Since:
- 1.0
- Default Value:
- 4
- Source:
- ResourceReader.js, line 437
-
maxNumOfStreams :uint
-
- Since:
- 1.0
- Default Value:
- 4
- Source:
- ResourceReader.js, line 443
-
<readonly> mimeMagicQueue :Queue
-
- Since:
- 1.0
- Default Value:
- new Queue()
- Source:
- ResourceReader.js, line 398
-
numOfGlobs :uint
-
- Since:
- 1.0
- Default Value:
- 0
- Source:
- ResourceReader.js, line 449
-
numOfMimeMagics :uint
-
- Since:
- 1.0
- Default Value:
- 0
- Source:
- ResourceReader.js, line 455
-
numOfStreams :uint
-
- Since:
- 1.0
- Default Value:
- 0
- Source:
- ResourceReader.js, line 461
-
recursive :boolean
-
- Since:
- 1.0
- Default Value:
- false
- Source:
- ResourceReader.js, line 467
-
<readonly> streamQueue :Queue
-
- Since:
- 1.0
- Default Value:
- new Queue()
- Source:
- ResourceReader.js, line 405
-
<readonly> streams :Object
-
- Since:
- 1.0
- Default Value:
- new Object()
- Source:
- ResourceReader.js, line 412
-
<readonly> totalAsync :uint
-
- Since:
- 1.0
- Default Value:
- 0
- Source:
- ResourceReader.js, line 474
Methods
-
destroyStream(file) → {void}
-
Parameters:
Name Type Description file
string - Since:
- 1.0
- Source:
- ResourceReader.js, line 503
Returns:
- Type
- void
-
getActiveStream(file) → {module:fs.ReadStream}
-
Parameters:
Name Type Description file
string - Since:
- 1.0
- Source:
- ResourceReader.js, line 491
Returns:
- Type
- module:fs.ReadStream
-
read(patterns, cwd, recursive) → {ResourceReader}
-
Parameters:
Name Type Argument Default Description patterns
Array.<string> cwd
string <optional>
Use this instead of the value returned by process.cwd(). recursive
boolean <optional>
false - Since:
- 1.0
- Source:
- ResourceReader.js, line 531
Throws:
ErrorReturns:
this- Type
- ResourceReader
-
reset() → {ResourceReader}
-
Removes properties that may have been set after instantiation.
- Since:
- 1.0
- Source:
- ResourceReader.js, line 562
Returns:
this- Type
- ResourceReader