Skip to content

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

License

Notifications You must be signed in to change notification settings

jamonkko/bluebird-chain

Repository files navigation

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

About

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

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published