1.0.1 • Published 9 years ago

exec-fn v1.0.1

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

exec-fn Circle CI

Execute function, promise, generator and get a consistent result.

Installation

$ npm install exec-fn --save

Usage

const execute = require('exec-fn');

function regularFn () {
  return 'regular';
}

function promiseFn () {
  return Promise.resolve('promise');
}

function * generatorFn () {
  return 'generator';
}

exec(regularFn).then(function (value) {
  value === 'regular';
});

exec(promiseFn).then(function (value) {
  value === 'promise';
});

exec(generatorFn).then(function (value) {
  value === 'generator';
});

API

exec(fn, arguments, context)
  • fn - function to execute. Can be a regular function, generator function or function that returns a Promise.
  • arguments - array of arguments for the fn (optional)
  • context - context for the fn (optional)

Tests

Circle CI

$ make test

License

MIT © vdemedes