generated from finsweet/developer-starter
-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
da7fa9c
commit 0024923
Showing
3 changed files
with
25 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'@finsweet/ts-utils': minor | ||
--- | ||
|
||
Added primitive type guards |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
export { isFormField } from './isFormField'; | ||
export { isKeyOf } from './isKeyOf'; | ||
export { isNotEmpty } from './isNotEmpty'; | ||
export * from './primitives'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
/* eslint-disable @typescript-eslint/no-explicit-any */ | ||
/* eslint-disable @typescript-eslint/ban-types */ | ||
export const isString = (value: unknown): value is string => typeof value === 'string'; | ||
|
||
export const isNumber = (value: unknown): value is number => typeof value === 'number'; | ||
|
||
export const isBigint = (value: unknown): value is bigint => typeof value === 'bigint'; | ||
|
||
export const isBoolean = (value: unknown): value is boolean => typeof value === 'boolean'; | ||
|
||
export const isSymbol = (value: unknown): value is symbol => typeof value === 'symbol'; | ||
|
||
export const isUndefined = (value: unknown): value is undefined => value === undefined; | ||
|
||
export const isNull = (value: unknown): value is null => value === null; | ||
|
||
export const isFunction = (value: unknown): value is Function => typeof value === 'function'; | ||
|
||
export const isObject = (value: unknown): value is Record<any, any> => value !== null && typeof value === 'object'; |