Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

snowyu/task-registry-series.js

Open more actions menu

Repository files navigation

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

About

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

Resources

License

Stars

Watchers

Forks

Packages

No packages published
Morty Proxy This is a proxified and sanitized view of the page, visit original site.