Class Interface

Defined in: src/lib/taskgroup.coffee
Inherits: EventEmitter

Overview

Base class containing common functionality for Task and TaskGroup.

Subclasses

Task, TaskGroup

Instance Method Summary

Constructor Details

::constructor() Source

Adds support for the done event while ensuring that errors are always handled correctly.

It does this by listening to the error and completed events, and when the emit, we check if there is a done listener:

  • if there is, then emit the done event with the original event arguments
  • if there isn't, then output the error to stderr and throw it.

Instance Method Details

::complete() Source

Fire our completion event.

::done(args...) Source

Alias for ::onceDone

Object ::getConfig() Source

Get the configuration of our instance.

Returns:

  • (Object) — Returns our configuration Object directly.

String ::getName() Source

Get the name of our instance.

If the name was never configured, then return the name in the format of '#{@type} #{Math.random()}' to output something like task 0.2123

Returns:

  • (String) — Returns the configured name String.

String ::getNames(opts = {}) Source

Get our name with all of our parent names into a String or Array.

Parameters:

  • optsThe options
    • (String) format(default: 'string') A String that determines the format that we return, when string it will output a string of all our names, when array it will return the names as an array
    • (String) seperator(default: ' ➞ ') A String that is used to join our array when returning a joined String

Returns:

  • (String) — Returns either a joined String or an Array based on the value of the format option.

::onceDone(listener) Source

Attaches the listener to the done event to be emitted only once, then removed to not fire again.

Parameters:

  • (Function) listenerThe Function to attach to the done event.

::whenDone(listener) Source

Attaches the listener to the done event to be emitted each time.

Parameters:

  • (Function) listenerThe Function to attach to the done event.