Class: ResourceReader

ResourceReader

new ResourceReader(emitter)

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 module:node-samson/lib/event
Parameters:
Name Type Argument Description
emitter EventEmitter <optional>
Since:
  • 1.0
Source:
  • ResourceReader.js, line 284
Fires:
  • node-samson/lib/event.event:READER_GLOB_END
  • node-samson/lib/event.event:READER_MIME_MAGIC_END
  • node-samson/lib/event.event:READER_STREAM_START
  • node-samson/lib/event.event:READER_STREAM_DATA
  • node-samson/lib/event.event:READER_STREAM_END
  • node-samson/lib/event.event:READER_STREAM_ERROR
  • node-samson/lib/event.event:READER_STREAM_CLOSE
  • node-samson/lib/event.event:READER_END

Extends

  • module:events.EventEmitter

Members

<static, constant> DEFAULT_MIMETYPE :string

Since:
  • 1.0
Default Value:
  • "application/octet-stream"
Source:
  • ResourceReader.js, line 538

<static, constant> RECURSIVE_PATTERN :string

Since:
  • 1.0
Default Value:
  • "** / *" (Without the spaces)
Source:
  • ResourceReader.js, line 545

<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 554

emit

Override EventEmitter.prototype.emit to allow for an "EventTarget-like" approach to emitting events.
Since:
  • 1.0
Source:
  • ResourceReader.js, line 425

<readonly> emitter :EventEmitter

Since:
  • 1.0
Source:
  • ResourceReader.js, line 318

filterFileBeforeRead :Function

Since:
  • 1.0
Source:
  • ResourceReader.js, line 359

<readonly> globQueue :Queue

Since:
  • 1.0
Default Value:
  • new Queue()
Source:
  • ResourceReader.js, line 325

maxNumOfGlobs :uint

Since:
  • 1.0
Default Value:
  • 8
Source:
  • ResourceReader.js, line 365

maxNumOfMimeMagics :uint

Since:
  • 1.0
Default Value:
  • 4
Source:
  • ResourceReader.js, line 371

maxNumOfStreams :uint

Since:
  • 1.0
Default Value:
  • 4
Source:
  • ResourceReader.js, line 377

<readonly> mimeMagicQueue :Queue

Since:
  • 1.0
Default Value:
  • new Queue()
Source:
  • ResourceReader.js, line 332

numOfGlobs :uint

Since:
  • 1.0
Default Value:
  • 0
Source:
  • ResourceReader.js, line 383

numOfMimeMagics :uint

Since:
  • 1.0
Default Value:
  • 0
Source:
  • ResourceReader.js, line 389

numOfStreams :uint

Since:
  • 1.0
Default Value:
  • 0
Source:
  • ResourceReader.js, line 395

recursive :boolean

Since:
  • 1.0
Default Value:
  • false
Source:
  • ResourceReader.js, line 401

<readonly> streamQueue :Queue

Since:
  • 1.0
Default Value:
  • new Queue()
Source:
  • ResourceReader.js, line 339

<readonly> streams :Object

Since:
  • 1.0
Default Value:
  • new Object()
Source:
  • ResourceReader.js, line 346

<readonly> totalAsync :uint

Since:
  • 1.0
Default Value:
  • 0
Source:
  • ResourceReader.js, line 408

Methods

destroyStream(file) → {void}

Parameters:
Name Type Description
file string
Since:
  • 1.0
Source:
  • ResourceReader.js, line 454
Returns:
Type
void

getActiveStream(file) → {module:fs.ReadStream}

Parameters:
Name Type Description
file string
Since:
  • 1.0
Source:
  • ResourceReader.js, line 442
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 482
Throws:
Error
Returns:
this
Type
ResourceReader

reset() → {ResourceReader}

Removes properties that may have been set after instantiation.
Since:
  • 1.0
Source:
  • ResourceReader.js, line 513
Returns:
this
Type
ResourceReader