Skip to content

Latest commit

 

History

History
30 lines (26 loc) · 1.74 KB

README.md

File metadata and controls

30 lines (26 loc) · 1.74 KB

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!`))
  )