@thi.ng/transducers-async
Version:
Async versions of various highly composable transducers, reducers and iterators
16 lines (15 loc) • 346 B
JavaScript
import { reducer } from "./reduce.js";
function str(sep = "", src) {
let first = true;
return src ? (async () => {
let res = [];
for await (let x of src) res.push(String(x));
return res.join(sep);
})() : reducer(
() => "",
(acc, x) => (acc = first ? acc + x : acc + sep + x, first = false, acc)
);
}
export {
str
};