Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/marpple/FxTS
A functional programming library for TypeScript/JavaScript
https://github.com/marpple/FxTS
concurrency fp javascript lazy typescript
Last synced: 3 months ago
JSON representation
A functional programming library for TypeScript/JavaScript
- Host: GitHub
- URL: https://github.com/marpple/FxTS
- Owner: marpple
- License: apache-2.0
- Created: 2021-09-30T06:00:50.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2024-04-14T04:32:20.000Z (9 months ago)
- Last Synced: 2024-04-14T11:55:55.771Z (9 months ago)
- Topics: concurrency, fp, javascript, lazy, typescript
- Language: TypeScript
- Homepage: https://fxts.dev
- Size: 6.79 MB
- Stars: 716
- Watchers: 12
- Forks: 62
- Open Issues: 17
-
Metadata Files:
- Readme: README.md
- License: LICENSE
- Codeowners: .github/CODEOWNERS
Awesome Lists containing this project
- awesome-tiny-js - @fxts/core - 96 tree-shakable helpers. Lazy evaluation support. (Generic Utilities / Reactive Programming)
README
![Build Status](https://github.com/marpple/FxTS/actions/workflows/ci.yml/badge.svg)
[![npm version](https://badge.fury.io/js/@fxts%2Fcore.svg)](https://badge.fury.io/js/@fxts%2Fcore)# ![fxts-icon](https://github.com/marpple/FxTS/assets/10924072/415500c9-12ce-4aec-8563-835514b94b22) FxTS
FxTS is a functional library for TypeScript/JavaScript programmers.
### Why FxTS?
- Lazy evaluation
- Handling concurrent requests
- Type inference
- Follow [iteration protocols](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols) Iterable / AsyncIterable## Installation
```
npm install @fxts/core
```## Documentation
Please review the [API documentation](https://fxts.dev/docs/)
## Usage
```ts
import { each, filter, fx, map, pipe, range, take } from "@fxts/core";pipe(
range(10),
map((a) => a + 10),
filter((a) => a % 2 === 0),
take(2),
each((a) => console.log(a)),
);// chaining
fx(range(10))
.map((a) => a + 10)
.filter((a) => a % 2 === 0)
.take(2)
.each((a) => console.log(a));
```## Usage(concurrent)
```ts
import { concurrent, countBy, flat, fx, map, pipe, toAsync } 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: number) =>
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 start [here](http://fxts.dev/docs/getting-started)
## Build
- `npm run build`
## Running Test
- `npm test`
## Running Type Test
- `npm run compile:check`
## License
Apache License 2.0