💬 Join the FxTS Slack community(en) 💬 Join the FxTS Slack community(ko)
FxTS is a functional library for TypeScript/JavaScript programmers.
- Lazy evaluation
- Handling concurrent requests
- Type inference
- Follow iteration protocal Iterable / AsyncIterable
npm install @fxts/core
Please review the API documentation
import { pipe, range, map, filter, take, each } from "@fxts/core";
pipe(
range(10),
map((a) => a + 10),
filter((a) => a % 2 === 0),
take(2),
each((a) => console.log(a)),
);
import { pipe, toAsync, map, flat, concurrent, countBy } from "@fxts/core";
// maybe 1 seconds api
const fetchWiki = (page: string) =>
fetch(`https://en.wikipedia.org/w/api.php?action=parse&page=${page}`);
const countWords = async (concurrency = 1) =>
pipe(
["html", "css", "javascript", "typescript"],
toAsync,
map(fetchWiki),
map((res) => res.text()),
map((words) => words.split(" ")),
flat,
concurrent(concurrency),
countBy((word) => word),
);
await countWords(); // 4 seconds
await countWords(2); // 2 seconds
you can also handle asynchronous data, see the example
npm run build
npm test
npm run compile:check
Apache License 2.0