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
function add (x, y) {return x+y} | |
let curry = (f, ...args) => f.bind.apply(f,[null, ...args]) | |
let add4 = curry(add,4) | |
console.log(add4(5)) //9 | |
let add4n6 = curry(add4,6) | |
console.log(add4n6()) //10 |
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
const bb = require('bluebird'); | |
const axios = require('axios'); | |
const f = require('lodash/fp'); | |
const autheader = 'token xxx'; | |
const fetch = (page, continuePredicate, accumulator = [] ) => | |
axios.get('https://api.github.com/orgs/:org/repos', { | |
params: { | |
page, | |
per_page: 100 |
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
# install zsh | |
sudo apt-get update | |
sudo apt-get install zsh git -y | |
sh -c "$(curl -fsSL https://raw.github.com/robbyrussell/oh-my-zsh/master/tools/install.sh)" | |
chsh -s $(which zsh) | |
# manual: edit theme in ~/.zshrc to "clean" | |
# ssh-key | |
ssh-keygen -t rsa |
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
const makeRequest = () => | |
getJSON() | |
.then(data => { | |
console.log(data) | |
return "done" | |
}) | |
makeRequest() |
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
const makeRequest = async () => { | |
console.log(await getJSON()) | |
return "done" | |
} | |
makeRequest() |
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
const makeRequest = () => { | |
try { | |
getJSON() | |
.then(result => { | |
// this parse may fail | |
const data = JSON.parse(result) | |
console.log(data) | |
}) | |
// uncomment this block to handle asynchronous errors | |
// .catch((err) => { |
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
const makeRequest = async () => { | |
try { | |
// this parse may fail | |
const data = JSON.parse(await getJSON()) | |
console.log(data) | |
} catch (err) { | |
console.log(err) | |
} | |
} |
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
const makeRequest = () => { | |
return getJSON() | |
.then(data => { | |
if (data.needsAnotherRequest) { | |
return makeAnotherRequest(data) | |
.then(moreData => { | |
console.log(moreData) | |
return moreData | |
}) | |
} else { |
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
const makeRequest = async () => { | |
const data = await getJSON() | |
if (data.needsAnotherRequest) { | |
const moreData = await makeAnotherRequest(data) | |
console.log(moreData) | |
return moreData | |
} else { | |
console.log(data) | |
return data | |
} |
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
const makeRequest = () => { | |
return promise1() | |
.then(value1 => { | |
// do something | |
return promise2(value1) | |
.then(value2 => { | |
// do something | |
return promise3(value1, value2) | |
}) | |
}) |
OlderNewer