Skip to content

Commit f61b9c6

Browse files
committed
feat(notEmpty): add notEmpty function
1 parent 66c99e5 commit f61b9c6

File tree

2 files changed

+24
-1
lines changed

2 files changed

+24
-1
lines changed

index.test.ts

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,16 @@
11
import test from "ava";
2-
import {asyncIterable, empty, initial, last, only, push, tail, toArray, unshift} from "./index";
2+
import {
3+
asyncIterable,
4+
empty,
5+
initial,
6+
last,
7+
notEmpty,
8+
only,
9+
push,
10+
tail,
11+
toArray,
12+
unshift
13+
} from "./index";
314

415
test("tail", async t => {
516
t.deepEqual(await toArray(tail(asyncIterable([1, 2, 3, 4]))), [2, 3, 4]);
@@ -39,3 +50,9 @@ test("empty", async t => {
3950
t.is(await empty(asyncIterable([1])), false);
4051
t.is(await empty(asyncIterable([1, 2, 3])), false);
4152
});
53+
54+
test("notEmpty", async t => {
55+
t.is(await notEmpty(asyncIterable([])), false);
56+
t.is(await notEmpty(asyncIterable([1])), true);
57+
t.is(await notEmpty(asyncIterable([1, 2, 3])), true);
58+
});

index.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,3 +125,9 @@ export async function empty(iterable: AsyncIterableLike<unknown>): Promise<boole
125125
}
126126

127127
export const asyncEmpty = empty;
128+
129+
export async function notEmpty(iterable: AsyncIterableLike<unknown>): Promise<boolean> {
130+
return !(await empty(iterable));
131+
}
132+
133+
export const asyncNotEmpty = notEmpty;

0 commit comments

Comments
 (0)