@justinmchase/type@0.2.4Built and signed on GitHub ActionsBuilt and signed on GitHub Actions
Built and signed on GitHub Actions
latest
justinmchase/typeSimple Type checking and assertions for javascript primitive types.
This package works with Cloudflare Workers, Node.js, Deno, Bun, Browsers
JSR Score
100%
Published
2 months ago (0.2.4)
type
Simple type inference for javascript runtimes
Usage
import { Type, type } from "https://deno.land/x/type/mod.ts"; const value: unknown = BigInt(100); const [t, v] = type(value); // [Type.BigInt, bigint]
Additionally, each type has an is{Type}
, assert{Type}
, and
assert{Type}Type
helper function available.
import { type } from "https://deno.land/x/type/mod.ts"; import { assertBigInt, assertBigIntType, isBigInt, } from "https://deno.land/x/type/src/bigint.ts"; const [t, v] = type(BigInt(100)); isBigInt(v); // true assertBigInt(v); // void assertBigIntType(t); // void
Type Map
value | type | as |
---|---|---|
[] |
Type.Array |
unknown[] |
BigInt(100) |
Type.BigInt |
bigint |
true|false |
Type.Boolean |
boolean |
new Error() |
Type.Error |
Error |
() => {} |
Type.Function |
Function |
null |
Type.Null |
null |
1.23 |
Type.Number |
number |
{} |
Type.Object |
Record<string, unknown> |
"" |
Type.String |
string |
Symbol() |
Type.Symbol |
symbol |
undefined |
Type.Undefined |
undefined |
Built and signed on
View transparency logGitHub Actions
Add Package
deno add jsr:@justinmchase/type
Import symbol
import * as type from "@justinmchase/type";
---- OR ----
Import directly with a jsr specifier
import * as type from "jsr:@justinmchase/type";
Add Package
npx jsr add @justinmchase/type
Import symbol
import * as type from "@justinmchase/type";
Add Package
yarn dlx jsr add @justinmchase/type
Import symbol
import * as type from "@justinmchase/type";
Add Package
pnpm dlx jsr add @justinmchase/type
Import symbol
import * as type from "@justinmchase/type";
Add Package
bunx jsr add @justinmchase/type
Import symbol
import * as type from "@justinmchase/type";