Skip to main content

Built and signed on GitHub Actions

🏷️ Collection of TypeScript types.

This package works with Cloudflare Workers, Node.js, Deno, Bun, Browsers
This package works with Cloudflare Workers
This package works with Node.js
This package works with Deno
This package works with Bun
This package works with Browsers
JSR Score
100%
Published
3 weeks ago (0.3.3)
type alias Awaitable

A value that might be coming from a Promise or might not, but can be awaited. This type is specially useful when a code is "isomorphic asynchronous", meaning it will handle both the asynchronous and synchronous version of the same type.

Examples

Example 1

const promisedValue = Promise.resolve("🧙‍♀️") satisfies Awaitable<string>;
const plainValue = "🔮" satisfies Awaitable<string>;

Promise.all([promisedValue, plainValue]).then(console.log); // ["🧙‍♀️", "🔮"]

Type Parameters

Type = unknown

The type to await.

Definition

Readonly<PromiseLike<Type> | Type>

See

Add Package

deno add jsr:@coven/types

Import symbol

import { type Awaitable } from "@coven/types";

---- OR ----

Import directly with a jsr specifier

import { type Awaitable } from "jsr:@coven/types";

Add Package

npx jsr add @coven/types

Import symbol

import { type Awaitable } from "@coven/types";

Add Package

yarn dlx jsr add @coven/types

Import symbol

import { type Awaitable } from "@coven/types";

Add Package

pnpm dlx jsr add @coven/types

Import symbol

import { type Awaitable } from "@coven/types";

Add Package

bunx jsr add @coven/types

Import symbol

import { type Awaitable } from "@coven/types";