task-registry-series

0.2.9 • Public • Published

task-registry-series npm

Build Status Code Climate Test Coverage downloads license

The SeriesTask run a task collection(array) one by one.

Usage

Task    = require 'task-registry'
tasks   = require 'task-registry-series'
register= Task.register
 
class OneTask
  register OneTask
  executeSync: (aOptions)->
    # the aOptions is the default options object of the task if no arguments passed. 
    aOptions = 0 unless isNumber aOptions
    aOptions+1
 
class TwoTask
  register TwoTask
  executeSync: (aOptions)->
    aOptions = 0 unless isNumber aOptions
    aOptions+2
 
result = tasks.execSync
  pipeline: true
  tasks: [
    One: 1 # call OneTask with 1 argument 
  'Two'  # call Two 
  ]  # the result should be 4 

API

tasks.execSync(aOptions)/task.exec(aOptions, done)

  • aOptions (Object|Array|String): it's a tasks if it's array. it's a task name if it's string.
    • pipeline (Boolean): whether the pass the result as a pipeline. default to false.
    • If true, the first task will be called with the arguments, and each subsequence task will be called with the result of the previous task.
    • If false, Each task will be called with the arguments, and each may return a value.
    • tasks (ArrayOf String|Object): the tasks to run.
      • Object:
        • key: it's the task name
        • value: it's the arugments object to be passed.
    • force (Boolean): whether force to continue executing even though a task occur error. default to false, ignore the raiseError if true.
    • raiseError (Boolean): whether throw the error. default to true.
    • logger (Logger Object): default to null.

TODO

License

MIT

Package Sidebar

Install

npm i task-registry-series

Weekly Downloads

4

Version

0.2.9

License

MIT

Last publish

Collaborators

  • riceball