-
-
Save scopevale/9bb203a51471fb471f3f48ea186b836f to your computer and use it in GitHub Desktop.
Ramda promises
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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