Skip to content

Commit 0f71ae5

Browse files
committed
feat(append): add append function
1 parent e73d9a7 commit 0f71ae5

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

index.test.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import {
33
all,
44
and,
55
any,
6+
append,
67
asyncIterable,
78
average,
89
concat,
@@ -327,3 +328,15 @@ test("prepend", async t => {
327328
);
328329
t.deepEqual(await toArray(prepend(asyncIterable([1, 2, 3]))(asyncIterable([]))), [1, 2, 3]);
329330
});
331+
332+
test("append", async t => {
333+
t.deepEqual(
334+
await toArray(append(asyncIterable([4, 5, 6]))(asyncIterable([1, 2, 3]))),
335+
[1, 2, 3, 4, 5, 6]
336+
);
337+
t.deepEqual(
338+
await toArray(append(asyncIterable<number>([]))(asyncIterable([1, 2, 3]))),
339+
[1, 2, 3]
340+
);
341+
t.deepEqual(await toArray(append(asyncIterable([4, 5, 6]))(asyncIterable([]))), [4, 5, 6]);
342+
});

index.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -898,3 +898,9 @@ export function prepend<T>(a: AsyncIterableLike<T>): (b: AsyncIterableLike<T>) =
898898
}
899899

900900
export const asyncPrepend = prepend;
901+
902+
export function append<T>(b: AsyncIterableLike<T>): (a: AsyncIterableLike<T>) => AsyncIterable<T> {
903+
return a => concat([a, b]);
904+
}
905+
906+
export const asyncAppend = append;

0 commit comments

Comments
 (0)