toPromise.ts overview


Exports Grouped by Category


adapters

toPromise

Transform a Result into a Promise, which rejects with the error.

Example

import assert from "node:assert"
import { sma, toPromise } from "@ldrick/trade-indicators"

assert.deepStrictEqual(await toPromise(sma([1, 2, 3], 2)), [null, 1.5, 2.5])
await assert.rejects(toPromise(sma([1], 2)), { name: "NotEnoughDataError" })

Signature

declare const toPromise: <A, E extends Error>(result: Result<A, E>) => Promise<A>

Source

Since v0.4.0


This site uses Just the Docs, a documentation theme for Jekyll.