Extremely Popular
Go to Latest
class DeferredAccessStack
import { DeferredAccessStack } from "https://dotland.deno.dev/x/postgres@v0.17.2/utils/deferred.ts";

The DeferredAccessStack provides access to a series of elements provided on the stack creation, but with the caveat that they require an initialization of sorts before they can be used

Instead of providing a creator function as you would with the DeferredStack, you provide an initialization callback to execute for each element that is retrieved from the stack and a check callback to determine if the element requires initialization and return a count of the initialized elements

Constructors

new
DeferredAccessStack(
elements: T[],
initCallback: (element: T) => Promise<void>,
checkInitCallback: (element: T) => Promise<boolean> | boolean,
)

Properties

readonly
available: number
readonly
size: number

The max number of elements that can be contained in the stack a time

Methods

initialized(): Promise<number>

Will execute the check for initialization on each element of the stack and then return the number of initialized elements that pass the check

pop(): Promise<T>
push(value: T): void