-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 59a50f6
Showing
8 changed files
with
657 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
node_modules |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
{ | ||
"browser": false, | ||
"esnext": true, | ||
"globals": { | ||
"require": true, | ||
"module": true, | ||
"process": true, | ||
"__dirname": true, | ||
"Buffer": true, | ||
"setTimeout": true, | ||
"exports": true | ||
}, | ||
"strict": false, | ||
"globalstrict": true, | ||
"quotmark": true, | ||
"smarttabs": true, | ||
"trailing": true, | ||
"unused": "vars", | ||
"curly": true, | ||
"debug": false, | ||
"devel": false, | ||
"eqeqeq": true, | ||
"eqnull": true, | ||
"evil": true, | ||
"forin": false, | ||
"immed": true, | ||
"laxbreak": false, | ||
"newcap": true, | ||
"noarg": true, | ||
"noempty": false, | ||
"nonew": true, | ||
"nomen": false, | ||
"onevar": false, | ||
"plusplus": false, | ||
"undef": true, | ||
"sub": true, | ||
"white": false, | ||
"latedef": "nofunc" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
The MIT License (MIT) | ||
|
||
Copyright (c) 2015 Phillip Gates-Idem | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,113 @@ | ||
task-list | ||
=========== | ||
Simple utility library for managing a list of tasks and their lifecycle. | ||
|
||
## Installation | ||
```bash | ||
npm install task-list --save | ||
``` | ||
|
||
## Overview | ||
A task list is created from an array of objects. Each object has a `start` | ||
function and an optional `stop` function. Both of these functions should expect | ||
a callback argument that should be invoked when the operation completes. | ||
Operations can be called on the task list and if a logger was provided | ||
in the config then the current activity will be logged via the given logger. | ||
|
||
## Usage | ||
Simple example with minimal configuration: | ||
```javascript | ||
var serviceList = taskList.create([ | ||
{ | ||
name: 'service1', | ||
|
||
start: function(callback) { | ||
task1Started = true; | ||
callback(); | ||
}, | ||
|
||
stop: function(callback) { | ||
task1Started = false; | ||
callback(); | ||
} | ||
}, | ||
|
||
{ | ||
name: 'service2', | ||
|
||
start: function(callback) { | ||
task2Started = true; | ||
callback(); | ||
}, | ||
|
||
stop: function(callback) { | ||
task2Started = false; | ||
callback(); | ||
} | ||
} | ||
]); | ||
|
||
serviceList.startAll(function(err) { | ||
if (err) { | ||
// some error occurred | ||
} else { | ||
// services are running | ||
} | ||
|
||
// now stop the services | ||
serviceList.stopAll(function(err) { | ||
if (err) { | ||
// one or more services failed to stop | ||
} else { | ||
// all services stopped successfully | ||
} | ||
}); | ||
}); | ||
``` | ||
|
||
An example that provides a `logger`: | ||
```javascript | ||
var serviceList = taskList.create({ | ||
logger: { | ||
info: function(message) { | ||
console.log('INFO: ' + message); | ||
}, | ||
|
||
success: function(message) { | ||
console.log('SUCCESS: ' + message); | ||
}, | ||
|
||
error: function(message) { | ||
console.error('ERROR: ' + message); | ||
} | ||
}, | ||
|
||
tasks: [ | ||
{ | ||
name: 'task1', | ||
|
||
start: function(callback) { | ||
// do something | ||
callback(); | ||
}, | ||
|
||
stop: function(callback) { | ||
callback(); | ||
} | ||
}, | ||
|
||
{ | ||
name: 'task2', | ||
|
||
start: function(callback) { | ||
// do something | ||
callback(); | ||
}, | ||
|
||
stop: function(callback) { | ||
callback(); | ||
} | ||
} | ||
] | ||
}); | ||
``` |
Oops, something went wrong.