πŸ“„ File detail

utils/withResolvers.ts

🧩 .tsπŸ“ 14 linesπŸ’Ύ 444 bytesπŸ“ text
← Back to All Files

🎯 Use case

This file lives under β€œutils/”, which covers cross-cutting helpers (shell, tempfiles, settings, messages, process input, …). On the API surface it exposes withResolvers β€” mainly functions, hooks, or classes. What the file header says: Polyfill for Promise.withResolvers() (ES2024, Node 22+). package.json declares "engines": { "node": ">=18.0.0" } so we can't use the native one.

Generated from folder role, exports, dependency roots, and inline comments β€” not hand-reviewed for every path.

🧠 Inline summary

Polyfill for Promise.withResolvers() (ES2024, Node 22+). package.json declares "engines": { "node": ">=18.0.0" } so we can't use the native one.

πŸ“€ Exports (heuristic)

  • withResolvers

πŸ–₯️ Source preview

/**
 * Polyfill for Promise.withResolvers() (ES2024, Node 22+).
 * package.json declares "engines": { "node": ">=18.0.0" } so we can't use the native one.
 */
export function withResolvers<T>(): PromiseWithResolvers<T> {
  let resolve!: (value: T | PromiseLike<T>) => void
  let reject!: (reason?: unknown) => void
  const promise = new Promise<T>((res, rej) => {
    resolve = res
    reject = rej
  })
  return { promise, resolve, reject }
}