Skip to content

Commit

Permalink
Add 'chain' method
Browse files Browse the repository at this point in the history
  • Loading branch information
pyldin601 committed Feb 6, 2018
1 parent c00d945 commit 9710d33
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 6 deletions.
6 changes: 3 additions & 3 deletions example/incrementJob.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
const LongLongJob = require('./LongLongJob');
const { repeat, done } = require('../dist/');
const { repeat, done, chain } = require('../dist/');

const incrementJob = new LongLongJob('increment-job', [
const incrementJob = new LongLongJob('increment-job', chain(
async ({ value, threshold }) => {
incrementJob.emit('tick', value);
return value < threshold
? repeat({ value: value + 1, threshold })
: done({ value, threshold });
},
]);
));

module.exports = incrementJob;
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "long-long-job",
"version": "1.0.1",
"version": "1.0.2",
"description": "Library for execution of long jobs with resume support.",
"main": "dist/index.js",
"engineStrict": true,
Expand Down
5 changes: 5 additions & 0 deletions src/chain.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { TaskUnit } from './types';

export default function <S> (...tasks: TaskUnit<S>[]): TaskUnit<S>[] {
return tasks;
}
4 changes: 2 additions & 2 deletions src/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// @flow
import { next, repeat, goto, label, done } from './helpers';
import longLongJob from './LongLongJob';
import chain from './chain';

export { next, repeat, goto, label, done, longLongJob };

export { next, repeat, goto, label, done, chain, longLongJob };

0 comments on commit 9710d33

Please sign in to comment.