From 428ad88d7d987b9dbfdc5771b80103886d16e135 Mon Sep 17 00:00:00 2001 From: alex Date: Wed, 19 Aug 2020 11:18:53 +0300 Subject: [PATCH] is.array checks if assertion is a function --- source/index.ts | 2 +- test/test.ts | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/source/index.ts b/source/index.ts index 9bed5cc..7e68ccb 100644 --- a/source/index.ts +++ b/source/index.ts @@ -170,7 +170,7 @@ is.array = (value: unknown, assertion?: (value: T) => value is T): return false; } - if (!assertion) { + if (!is.function_(assertion)) { return true; } diff --git a/test/test.ts b/test/test.ts index 16e376c..c5c98cd 100644 --- a/test/test.ts +++ b/test/test.ts @@ -1537,6 +1537,8 @@ test('is.all', t => { t.false(is.all(is.string, '🦄', [])); t.false(is.all(is.set, new Map(), {})); + t.true(is.all(is.array, ...[['1'], ['2']])); + t.throws(() => { is.all(null as any, true); });