Skip to main content

Benji's personal standard library. Collection of tools for manipulating strings, async iterables, shell scripting, and common data structures.

This package works with Deno, BrowsersIt is unknown whether this package works with Cloudflare Workers, Node.js, Bun
It is unknown whether this package works with Cloudflare Workers
It is unknown whether this package works with Node.js
This package works with Deno
It is unknown whether this package works with Bun
This package works with Browsers
JSR Score
76%
Published
3 weeks ago (1.5.1)
function pinkyPromise
pinkyPromise(): [
Promise<void>,
() => void,
(reason?: unknown) => void,
]

A "destructured" Promise, useful for waiting for callbacks.

Examples

Example 1

// When awaited, this function returns a promise that resolves to // an OPEN WebSocket () => { const sock = new WebSocket('wss://wss.example.com') const [p, res, rej] = pinkyPromise() sock.onerror = err => rej(err) sock.onopen = () => res(sock) return p }

Return Type

[
Promise<void>,
() => void,
(reason?: unknown) => void,
]
pinkyPromise<T>(): [
Promise<T>,
(value: T) => void,
(reason?: unknown) => void,
]

Type Parameters

Return Type

[
(value: T) => void,
(reason?: unknown) => void,
]

Add Package

deno add @mindfulminun/pear

Import symbol

import { pinkyPromise } from "@mindfulminun/pear/core/async";

Add Package

npx jsr add @mindfulminun/pear

Import symbol

import { pinkyPromise } from "@mindfulminun/pear/core/async";

Add Package

yarn dlx jsr add @mindfulminun/pear

Import symbol

import { pinkyPromise } from "@mindfulminun/pear/core/async";

Add Package

pnpm dlx jsr add @mindfulminun/pear

Import symbol

import { pinkyPromise } from "@mindfulminun/pear/core/async";

Add Package

bunx jsr add @mindfulminun/pear

Import symbol

import { pinkyPromise } from "@mindfulminun/pear/core/async";