-
-
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
e2c01c0
commit d8e5e77
Showing
12 changed files
with
178 additions
and
15 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,6 @@ | ||
{ | ||
"clamp": "clamp", | ||
"isNegZero": "isNegZero", | ||
"isZero": "isZero", | ||
"toNum": "toNum" | ||
} |
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 @@ | ||
import REPL from "../../components/REPL"; | ||
|
||
> Returns a value clamped to the inclusive range of min and max. | ||
## Syntax | ||
|
||
```ts | ||
import { clamp } from '@opentf/utils'; | ||
|
||
clamp(val: number, min: number, max: number): number; | ||
``` | ||
|
||
## Examples | ||
|
||
```ts | ||
clamp(10, -5, 5) //=> 5 | ||
|
||
clamp(0, 1000, 1366) //=> 1000 | ||
|
||
clamp(1001, 1000, 1366) //=> 1001 | ||
|
||
clamp(1500, 1000, 1366) //=> 1366 | ||
``` | ||
|
||
## Try | ||
|
||
<REPL code={`const { clamp } = require('@opentf/utils'); | ||
clamp(0, 1000, 1366); | ||
`} /> |
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,36 @@ | ||
import { Callout } from "nextra/components"; | ||
import REPL from "../../components/REPL"; | ||
|
||
> Checks if the given number is negative zero (-0). | ||
<Callout type="info"> | ||
In JavaScript 0 === -0 is true. | ||
</Callout> | ||
|
||
## Syntax | ||
|
||
```ts | ||
import { isNegZero } from '@opentf/utils'; | ||
|
||
isNegZero(n: number): boolean; | ||
``` | ||
|
||
## Examples | ||
|
||
```ts | ||
isNegZero(0) //=> false | ||
|
||
isNegZero(-0) //=> true | ||
|
||
isNegZero(-0.0) //=> true | ||
|
||
isNegZero(-0x0) //=> true | ||
``` | ||
|
||
## Try | ||
|
||
<REPL code={`const { isNegZero } = require('@opentf/utils'); | ||
log(isNegZero(0)); | ||
isNegZero(-0); | ||
`} /> |
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,40 @@ | ||
import { Callout } from "nextra/components"; | ||
import REPL from "../../components/REPL"; | ||
|
||
> Checks if the given number is positive zero (0). | ||
<Callout type="info"> | ||
In JavaScript 0 === -0 is true. | ||
</Callout> | ||
|
||
## Syntax | ||
|
||
```ts | ||
import { isZero } from '@opentf/utils'; | ||
|
||
isZero(n: number): boolean; | ||
``` | ||
|
||
## Examples | ||
|
||
```ts | ||
isZero(0) //=> true | ||
|
||
isZero(0.0) //=> true | ||
|
||
isZero(0x0) //=> true | ||
|
||
isZero(-0) //=> false | ||
|
||
isZero(-0.0) //=> false | ||
|
||
isZero(-0x0) //=> false | ||
``` | ||
|
||
## Try | ||
|
||
<REPL code={`const { isZero } = require('@opentf/utils'); | ||
log(isZero(0)); | ||
isZero(-0); | ||
`} /> |
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,35 @@ | ||
import { Callout } from "nextra/components"; | ||
import REPL from "../../components/REPL"; | ||
|
||
> Try to convert the given value into a finite number. | ||
## Syntax | ||
|
||
```ts | ||
import { toNum } from '@opentf/utils'; | ||
|
||
toNum(val: unknown): number; | ||
``` | ||
|
||
## Examples | ||
|
||
```ts | ||
toNum(1) //=> 1 | ||
|
||
toNum('1.3') //=> 1.3 | ||
|
||
toNum('1_000') //=> 1000 | ||
|
||
toNum(Infinity) //=> NaN | ||
|
||
toNum('a') //=> NaN | ||
|
||
toNum('0xF') //=> 15 | ||
``` | ||
|
||
## Try | ||
|
||
<REPL code={`const { toNum } = require('@opentf/utils'); | ||
toNum('1_000'); | ||
`} /> |
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
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
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