Skip to content

Commit

Permalink
README upd.
Browse files Browse the repository at this point in the history
  • Loading branch information
Smoren committed Dec 23, 2024
1 parent ad7d853 commit 97238af
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 5 deletions.
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ const pipe = createPipe(
const result1 = pipe([1, 1, 2, 2, 3, 4, 5]); // 14
const result2 = pipe([1, 1, 1, 2, 2, 2]); // 5

// Async example
const asyncPipe = createPipe(
set.distinctAsync<number>,
(input) => single.mapAsync(input, (x) => x**2),
Expand All @@ -81,6 +82,16 @@ const asyncPipe = createPipe(
);
const result3 = await asyncPipe([1, 1, 2, 2, 3, 4, 5].map((x) => Promise.resolve(x))); // 14
const result4 = await asyncPipe([1, 1, 1, 2, 2, 2].map((x) => Promise.resolve(x))); // 5

// Another way to create pipes
const anotherPipe = createPipe()
.add(set.distinct<number>)
.add((input) => single.map(input, (x) => x**2))
.add((input) => single.filter(input, (x) => x < 10))
.add(reduce.toSum);

const result5 = anotherPipe([1, 1, 2, 2, 3, 4, 5]); // 14
const result6 = anotherPipe([1, 1, 1, 2, 2, 2]); // 5
```

[More about Pipes](#Pipes)
Expand Down
10 changes: 5 additions & 5 deletions tests/examples/pipe.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,9 @@ it("Pipe Usage Example Test", () => {
}
});

it("Chained Pipe Usage Example Test", () => {
const pipe = createPipe(set.distinct<number>)
it("Chain Pipe Usage Example Test", () => {
const pipe = createPipe()
.add(set.distinct<number>)
.add((input) => single.map(input, (x) => x**2))
.add((input) => single.filter(input, (x) => x < 10))
.add(reduce.toSum);
Expand All @@ -64,9 +65,8 @@ it("Chained Pipe Usage Example Test", () => {
}
});

it("Another Chain Pipe Usage Example Test", () => {
const pipe = createPipe()
.add(set.distinct<number>)
it("Another Chained Pipe Usage Example Test", () => {
const pipe = createPipe(set.distinct<number>)
.add((input) => single.map(input, (x) => x**2))
.add((input) => single.filter(input, (x) => x < 10))
.add(reduce.toSum);
Expand Down

0 comments on commit 97238af

Please sign in to comment.