Skip to content

Commit 87452a1

Browse files
committed
feat(asyncAppendOnce): add asyncAppendOnce function
1 parent 7078bf2 commit 87452a1

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed

index.test.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import {
44
asyncAllOnce,
55
asyncAndOnce,
66
asyncAnyOnce,
7+
asyncAppendOnce,
78
asyncAverageOnce,
89
asyncConcatOnce,
910
asyncContainsOnce,
@@ -553,3 +554,20 @@ test("asyncPrependOnce", async t => {
553554
[1, 2, 3]
554555
);
555556
});
557+
558+
test("asyncAppendOnce", async t => {
559+
t.deepEqual(
560+
await asyncToArrayOnce(asyncAppendOnce(asyncIterator([4, 5, 6]))(asyncIterator([1, 2, 3]))),
561+
[1, 2, 3, 4, 5, 6]
562+
);
563+
t.deepEqual(
564+
await asyncToArrayOnce(
565+
asyncAppendOnce(asyncIterator<number>([]))(asyncIterator([1, 2, 3]))
566+
),
567+
[1, 2, 3]
568+
);
569+
t.deepEqual(
570+
await asyncToArrayOnce(asyncAppendOnce(asyncIterator([4, 5, 6]))(asyncIterator([]))),
571+
[4, 5, 6]
572+
);
573+
});

index.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1035,3 +1035,9 @@ export function asyncPrependOnce<T>(
10351035
): (b: AsyncIteratorLike<T>) => AsyncIterator<T> {
10361036
return b => asyncConcatOnce([a, b]);
10371037
}
1038+
1039+
export function asyncAppendOnce<T>(
1040+
b: AsyncIteratorLike<T>
1041+
): (a: AsyncIteratorLike<T>) => AsyncIterator<T> {
1042+
return a => asyncConcatOnce([a, b]);
1043+
}

0 commit comments

Comments
 (0)