/bluebird-chain

Compose your async program flow from pure-style functions and promises

Primary LanguageJavaScriptMIT LicenseMIT

Build Status Coverage Status npm version npm downloads Dependency Status devDependency Status JavaScript Style Guide Greenkeeper badge

bluebird-chain

Compose your async program flow from pure style functions and promises. Sorry await, it does not really get any better than this!

tl;dr

  import pchain from 'bluebird-chain'
  import _ from 'lodash/fp'
  import { getBooksReadAsync, calculateTasteScoreAsync } from 'my_async_functions'

  pchain(
    ['John', 'Mary', 'Spirit'],
    _.reduce((res, name) => _.assign(res, {[name]: getBooksReadAsync(name)}), {}),
    _.mapValues((books) => calculateTasteScoreAsync(books)),
    _.toPairs,
    _.map(_.zipObject(['name', 'score'])),
    _.maxBy('score'),
    _.tap(({name}) => console.log(`${name} has the best taste!`))
  )