Skip to content

Commit ea620c4

Browse files
refactor(guardBoolean): add guard for primitive Boolean object
1 parent 09634bd commit ea620c4

1 file changed

Lines changed: 5 additions & 4 deletions

File tree

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
// Function.
22
import { isBoolean } from '../../is/lib/is-boolean.func';
33
// Type.
4+
import { AnyBoolean } from '../../type/any-boolean.type';
45
import { GuardBoolean } from '../type/guard-boolean.type';
56
import { ResultCallback } from '../../type/result-callback.type';
67
/**
7-
* Guard the `value` to be a `boolean`.
8+
* Guard the `value` to be any type of a boolean.
89
* @param value A `boolean` type `value` to guard.
9-
* @param callback Optional `ResultCallback` function to handle result before returns.
10-
* @returns A `boolean` indicating whether or not the `value` is a `boolean`.
10+
* @param callback An optional `ResultCallback` function to handle result before returns.
11+
* @returns A `boolean` indicating whether or not the `value` is a `boolean` or `Boolean`.
1112
*/
12-
export const guardBoolean: GuardBoolean = (value: boolean, callback?: ResultCallback): value is boolean =>
13+
export const guardBoolean: GuardBoolean = <B extends AnyBoolean>(value: B, callback?: ResultCallback): value is B =>
1314
isBoolean(value, callback);

0 commit comments

Comments
 (0)