clojure-thread-js-async
Clojure threading macro. Supports first
, last
, and as
macro. No
support for binding.
Usage
const thread = require('clojure-thread-async')
await thread.first(
1,
x => x * 10,
[(x, y) => x - y, 1]
)
await thread.last(
1,
x => x * 10,
[(x, y) => x - y, 1]
)
await thread.as(
1,
placeholder => [
x => x * 10,
[(x, y) => x - y, placeholder, 1],
[(x, y) => x - y, 1, placeholder]
]
)
const reducer = (state = 0, action) => {
switch(action.type) {
case "INC":
return state + 1
default:
return state
}
}
const state = thread.first(
reducer(undefined, {}),
[reducer, {type: "INC"}],
)
console.log(state == 1)