toNumber

A helpful utility to reactively convert a string readable/writable to number.

Demo

Result: 1

Usage

<script lang="ts">
import { toNumber } from "svelte-legos";
import { writable } from "svelte/store";

const str = writable("1.0");
const number = toNumber(str);

// use $number as Number
</script>