To Number
Reactive async state.
Usage
<script>
import {toNumber} from "@sveu/shared"
</script>
{toNumber("1.5", {method: "int"})}
<hr/>
{toNumber("edc", {nanToZero: true})}
<script>
import {toNumber} from "@sveu/shared"
</script>
{toNumber("1.5", {method: "int"})}
<hr/>
{toNumber("edc", {nanToZero: true})}
svelte
Example
1
0
0
<script>
import { toNumber } from "@sveu/shared"
</script>
{toNumber("1.5", { method: "int" })}
<hr />
{toNumber("edc", { nanToZero: true })}
<script>
import { toNumber } from "@sveu/shared"
</script>
{toNumber("1.5", { method: "int" })}
<hr />
{toNumber("edc", { nanToZero: true })}
svelte
1
2
3
4
5
6
7
Click fold/expand code
API
Arguments
Name | Description | Type | Required |
---|---|---|---|
value | The value to be converted | `string | number` |
Options
Name | Description | Type | Default |
---|---|---|---|
method | The method to be used to convert | int or float | float |
nanToZero | Convert NaN to zero | boolean | False |
radix | The base in mathematical numeral systems passed to parseInt. | number | undefined |