new PipelineStage(name, opts) → {PipelineStage}
Creates a new PipelineStage
Parameters:
| Name | Type | Description |
|---|---|---|
name |
string | The name of this stage |
opts |
Object | Options for this stage |
Members
-
name :string
-
The name of this stage
-
nextStage :Array.<PipelineStage>
-
Outputs connected to this stage
Methods
-
static clearAll()
-
Removes all PipelineStages that were registered with
register. Mostly used for testing. -
static clearConverters()
-
Removes all converters that were registered with
registerConverter. Mostly used for testing. -
static create(name, opts) → {PipelineStage}
-
Creates a new stage with the corresponding name and the specified options
Parameters:
Name Type Description namestring The name of the stage to create. Name is resolved to a stage using hte global registry (see
register)optsobject The options for creating this stage
-
static findConverter(inputType, outputType) → {function}
-
Retreive a converter function that can convert from
inputTypetooutputTypeParameters:
Name Type Description inputTypestring Name of the input type
outputTypestring Name of the output type
Returns:
function -Returns a function that can perform the conversion, or undefined if one doesn't exist
-
static register(name, fn, force)
-
Register a new stage in the global registry
Parameters:
Name Type Default Description namestring The name of this stage
fnfunction The function to execute when this stage is run
forceboolean false If true, foreces registration even if a stage with the same name already exists
-
static registerConverter(inputType, outputType, fn, force)
-
Register a function for converting between types. Used to automatically convert data types between Pipeline stages
Parameters:
Name Type Default Description inputTypestring The name of the input type
outputTypestring The name of the output type
fnfunction A function that takes data of type
inputType, converts it tooutputType, and returns the converted valueforceboolean false If true, forces registration even if an existing converter for the
inputType/outputTypepair already exists -
async run(input) → {Promise.<any>}
-
Executes this stage of the pipeline with the specified input
Parameters:
Name Type Description inputany The data to use to execute this stage of the Pipeline
Returns:
Promise.<any> -A Promise that resolves to the result of this stage or rejects with an Error.
-
setOutput(stage, force)
-
Set the next stage after this one. Will automatically convert between data types using a converter if necessary.
Parameters:
Name Type Default Description stagePipelineStage The next stage
forceboolean false If true, sets the next stage even if one already exists.