0.4.8 • Published 10 years ago

when-all v0.4.8

Weekly downloads
5
License
MIT
Repository
github
Last release
10 years ago

when-all

normalize an object/array where some value may be wrapped in Results

Installation

With component, packin

$ {package mananger} install jkroso/when-all

With npm

$ npm install --save when-all

then in your app:

var all = require('when-all')

API

all(x)

Create a Result for a new x with all values lifted out of their Results

all([
  getPage('google.com'),
  getPage('google.co.nz')
]).then(compare)
all({
  usa: getPage('google.com'),
  nz: getPage('google.co.nz')
}).then(compare)

Example

You could decorate a function so it can take Results as arguments.

var all = require('when-all')

function decorate(fn) {
  return function(){
    var self = this
    return all(arguments).then(function(args){
      return fn.apply(self, args)
    })
  }
}

var asyncCompare = decorate(compare)
asyncCompare(
  getPage('google.com'),
  getPage('google.co.nz')
)

Running the tests

$ make

Then open your browser to.

0.4.8

10 years ago

0.4.7

10 years ago

0.4.6

10 years ago

0.4.5

11 years ago

0.4.4

11 years ago

0.4.3

11 years ago

0.4.2

11 years ago

0.4.1

11 years ago

0.4.0

11 years ago

0.3.0

11 years ago

0.2.2

11 years ago