Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
function ready(payload) {
const fns = []
let lastReturnValue = payload;
function steady(fn) {
fns.push(fn)
return {
steady, go
}
}
function go() {
fns.forEach(fn =>(lastReturnValue = fn(lastReturnValue)))
return lastReturnValue
}
return {
steady
}
}
console.log(
ready('Hello, I am ready steady go')
.steady(text => Array.from(text))
.steady(arr => arr.reverse())
.steady(arr => arr.map(c => c.toUpperCase()))
.steady(arr => arr.join(' '))
.go()
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.