feat: is.not

This commit is contained in:
EnixCoda 2022-06-03 21:44:17 +08:00
parent 5c65f9e7f5
commit c558eaf35c

View file

@ -2,6 +2,14 @@ export const is = {
boolean: (d: unknown): d is boolean => typeof d === 'boolean',
number: (d: unknown): d is number => typeof d === 'number',
string: (d: unknown): d is string => typeof d === 'string',
not: {
undefined: <T>(d: T | undefined): d is T => d !== undefined,
null: <T>(d: T | null): d is T => d !== null,
true: <T>(d: T | true): d is T => d !== true,
false: <T>(d: T | false): d is T => d !== false,
number: <T>(d: T | number): d is T => typeof d !== 'number',
string: <T>(d: T | string): d is T => typeof d !== 'string',
},
JSON: {
object(d: unknown): d is JSONObject {
return (typeof d === 'object' && d && !Array.isArray(d)) || false