-
Notifications
You must be signed in to change notification settings - Fork 175
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add isKeyOf function for checking if a value is a key of an object
- Loading branch information
Showing
7 changed files
with
57 additions
and
2 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
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
Large diffs are not rendered by default.
Oops, something went wrong.
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,21 @@ | ||
--- | ||
title: isKeyOf | ||
description: 'Checks if the given value is a key of the given object. It is useful for narrowing down the type of a value.' | ||
group: Typed | ||
--- | ||
|
||
## Basic usage | ||
|
||
Pass the object and the value to check. It will return a boolean indicating if the value is a key of the object. | ||
|
||
```ts | ||
import { isKeyOf } from 'radash' | ||
|
||
const obj = { | ||
a: 1, | ||
b: 2, | ||
c: 3, | ||
} | ||
isKeyOf(obj, 'a') // true | ||
isKeyOf(obj, 'd') // false | ||
``` |
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 |
---|---|---|
|
@@ -93,6 +93,7 @@ export { | |
isFloat, | ||
isFunction, | ||
isInt, | ||
isKeyOf, | ||
isNonNullish, | ||
isNullish, | ||
isNumber, | ||
|
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
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