Skip to main content
The Deno 2 Release Candidate is here
Learn more
Latest
function primitiveParse
import { primitiveParse } from "https://deno.land/x/simple_utility@v2.3.2/mod.pure.full.ts";

Convert from dirty text to specified type. Enabling strict flag will throw exception if parsing failed.

Examples

Example 1

const value = primitiveParse("123", "number", true);

Type Parameters

T extends keyof PrimitiveTypeMap
U extends boolean

Parameters

text: MaybeString
type: T
optional
strict: U

Returns

TypeStrict<PrimitiveTypeMap[T], U>