Skip to main content
Deno 2 is finally here 🎉️
Learn more
Module

x/ayonli_jsext/json/index.ts>as

A JavaScript extension package for building strong and modern applications.
Latest
function as
import { as } from "https://deno.land/x/ayonli_jsext@v0.9.72/json/index.ts";

Converts the data into the given type.

This function is primarily used in parseAs and shares the same conversion rules, but it can be used in other scenarios too, for example, inside the fromJSON function.

Parameters

data: unknown
type: StringConstructor

Returns

string | null

Parameters

data: unknown
type: NumberConstructor

Returns

number | null

Parameters

data: unknown
type: BigIntConstructor

Returns

bigint | null

Parameters

data: unknown
type: BooleanConstructor

Returns

boolean | null

Parameters

data: unknown
type: Constructor<T> & { fromJSON?(data: any): T; }

Returns

T | null