Created
September 8, 2015 10:29
-
-
Save andre487/e637a8024a29afa2e36c to your computer and use it in GitHub Desktop.
Ramda promises
This file contains hidden or 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
👍