fynjs API
    Preparing search index...

    Class AveAzul<T>

    AveAzul ("Blue Bird" in Spanish) - Extended Promise class that provides Bluebird like utility methods This implementation is inspired by and provides similar APIs to the Bluebird Promise library, but built on top of native Promises. The name is a Spanish play on words referencing Bluebird.

    Type Parameters

    • T

    Hierarchy

    • Promise<T>
      • AveAzul
    Index
    • Type Parameters

      • T

      Parameters

      • executor: (
            resolve: (value: T | PromiseLike<T>) => void,
            reject: (reason?: unknown) => void,
        ) => void

      Returns AveAzul<T>

    "[toStringTag]": string
    finally: (onfinally?: () => void) => AveAzul<T>

    Attaches a callback that is invoked when the Promise is settled (fulfilled or rejected). The resolved value cannot be modified from the callback.

    Type Declaration

      • (onfinally?: () => void): AveAzul<T>
      • Parameters

        • Optionalonfinally: () => void

          The callback to execute when the Promise is settled (fulfilled or rejected).

        Returns AveAzul<T>

        A Promise for the completion of the callback.

    then: <TResult1 = T, TResult2 = never>(
        onfulfilled?: (value: T) => TResult1 | PromiseLike<TResult1>,
        onrejected?: (reason: any) => TResult2 | PromiseLike<TResult2>,
    ) => AveAzul<TResult1 | TResult2>

    The instance-side counterpart to the declare static block above, and for the same reason: then/catch/finally construct through this (SpeciesConstructor), so each one really hands back an AveAzul -- but Promise's lib types say plain Promise, so the first link in any chain loses every bluebird method and callers need as AveAzulInstance<T> to get them back. These are declare, so nothing is emitted and no runtime behavior changes.

    AveAzul<T> still satisfies Promise<T>/PromiseLike<T> after this, since the returned AveAzul is itself a Promise - await and interop are unaffected.

    ___throwUncaughtError: (error: unknown) => void = triggerUncaughtException

    When fatal error and AveAzul needs to crash the process, this method is used to throw the error.

    Type Declaration

      • (error: unknown): void
      • Triggers an uncaught exception in a safe way by scheduling it on the next event loop tick This is used for fatal errors that should crash the process

        Parameters

        • error: unknown

          The error to throw

        Returns void

    The error to throw.

    __notImplementedInstance?: string[]
    __notImplementedStatic?: string[]
    "[species]": PromiseConstructor
    all: <U>(values: Iterable<U | PromiseLike<U>>) => AveAzul<Awaited<U>[]>

    Creates a Promise that is resolved with an array of results when all of the provided Promises resolve, or rejected when any Promise is rejected.

    Type Declaration

      • <U>(values: Iterable<U | PromiseLike<U>>): AveAzul<Awaited<U>[]>
      • Type Parameters

        • U

        Parameters

        • values: Iterable<U | PromiseLike<U>>

          An iterable of Promises.

        Returns AveAzul<Awaited<U>[]>

        A new Promise.

    Disposer: typeof Disposer = Disposer
    fromNode: <T>(
        fn: (callback: (err: Error, ...args: T[]) => void) => void,
        options?: FromCallbackOptions,
    ) => AveAzul<T> = AveAzul.fromCallback

    Type Declaration

      • <T>(
            fn: (callback: (err: Error, ...args: T[]) => void) => void,
            options?: FromCallbackOptions,
        ): AveAzul<T>
      • Bluebird-style fromCallback() for converting callback-based functions to promises

        Type Parameters

        • T

        Parameters

        • fn: (callback: (err: Error, ...args: T[]) => void) => void

          Function to convert

        • Optionaloptions: FromCallbackOptions

          Options object

        Returns AveAzul<T>

        Promise that resolves with the function's return value

    isOperationalError: (error: unknown) => boolean = isOperationalError

    Type Declaration

      • (error: unknown): boolean
      • Check if an error is an operational error

        Parameters

        • error: unknown

          Error to check

        Returns boolean

        True if the error is operational

    isProgrammerError: (error: unknown) => boolean = isProgrammerError

    Type Declaration

      • (error: unknown): boolean
      • Check if an error is a programmer error (unexpected, likely a bug)

        Parameters

        • error: unknown

          Error to check

        Returns boolean

        True if the error is a programmer error

    OperationalError: typeof OperationalError = OperationalError
    reject: <U = never>(reason?: unknown) => AveAzul<U>

    Creates a new rejected promise for the provided reason.

    Type Declaration

      • <U = never>(reason?: unknown): AveAzul<U>
      • Type Parameters

        • U = never

        Parameters

        • Optionalreason: unknown

          The reason the promise was rejected.

        Returns AveAzul<U>

        A new rejected Promise.

    resolve: { <U>(value: U | PromiseLike<U>): AveAzul<U>; (): AveAzul<void> }

    resolve/reject/all are inherited from Promise. Per the ECMAScript spec they construct through this, so at runtime they already hand back AveAzul instances -- but PromiseConstructor types them as plain Promise, which drops every AveAzul method (.spread(), .disposer(), ...). These ambient re-declarations state the real return types; they add declare, so nothing is emitted and no behavior changes. They match what the exported AveAzulClass interface has always promised.

    • Bluebird-style all() method for array operations Similar to Promise.all() but operates on the resolved value of this promise

      Returns AveAzul<any[]>

      Promise that resolves when all items in the array resolve

    • Bluebird-style any() method for waiting for any promises to resolve

      Returns AveAzul<any>

      Promise that resolves with the first resolved promise

    • Bluebird-style asCallback() method Attaches a callback to the promise and returns the promise. The callback is invoked when the promise is resolved or rejected.

      Parameters

      • cb: ((err: Error, value?: T) => void) | ((err: Error, ...values: any[]) => void)

        Node.js-style callback function (err, value)

      • options: AsCallbackOptions = {}

        Additional options

      Returns AveAzul<T>

      The same promise instance

    • Bluebird-style call() method for calling a method on the resolved value

      Parameters

      • methodName: string

        Name of the method to call

      • ...args: any[]

        Arguments to pass to the method

      Returns AveAzul<any>

      Promise that resolves with the method's return value

    • Bluebird-style filtered catch: .catch(filter..., handler). A filter is an Error class (instanceof), a predicate function, or an object whose own properties must equal the error's. Unmatched errors are rethrown. With a single argument it is the native catch.

      Type Parameters

      • TResult = never

      Parameters

      Returns AveAzul<T | TResult>

    • Bluebird-style filtered catch: .catch(filter..., handler). A filter is an Error class (instanceof), a predicate function, or an object whose own properties must equal the error's. Unmatched errors are rethrown. With a single argument it is the native catch.

      Type Parameters

      • TResult = never

      Parameters

      • ...filtersAndHandler: [...CatchFilter[], (reason: any) => TResult | PromiseLike<TResult>]

      Returns AveAzul<T | TResult>

    • Bluebird-style catchReturn() that catches an error and returns a value instead

      Type Parameters

      • U

      Parameters

      • value: U

        Value to return

      Returns AveAzul<T | U>

      Promise that resolves with the given value

    • Bluebird-style catchThrow() that catches an error and throws a new one

      Parameters

      • reason: unknown

        Value to reject the promise with

      Returns AveAzul<T>

      Promise that rejects with the new reason

    • Bluebird-style delay() method

      Parameters

      • ms: number

        Milliseconds to delay

      Returns AveAzul<T>

      Promise that resolves after the delay

    • Bluebird-style disposer() for resource cleanup

      Parameters

      • fn: (resource: T) => void | Promise<void>

        Cleanup function

      Returns Disposer<T>

      Disposer object

    • Bluebird-style each() method for array iteration Similar to Bluebird's Promise.prototype.each()

      Parameters

      • fn: (item: any, index: number, length: number) => unknown

        Function to execute for each element

      Returns AveAzul<any[]>

      Promise that resolves when iteration is complete

    • Catches only operational errors and passes them to the handler. Programmer errors (non-operational) are rethrown.

      Parameters

      • handler: (err: Error) => unknown

        Function to handle operational errors

      Returns AveAzul<T>

      Promise with the error handled or rethrown

    • Bluebird-style filter() method for array operations Similar to Bluebird's Promise.prototype.filter()

      Parameters

      • fn: (item: any, index: number, length: number) => any

        Filter function to apply to each element

      Returns AveAzul<any[]>

      Promise that resolves with the filtered array

    • Bluebird-style get() for retrieving a property value

      Type Parameters

      • K extends string | number | symbol

      Parameters

      • key: K

        Key to retrieve

      Returns AveAzul<T[K]>

      Promise that resolves with the property value

    • Bluebird-style map() method for array operations Similar to Bluebird's Promise.prototype.map()

      Type Parameters

      • U

      Parameters

      • fn: (item: any, index: number, length: number) => U | PromiseLike<U>

        Map function to apply to each element

      • options: MapOptions = ...

      Returns AveAzul<U[]>

      Promise that resolves with the mapped array

    • Bluebird-style mapSeries() method for array operations Similar to Bluebird's Promise.prototype.mapSeries()

      Type Parameters

      • U

      Parameters

      • fn: (item: any, index: number, length: number) => U | PromiseLike<U>

        Map function to apply to each element

      Returns AveAzul<U[]>

      Promise that resolves with the mapped array

    • Bluebird-style props() for object properties

      Returns AveAzul<any>

      Promise that resolves with an object of resolved values

    • Bluebird-style reduce() method for array reduction Similar to Bluebird's Promise.prototype.reduce()

      Type Parameters

      • U

      Parameters

      • fn: (value: U, item: any, index: number, length: number) => U | PromiseLike<U>

        Reducer function to apply to each element

      • OptionalinitialValue: U

        Optional initial value

      Returns AveAzul<U>

      Promise that resolves with the final reduced value

    • Bluebird-style return() method to inject a value into the chain Similar to Bluebird's Promise.prototype.return()

      Type Parameters

      • U

      Parameters

      • value: U

        Value to return

      Returns AveAzul<U>

      Promise that resolves with the new value

    • Parameters

      • count: number

      Returns AveAzul<any[]>

    • Bluebird-style spread() method for handling array arguments Similar to Bluebird's Promise.prototype.spread()

      Type Parameters

      • U

      Parameters

      • fn: (...args: any[]) => U | PromiseLike<U>

        Function to apply to the array arguments

      Returns AveAzul<U>

      Promise that resolves with the function's return value

    • Bluebird-style tap() method that lets you perform side effects in a chain Similar to Bluebird's Promise.prototype.tap()

      Parameters

      • fn: (value: T) => unknown

        Function to execute with the resolved value

      Returns AveAzul<T>

      Promise that resolves with the original value

    • Bluebird-style tapCatch() for side effects on rejection

      Parameters

      • fn: (err: Error) => unknown

        Function to execute on rejection

      Returns AveAzul<T>

      Promise that maintains the rejection

    • Bluebird-style throw() that returns a rejected promise with the given reason

      Parameters

      • reason: unknown

        Value to reject the promise with

      Returns AveAzul<never>

      Promise that rejects with the given reason

    • Bluebird-style timeout() method

      Parameters

      • ms: number

        Milliseconds before timeout

      • message: string = "operation timed out"

        Optional error message

      Returns AveAzul<T>

      Promise that rejects if timeout occurs

    • Creates a Promise that is resolved with an array of results when all of the provided Promises resolve or reject.

      Type Parameters

      • T extends [] | readonly unknown[]

      Parameters

      • values: T

        An array of Promises.

      Returns Promise<
          {
              -readonly [P in string
              | number
              | symbol]: PromiseSettledResult<Awaited<T[P]>>
          },
      >

      A new Promise.

    • Creates a Promise that is resolved with an array of results when all of the provided Promises resolve or reject.

      Type Parameters

      • T

      Parameters

      • values: Iterable<T | PromiseLike<T>>

        An array of Promises.

      Returns Promise<PromiseSettledResult<Awaited<T>>[]>

      A new Promise.

    • Bluebird-style any() for waiting for any promise to resolve

      Type Parameters

      • T

      Parameters

      • args: Iterable<T | PromiseLike<T>>

        Array or iterable of promises

      Returns AveAzul<T>

      Promise that resolves with the first resolved value

    • Bluebird-style defer() for creating a deferred promise

      Type Parameters

      • T

      Returns Deferred<T>

      Deferred object with promise, resolve, and reject methods

    • Bluebird-style delay() that resolves after specified milliseconds

      Type Parameters

      • U

      Parameters

      • ms: number

        Milliseconds to delay

      • Optionalvalue: U

        Optional value to resolve with

      Returns AveAzul<U>

      Promise that resolves after the delay

    • Bluebird-style each() for array iteration

      Type Parameters

      • T

      Parameters

      • items: Iterable<T | PromiseLike<T>>

        Array to iterate over

      • fn: (item: T, index: number, length: number) => unknown

        Iterator function to call for each item

      Returns AveAzul<T[]>

      Promise that resolves when iteration is complete

    • Bluebird-style filter() for array filtering

      Type Parameters

      • T

      Parameters

      • items: Iterable<T | PromiseLike<T>>

        Array or iterable to filter

      • fn: (item: T, index: number, length: number) => unknown

        Filter function (item, index, length)

      Returns AveAzul<T[]>

      Promise that resolves with the items that passed the filter

    • Bluebird-style fromCallback() for converting callback-based functions to promises

      Type Parameters

      • T

      Parameters

      • fn: (callback: (err: Error, ...args: T[]) => void) => void

        Function to convert

      • Optionaloptions: FromCallbackOptions

        Options object

      Returns AveAzul<T>

      Promise that resolves with the function's return value

    • Bluebird-style join() for joining promises

      Parameters

      • ...args: any[]

        Promises to join

      Returns AveAzul<any>

      Promise that resolves with the handler's return value

    • Bluebird-style map() for array operations

      Type Parameters

      • T
      • U

      Parameters

      • value: Iterable<T | PromiseLike<T>>

        Array to map over

      • fn: (item: T, index: number, length: number) => U | PromiseLike<U>

        Map function to apply to each element

      • options: MapOptions = ...

      Returns AveAzul<U[]>

      Promise that resolves with the mapped array

    • Bluebird-style mapSeries() for array operations

      Type Parameters

      • T
      • U

      Parameters

      • value: Iterable<T | PromiseLike<T>>

        Array to map over

      • fn: (item: T, index: number, length: number) => U | PromiseLike<U>

        Map function to apply to each element

      Returns AveAzul<U[]>

      Promise that resolves with the mapped array

    • Bluebird-style method() for creating a method that returns a promise

      Type Parameters

      • T
      • Args extends any[]

      Parameters

      • fn: (...args: Args) => T | PromiseLike<T>

        Function to create a method for

      Returns (...args: Args) => AveAzul<T>

      Method function that returns a promise

    • Bluebird-style promisify() for converting callback-based functions to promises

      Type Parameters

      • T = unknown

      Parameters

      • fn: (...args: any[]) => void

        Function to promisify

      • Optionaloptions: PromisifyOptions

        Options object

      Returns (...args: any[]) => AveAzul<T>

      Promisified function

    • Bluebird-style promisifyAll() for converting callback-based functions to promises

      Type Parameters

      • T extends object

      Parameters

      Returns T

      Object with promisified methods

    • Bluebird-style props() for object properties

      Type Parameters

      • T extends object

      Parameters

      • obj: T

        Object with promise values

      Returns AveAzul<{ [K in string | number | symbol]: Awaited<T[K]> }>

      Promise that resolves with an object of resolved values

    • Creates a Promise that is resolved or rejected when any of the provided Promises are resolved or rejected.

      Type Parameters

      • T

      Parameters

      • values: Iterable<T | PromiseLike<T>>

        An iterable of Promises.

      Returns Promise<Awaited<T>>

      A new Promise.

    • Creates a Promise that is resolved or rejected when any of the provided Promises are resolved or rejected.

      Type Parameters

      • T extends [] | readonly unknown[]

      Parameters

      • values: T

        An array of Promises.

      Returns Promise<Awaited<T[number]>>

      A new Promise.

    • Bluebird-style reduce() for array reduction

      Type Parameters

      • T
      • U

      Parameters

      • array: Iterable<T | PromiseLike<T>>

        Array to reduce

      • fn: (value: U, item: T, index: number, length: number) => U | PromiseLike<U>

        Reducer function (value, item, index, length)

      • OptionalinitialValue: U

        Optional initial value

      Returns AveAzul<U>

      Promise that resolves with the final reduced value

    • Bluebird-style some() for waiting for some promises to resolve

      Type Parameters

      • T

      Parameters

      • promises: Iterable<T | PromiseLike<T>>

        Array or iterable of promises

      • count: number

        Number of promises that need to resolve

      Returns AveAzul<T[]>

      Promise that resolves when count promises have resolved

    • Bluebird-style try() for wrapping sync/async functions

      Type Parameters

      • T

      Parameters

      • fn: () => T | PromiseLike<T>

        Function to execute

      Returns AveAzul<T>

      Promise that resolves with the function's return value

    • Bluebird-style using() for resource management. There is only a static version of this method. After the handler finish and returns, regardless of whether it resolves or rejects, the resources will be disposed.

      Type Parameters

      • R

      Parameters

      • resources: any

        Resource disposers, either an array of disposers or a variadic argument list

      • ...args: any[]

        Handler function that will receive the resources as arguments

      Returns AveAzul<R>

      Promise that resolves with handler result