Class: TaskArray<T2>
index.TaskArray
Represents an array of tasks. These are usually created when operating on collections of source files.
The transform()
and pipe()
methods operate on the entire collection of tasks. To process tasks individually, use the map()
or reduce()
methods.
Type parameters
Name | Type |
---|---|
T2 | extends Task <any > |
Hierarchy
-
AbstractTask
<T2
[]>↳
TaskArray
Table of contents
Constructors
Properties
Accessors
Methods
Constructors
constructor
• new TaskArray<T2
>(sources
, path
)
Type parameters
Name | Type |
---|---|
T2 | extends Task <any , T2 > |
Parameters
Name | Type |
---|---|
sources | T2 [] |
path | Path |
Overrides
Defined in
Properties
path
• Readonly
path: Path
The filesystem location associated with the build artifact produced by this task.
Inherited from
Accessors
length
• get
length(): number
Returns the number of tasks in this TaskArray
.
Returns
number
Defined in
Methods
addDependent
▸ addDependent(dependent
, dependencies
): void
Mark a task as being dependent on this task, meaning that the target is considered to be out of date when any of its dependencies are out of date.
Parameters
Name | Type |
---|---|
dependent | Task <unknown > |
dependencies | Set <SourceTask > |
Returns
void
Overrides
Defined in
dest
▸ dest(baseOrPath
, fragment?
): OutputFileTask
Create an output task that writes to a specified location. This method is only valid if the output type of the task is a string or Buffer object.
Examples:
path.dest(newPath);
path.dest(newBase, null);
path.dest(null, newFragment);
path.dest(path => path.withBase(newBase));
Parameters
Name | Type |
---|---|
baseOrPath | null | string | Path | PathMapping |
fragment? | null | string |
Returns
OutputFileTask
Inherited from
Defined in
find
▸ find(predicate
): undefined
| T2
Find a task by some predicate.
Parameters
Name | Type |
---|---|
predicate | (value : T2 ) => boolean |
Returns
undefined
| T2
Defined in
items
▸ items(): T2
[]
The array of tasks contained in this TaskArray
.
Returns
T2
[]
Defined in
map
▸ map<Out
, Depends
>(fn
): TaskArray
<Depends
>
Works like Array.map(), except that the elements are tasks.
Type parameters
Name | Type |
---|---|
Out | Out |
Depends | extends Task <Out , Depends > |
Parameters
Name | Type |
---|---|
fn | (input : T2 ) => Depends |
Returns
TaskArray
<Depends
>
Defined in
pipe
▸ pipe<Out
, Dependant
>(taskGen
): Dependant
Pipe the output of this task through another task. Similar to transform()
, except that it allows more flexibility in processing.
Type parameters
Name | Type |
---|---|
Out | Out |
Dependant | extends Task <Out , Dependant > |
Parameters
Name | Type |
---|---|
taskGen | (input : TaskArray <T2 >) => Dependant |
Returns
Dependant
Inherited from
Defined in
read
▸ read(): Promise
<T2
[]>
Returns a Promise that resolves to the data output by this task. This is generally called by pipeline operators to read the data from the previous step, however operators are not required to do this.
Returns
Promise
<T2
[]>
Overrides
Defined in
reduce
▸ reduce<Out
>(init
, reducer
): Task
<Out
>
Combine the output of all the tasks in the task array into a single data structure. The reducer function operates much like Array.reduce()
except that it is asynchronous.
Type parameters
Name |
---|
Out |
Parameters
Name | Type | Description |
---|---|---|
init | Out | The initial value before any reductions. |
reducer | (acc : Out , next : T2 ) => Out | Promise <Out > | Function which combines the accumulated value with new values. |
Returns
Task
<Out
>
A new Task which produces the combined output of the reduction.
Defined in
transform
▸ transform<Out
>(transform
): Task
<Out
>
Creates a new task which transforms the output of this task’s data. The transform
argument is a function which accepts the task’s output as an argument, and which returns either the transformed data or a promise which resolves to that data.
The task created will list the current task as a dependency, so if the source file is changed the transform task will be re-run.
Type parameters
Name |
---|
Out |
Parameters
Name | Type |
---|---|
transform | (input : T2 []) => Out | Promise <Out > |
Returns
Task
<Out
>