exec-fn

1.0.1 • Public • Published

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

Readme

Keywords

none

Package Sidebar

Install

npm i exec-fn

Weekly Downloads

2

Version

1.0.1

License

MIT

Last publish

Collaborators

  • vdemedes