@quentinadam/ensure@0.1.0Built and signed on GitHub ActionsBuilt and signed on GitHub Actions
Built and signed on GitHub Actions
latest
quentinadam/deno-ensureA simple function that asserts that a value is not undefined or null and returns the narrowed value
This package works with Cloudflare Workers, Node.js, Deno, Bun, Browsers




JSR Score
100%
Published
2 months ago (0.1.0)
@quentinadam/ensure
A simple function that asserts that a value is not undefined or null and returns the narrowed value.
Usage
import ensure from '@quentinadam/ensure'; const a = ensure(1); // doesn't throw const b = ensure(undefined); // throws an AssertionError ensure(undefined, 'message'); // throws an AssertionError with a custom error message ensure(undefined, new Error('message')); // throws a custom Error const value: string | undefined = 'hello'; const narrowedValue = ensure(value); // narrows the type of value to string; value.toUpperCase(); // works
Built and signed on
GitHub Actions
Add Package
deno add jsr:@quentinadam/ensure
Import symbol
import * as ensure from "@quentinadam/ensure";
Import directly with a jsr specifier
import * as ensure from "jsr:@quentinadam/ensure";
Add Package
pnpm i jsr:@quentinadam/ensure
pnpm dlx jsr add @quentinadam/ensure
Import symbol
import * as ensure from "@quentinadam/ensure";
Add Package
yarn add jsr:@quentinadam/ensure
yarn dlx jsr add @quentinadam/ensure
Import symbol
import * as ensure from "@quentinadam/ensure";
Add Package
vlt install jsr:@quentinadam/ensure
Import symbol
import * as ensure from "@quentinadam/ensure";
Add Package
npx jsr add @quentinadam/ensure
Import symbol
import * as ensure from "@quentinadam/ensure";
Add Package
bunx jsr add @quentinadam/ensure
Import symbol
import * as ensure from "@quentinadam/ensure";