summaryrefslogtreecommitdiffstats
path: root/chromium/third_party/node/node_modules/lit-html/directives/private-async-helpers.d.ts
blob: 1090d68b644dde254f001026c09bddac4c3257ce (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
/**
 * @license
 * Copyright 2021 Google LLC
 * SPDX-License-Identifier: BSD-3-Clause
 */
/**
 * Helper to iterate an AsyncIterable in its own closure.
 * @param iterable The iterable to iterate
 * @param callback The callback to call for each value. If the callback returns
 * `false`, the loop will be broken.
 */
export declare const forAwaitOf: <T>(iterable: AsyncIterable<T>, callback: (value: T) => Promise<boolean>) => Promise<void>;
/**
 * Holds a reference to an instance that can be disconnected and reconnected,
 * so that a closure over the ref (e.g. in a then function to a promise) does
 * not strongly hold a ref to the instance. Approximates a WeakRef but must
 * be manually connected & disconnected to the backing instance.
 */
export declare class PseudoWeakRef<T> {
    private _ref?;
    constructor(ref: T);
    /**
     * Disassociates the ref with the backing instance.
     */
    disconnect(): void;
    /**
     * Reassociates the ref with the backing instance.
     */
    reconnect(ref: T): void;
    /**
     * Retrieves the backing instance (will be undefined when disconnected)
     */
    deref(): T | undefined;
}
/**
 * A helper to pause and resume waiting on a condition in an async function
 */
export declare class Pauser {
    private _promise?;
    private _resolve?;
    /**
     * When paused, returns a promise to be awaited; when unpaused, returns
     * undefined. Note that in the microtask between the pauser being resumed
     * an an await of this promise resolving, the pauser could be paused again,
     * hence callers should check the promise in a loop when awaiting.
     * @returns A promise to be awaited when paused or undefined
     */
    get(): Promise<void> | undefined;
    /**
     * Creates a promise to be awaited
     */
    pause(): void;
    /**
     * Resolves the promise which may be awaited
     */
    resume(): void;
}
//# sourceMappingURL=private-async-helpers.d.ts.map