1.0.0 • Published 9 years ago

thunk-runner v1.0.0

Weekly downloads
2
License
MIT
Repository
github
Last release
9 years ago

thunk-runner

NPM version js-xo-style

Execute each thunk in an array of thunks, nonconcurrently

Installation

Install thunk-runner using npm:

npm install --save thunk-runner

Usage

Module usage

var thunkRunner = require('thunk-runner');

// Example creating folders and files:
var fs = require('fs');
// mkdir which returns a thunk:
var mkdir = function (dir) {
  return function (cb) {
    return fs.mkdir(dir, cb);
  };
};
// writeFile which returns a thunk:
var writeFile = function (file, content) {
  return function (cb) {
    return fs.writeFile(file, content, 'utf8', cb);
  };
};

var thunks = [
  mkdir('src'),
  mkdir('src/folder'),
  writeFile('src/folder/index.js', 'var test = 1;\n')
];

thunkRunner(thunks)(function (err) {
  // done...
});

API

thunkRunner(thunks)

NameTypeDescription
thunksArrayThe thunks to execute

Runs all thunks in the given array, one at a time, waiting on each to complete before running the next. Returns a thunk.

License

MIT