1+ /**
2+ * A type decision function
3+ */
14export type Predicate < T > = ( x : unknown ) => x is T ;
25
36/**
4- * Return true if the value is string
7+ * Return ` true` if the type of `x` is ` string`.
58 */
69export function isString ( x : unknown ) : x is string {
710 return typeof x === "string" ;
811}
912
1013/**
11- * Return true if the value is number
14+ * Return ` true` if the type of `x` is ` number`.
1215 */
1316export function isNumber ( x : unknown ) : x is number {
1417 return typeof x === "number" ;
1518}
1619
1720/**
18- * Return true if the value is boolean
21+ * Return ` true` if the type of `x` is ` boolean`.
1922 */
2023export function isBoolean ( x : unknown ) : x is boolean {
2124 return typeof x === "boolean" ;
2225}
2326
2427/**
25- * Return true if the value is array
28+ * Return `true` if the type of `x` is `array`.
29+ *
30+ * Use `pred` to predicate the type of items.
2631 */
2732export function isArray < T extends unknown > (
2833 x : unknown ,
@@ -32,7 +37,9 @@ export function isArray<T extends unknown>(
3237}
3338
3439/**
35- * Return true if the value is object
40+ * Return `true` if the type of `x` is `object`.
41+ *
42+ * Use `pred` to predicate the type of values.
3643 */
3744export function isObject < T extends unknown > (
3845 x : unknown ,
@@ -47,35 +54,35 @@ export function isObject<T extends unknown>(
4754}
4855
4956/**
50- * Return true if the value is function
57+ * Return ` true` if the type of `x` is ` function`.
5158 */
5259export function isFunction ( x : unknown ) : x is ( ...args : unknown [ ] ) => unknown {
5360 return Object . prototype . toString . call ( x ) === "[object Function]" ;
5461}
5562
5663/**
57- * Return true if the value is null
64+ * Return ` true` if the type of `x` is ` null`.
5865 */
5966export function isNull ( x : unknown ) : x is null {
6067 return x === null ;
6168}
6269
6370/**
64- * Return true if the value is undefined
71+ * Return ` true` if the type of `x` is ` undefined`.
6572 */
6673export function isUndefined ( x : unknown ) : x is undefined {
6774 return typeof x === "undefined" ;
6875}
6976
7077/**
71- * Return true if the value is null or undefined
78+ * Return ` true` if the type of `x` is ` null` or ` undefined`.
7279 */
7380export function isNullish ( x : unknown ) : x is null | undefined {
7481 return x == null ;
7582}
7683
7784/**
78- * Return true if a type of value is like a type of reference .
85+ * Return ` true` if the type of `x` follows the type of `ref` .
7986 */
8087export function isLike < R , T extends unknown > (
8188 ref : R ,
0 commit comments