-
-
Notifications
You must be signed in to change notification settings - Fork 0
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
0bf929e
commit 10e6e57
Showing
5 changed files
with
111 additions
and
3 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<!-- Do not edit this file. It is automatically generated by API Documenter. --> | ||
|
||
|
||
|
||
## isNaN variable | ||
|
||
> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. | ||
> | ||
Whatever argument is `NaN` or not. | ||
|
||
<b>Signature:</b> | ||
|
||
```typescript | ||
isNaN: (val: unknown) => val is number | ||
``` | ||
|
||
## Remarks | ||
|
||
`NaN` is primitive `number`<!-- -->. | ||
|
||
## Example | ||
|
||
|
||
```ts | ||
isNaN(NaN) // true | ||
isNaN(100) // 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
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 @@ | ||
/** | ||
* Whatever argument is `NaN` or not. | ||
* | ||
* @param val - input any value | ||
* @returns The result of `Number.isNaN(val)` | ||
* | ||
* @remarks | ||
* `NaN` is primitive `number`. | ||
* | ||
* @example | ||
* ```ts | ||
* isNaN(NaN) // true | ||
* isNaN(100) // false | ||
* ``` | ||
* | ||
* @beta | ||
* | ||
*/ | ||
const isNaN = (val: unknown): val is typeof NaN => Number.isNaN(val) | ||
|
||
export { isNaN } |
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,50 @@ | ||
import { | ||
BIG1, | ||
DATE, | ||
EMPTY_ARRAY, | ||
EMPTY_OBJECT, | ||
EMPTY_STRING, | ||
MAP, | ||
ONE, | ||
SET, | ||
SYMBOL, | ||
VOID_FN, | ||
VOID_PROMISE, | ||
WEAK_MAP, | ||
WEAK_SET, | ||
ZERO | ||
} from '@test' | ||
|
||
import { isNaN } from '@/isNaN' | ||
describe('isNaN', () => { | ||
const table: [unknown, boolean][] = [ | ||
[NaN, true], | ||
[Infinity, false], | ||
[-Infinity, false], | ||
[null, false], | ||
[undefined, false], | ||
[ZERO, false], | ||
[ONE, false], | ||
[EMPTY_STRING, false], | ||
['test', false], | ||
[false, false], | ||
[true, false], | ||
[BIG1, false], | ||
[SYMBOL, false], | ||
[EMPTY_OBJECT, false], | ||
[{ nest: {} }, false], | ||
[EMPTY_ARRAY, false], | ||
[[[]], false], | ||
[MAP, false], | ||
[SET, false], | ||
[WEAK_MAP, false], | ||
[WEAK_SET, false], | ||
[VOID_FN, false], | ||
[VOID_PROMISE, false], | ||
[DATE, false] | ||
] | ||
|
||
it.each(table)('isNaN(%s) -> %s', (val, expected) => { | ||
expect(isNaN(val)).toEqual(expected) | ||
}) | ||
}) |