Skip to content

Instantly share code, notes, and snippets.

@scopevale
Forked from andre487/ramda-promises.js
Created June 26, 2017 21:25
Show Gist options
  • Save scopevale/9bb203a51471fb471f3f48ea186b836f to your computer and use it in GitHub Desktop.
Save scopevale/9bb203a51471fb471f3f48ea186b836f to your computer and use it in GitHub Desktop.
Ramda promises
var Fs = require('fs');
var Http = require('q-io/http');
var Q = require('q');
var R = require('ramda');
var readFile = R.composeP(R.toString, R.partial(Q.ninvoke, Fs, 'readFile'));
var readPackageInfo = R.composeP(JSON.parse, readFile, R.partial(Q, 'package.json'));
var homePageFromAuthor = R.compose(R.propOr('', 1), R.match(/.+?\((.+?)\)$/), R.prop('author'));
var getHomePageHtml = R.composeP(R.toString, Http.read, homePageFromAuthor, readPackageInfo);
getHomePageHtml()
.then(R.bind(console.log, console));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment