Would you like to clone this notebook?

When you clone a notebook you are able to make changes without affecting the original notebook.

Cancel

untitled notebook

node v6.17.1
version: master
endpointsharetweet
require('es6-object-assign').polyfill() const GitHubApi = require('github') const Q = require('q@1.4.1') const _ = require('underscore') const sideEffect = fn => d => { fn(d) return d } const getRepoWithMax = fn => repos => _.max(repos, fn) const github = new GitHubApi({ version: '3.0.0' }) const getReposForUser = user => Q.nfcall(github.repos.getForUser, { user }) const getIssuesWithState = (user, state) => repo => Q.nfcall(github.issues.getForRepo, { user, repo, state }) const identity = d => d const merge = (promise, outTrans = identity, inTrans = identity) => d => promise(inTrans(d)) .then(outTrans) .then(result => Object.assign({}, d, result)) const getRateLimit = () => Q.nfcall(github.misc.getRateLimit, {}) const chainPromises = (initial, promises) => promises.reduce(Q.when, Q(initial)) const username = 'ColinEberhardt' chainPromises(username, [ getReposForUser, sideEffect(d => console.log(`total repos: ${d.length}`)), getRepoWithMax(d => d.forks_count), d => ({ repo: d.name, language: d.language }), sideEffect(console.log), merge(getIssuesWithState(username, 'all'), d => ({ issueCount: d.length }), d => d.repo), sideEffect(console.log), merge(getRateLimit, d => d.rate) ]) .then(console.log) .catch(console.error)
Loading…

no comments

    sign in to comment