Skip to content

Commit

Permalink
feat: add fx (#251)
Browse files Browse the repository at this point in the history
* feat: add `fx`

* docs: add `fx`

* docs: update README
  • Loading branch information
ppeeou authored Mar 14, 2024
1 parent e061098 commit 53d495c
Show file tree
Hide file tree
Showing 30 changed files with 1,156 additions and 19 deletions.
13 changes: 10 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ Please review the [API documentation](https://fxts.dev/docs/index)
## Usage

```ts
import { each, filter, map, pipe, range, take } from "@fxts/core";
import { each, filter, fx, map, pipe, range, take } from "@fxts/core";

pipe(
range(10),
Expand All @@ -34,18 +34,25 @@ pipe(
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, map, pipe, toAsync } from "@fxts/core";
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 = 1) =>
const countWords = async (concurrency: number) =>
pipe(
["html", "css", "javascript", "typescript"],
toAsync,
Expand Down
Loading

0 comments on commit 53d495c

Please sign in to comment.