0.0.2 • Published 7 years ago

nextable v0.0.2

Weekly downloads
4
License
MIT
Repository
github
Last release
7 years ago

nextable

Build Status

Known Vulnerabilities

Computing any kinds of functions in serial order.

Install

npm install nextable

Usage

Require nextable

const nextable = require('nextable');

Functions of async and sync

// if not passing "next" to the arguments,
// will be treated like a normal function.
const normalTask = () => {
  console.log('normal task');
};

// if passing "next" to the arguments,
// will wait for "next" to be called
const setTimeoutTask = next => {
  setTimeout(() => {
    console.log('setTimeout Task');
    next();
  }, 1000);
};

const promiseTask = next =>
  new Promise(resolve => {
    console.log('promise Task');
    next();
    resolve();
  });

Passing any kind of functions:

nextable(
  setTimeoutTask,
  promiseTask,
  normalTask
);

// will logs
// -> setTimeout Task
// -> promise Task
// -> normal Task

Test

npm test

LICENSE

MIT