Skip to content

BlackGlory/wait-for

Repository files navigation

wait-for

A module for waiting for things to happen.

Install

npm install --save @blackglory/wait-for
# or
yarn add @blackglory/wait-for

API

waitForDOMChanged

function waitForDOMChanged(): Promies<void>

waitForAttached

function waitForAttached(...nodes: Node[]): Promise<void>

waitForDetached

function waitForDetached(...nodes: Node[]): Promise<void>

waitForElementsMatchingSelectorAttached

function waitForElementsMatchingSelectorAttached(
  selector: string
): Promise<Element[]>

waitForElementsMatchingSelectorAttached

function waitForElementsMatchingSelectorAttached(
  selector: string
): Promise<Element[]>

waitForAllElementsMatchingSelectorDetached

function waitForAllElementsMatchingSelectorDetached(
  selector: string
): Promise<void>

waitForEventTarget

function waitForEventTarget<T extends EventTarget>(
  target: T
, event: string
, signal?: AbortSignal
): Promise<Event>

waitForEventEmitter

function waitForEventEmitter<T extends EventEmitter>(
  target: T
, event: string
, signal?: AbortSignal
): Promise<unknown[]>

waitForEmitter

function waitForEmitter<
  EventToArgs extends Record<string, unknown[]>
, Event extends keyof EventToArgs
>(
  target: Emitter<EventToArgs>
, event: Event
, signal?: AbortSignal
): Promise<EventToArgs[Event]>

waitForDOMContentLoaded

function waitForDOMContentLoaded(): Promise<void>

waitForLoad

function waitForLoad(): Promise<void>

waitForComplete

function waitForComplete(): Promise<void>

waitForInteractiveOrComplete

function waitForInteractiveOrComplete(): Promise<void>

waitForFunction

function waitForFunction<T>(
  fn: () => T | PromiseLike<T>
, interval: number = 0
): Promise<T>

waitForTimeout

function waitForTimeout(ms: number, signal?: AbortSignal): Promise<void>

waitForStateChanged

function waitForStateChanged(): Promise<void>

waitForUrlChanged

function waitForUrlChanged(): Promise<void>

waitForAllMacrotasksProcessed

function waitForAllMacrotasksProcessed(): Promise<void>

waitForAllMicrotasksProcessed

function waitForAllMicrotasksProcessed(): Promise<void>