Options
All
  • Public
  • Public/Protected
  • All
Menu

Helper class for creating a Promise that is paired with an error-and-value callback.

    const pvc1 = new PromiseAndErrorValueCallback<string>();
pvc1.callback(null, "a");
const result = await pvc1.promise; // returns "a"

const pvc2 = new PromiseAndErrorValueCallback<string>();
pvc2.callback(new Error("sorry"));
await pvc2.promise; // throws error

Type parameters

  • T

Hierarchy

  • PromiseAndErrorValueCallback

Index

Constructors

Properties

Constructors

Properties

callback: (err: any, value: T) => void

Type declaration

    • (err: any, value: T): void
    • A callback function that takes an error value and/or a result value; when it is called, promise is resolved or rejected.

      Parameters

      • err: any
      • value: T

      Returns void

promise: Promise<T>

A Promise that will be resolved when callback is called without an error, or rejected if callback is called with an error.

Generated using TypeDoc