Iterator and reactor functions for JavaScript
River provides a unified functional interface for iterators and reactors (asynchronous iterators). Every function is curried and automatically dispatches to the most efficient implementation based on the input type.
import { pipe } from "@dashkite/joy/function"
import {
collect
map
resolve
} from "@dashkite/river"
json = ( response ) -> response.json()
get = pipe [
map fetch
resolve
map json
resolve
collect
]
values = await get [ "https://httpbin.org/json" ]- Uses lazy evaluation whenever possible
- Dispatches to the optimized implementation based on the arguments
- Provides a functional interface for a superset of the JavaScript iterator helpers
- Preserves this binding within combinators allowing use within methods