UNPKG

@dialog-db/query

Version:

Datalog query engine inspired by Datomic

59 lines 2.9 kB
/** * Takes a `Promise` value and returns a task that suspends until the promise * is resolved and then returns the resolved value. If you pass a non-promise * value it will return it back immediately, however typescript inference may * get confused. * * @template U * @param {U} source * @returns {Task.Task<Awaited<U>>} */ export function wait<U>(source: U): Task.Task<Awaited<U>>; /** * @template Ok * @template {globalThis.Error} Fail * @template {Task.Suspend|Task.Join|Task.Throw<Fail>} Command * @param {Task.Task<Ok, Fail, Command>} task * @returns {Task.Task<Task.Result<Ok, Task.InferError<Command>>, never>} */ export function result<Ok, Fail extends globalThis.Error, Command extends Task.Suspend | Task.Join | Task.Throw<Fail>>(task: Task.Task<Ok, Fail, Command>): Task.Task<Task.Result<Ok, Task.InferError<Command>>, never>; /** * @template Ok * @template {globalThis.Error} Fail * @template {Task.Suspend|Task.Join|Task.Throw<Fail>} Command * @param {Task.Task<Ok, Fail, Command>} task * @returns {Task.Task<Task.Invocation<Ok, Task.InferError<Command>>>} */ export function fork<Ok, Fail extends globalThis.Error, Command extends Task.Suspend | Task.Join | Task.Throw<Fail>>(task: Task.Task<Ok, Fail, Command>): Task.Task<Task.Invocation<Ok, Task.InferError<Command>>>; /** * @returns {Task.Task<void>} */ export function suspend(): Task.Task<void>; export * from "./task/task.js"; export function sleep(duration: number): Task.Task<void>; export const ok: (<Ok extends unknown, Fail extends {}>(source: Task.Result<Ok, Fail>) => Task.Task<Ok & {}, Fail>) & { /** * Takes a `Promise` of the {@link Task.Result} value and returns a task that * return `ok` value of the successful result or throws the `error` of the * failed result. It suspends the task until the promise is resolved. * * @template {unknown} Ok * @template {unknown} Fail * @param {PromiseLike<Task.Result<Ok, Fail>>} source * @returns {Task.Task<Ok & {}, Fail & {}>} */ wait<Ok extends unknown, Fail extends unknown>(source: PromiseLike<Task.Result<Ok, Fail>>): Task.Task<Ok & {}, Fail & {}>; }; export function fail<Error extends globalThis.Error>(error: Error): Task.Task<never, Error>; export function spawn<Ok, Fail extends globalThis.Error, Command extends Task.Suspend | Task.Join | Task.Throw<Fail>>(work: () => Task.Task<Ok, Fail, Command>): Task.Invocation<Ok, Task.InferError<Command>>; export function perform<Ok, Fail extends globalThis.Error, Command extends Task.Suspend | Task.Join | Task.Throw<Fail>>(task: Task.Task<Ok, Fail, Command>): Task.Invocation<Ok, Task.InferError<Command>>; export class AbortError extends Error { /** * @param {unknown} reason */ constructor(reason: unknown); reason: unknown; name: "AbortError"; } import * as Task from './task/task.js'; //# sourceMappingURL=task.d.ts.map