1.1.0 • Published 8 years ago

promise-fnapply v1.1.0

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

promise-fnapply

Build status NPM version XO code style

A Function.apply that can deal with promise arguments

Installation

Install promise-fnapply using npm:

npm install --save promise-fnapply

Usage

Module usage

const apply = require('promise-fnapply');

function greet(val) {
  return `hello ${val}`;
}

apply(greet, [Promise.resolve('world')])
  .then(val => {
    // val === 'hello world'
  });

API

apply(fn, promises, thisArg)

NameTypeDescription
fnFunction|Promise<Function>The function, or a promise resolving to a function, to apply with the resolved promises as argument array
promisesArray<Promise>The arguments array to pass to fn when they all are resolved
thisArgAnyThe value to be passed as this when calling fn

Returns: Promise, which resolves to the result of applying fn with the resolved values of promises.

Related

License

MIT © Joakim Carlstein