diff --git a/readme.md b/readme.md index ecd9028..6d54d46 100644 --- a/readme.md +++ b/readme.md @@ -471,6 +471,10 @@ is.urlSearchParams(searchParams); //=> true ``` +#### .fortyTwo(value) + +Return `true` if `value` is `42`. + ##### .any(predicate | predicate[], ...values) Using a single `predicate` argument, returns `true` if **any** of the input `values` returns true in the `predicate`: diff --git a/source/index.ts b/source/index.ts index fcd66a0..00b9792 100644 --- a/source/index.ts +++ b/source/index.ts @@ -368,6 +368,8 @@ is.formData = (value: unknown): value is FormData => isObjectOfType('F is.urlSearchParams = (value: unknown): value is URLSearchParams => isObjectOfType('URLSearchParams')(value); +is.fortyTwo = (value: unknown): value is 42 => value === 42; + export type Predicate = (value: unknown) => boolean; type ArrayMethod = (fn: (value: unknown, index: number, array: unknown[]) => boolean, thisArg?: unknown) => boolean; diff --git a/test/test.ts b/test/test.ts index 734fd27..0998f10 100644 --- a/test/test.ts +++ b/test/test.ts @@ -1507,6 +1507,11 @@ test('is.nonEmptyMap', t => { }); }); +test('is.fortyTwo', t => { + t.true(is.fortyTwo(42)); + t.false(is.fortyTwo(43)); +}); + test('is.propertyKey', t => { t.true(is.propertyKey('key')); t.true(is.propertyKey(42));