Allow to bind data on a promise chain.
storeChain(fetch("http://ipinfo.io/json"))
.set("ipInfo")
.then(() => fs.openFileAsync("./path/to/data.json"))
.then(JSON.parse)
.set("data")
.get(({ ipInfo, data }) => Object.assign(data, { ipInfo }))
.then(JSON.stringify)
.then(result => fs.writeFile("./path/to/new-data.json", result))
.get(({ ipInfo }) => {
console.log(ipInfo)
console.log("save successfull.")
});
storeChain.all({
ipInfo: fetch("http://ipinfo.io/json"),
data: fs.openFileAsync("./path/to/data.json")
.then(JSON.parse)
})
.then({ ipInfo, data } => Object.assign(data, { ipInfo }))
.then(JSON.stringify)
.then(result => fs.writeFile("./path/to/new-data.json", result))
storeChain({
ipInfo: fetch("http://ipinfo.io/json"),
data: fs.openFileAsync("./path/to/data.json")
.then(JSON.parse)
})
.then({ ipInfo, data } => Object.assign(data, { ipInfo }))
.then(JSON.stringify)
.then(result => fs.writeFile("./path/to/new-data.json", result))
.get(({ ipInfo }) => {
console.log(ipInfo)
console.log("save successfull.")
})