包详细信息

@blackglory/wait-for

BlackGlory229MIT0.8.1

A module for waiting for things to happen.

waitFor, DOM

自述文件

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>

waitForIdleCallback

function waitForIdleCallback(options?: IdleRequestOptions): Promise<IdleDeadline>

waitForAnimationFrame

function waitForAnimationFrame(): Promise<DOMHighResTimeStamp>

waitForVideoFrameCallback

function waitForVideoFrameCallback(
  video: HTMLVideoElement
): Promise<Parameters<VideoFrameRequestCallback>>

更新日志

Changelog

All notable changes to this project will be documented in this file. See standard-version for commit guidelines.

0.8.1 (2025-02-14)

Features

  • add waitForVideoFrameCallback (8cf3ee9)

0.8.0 (2025-01-20)

⚠ BREAKING CHANGES

    • Node.js v16 => Node.js v22
  • ES2018 => ES2022

Features

  • add waitForIdleCallback, waitForAnimationFrame (f7f5db4)

0.7.4 (2023-06-11)

Bug Fixes

0.7.3 (2023-03-18)

0.7.2 (2023-03-18)

0.7.1 (2023-03-10)

Features

  • add the optional parameter signal (a64e2cf)

0.7.0 (2023-03-08)

⚠ BREAKING CHANGES

  • CommonJS => ESM

  • upgrade dependencies (4e1fb3e)

0.6.0 (2022-11-19)

⚠ BREAKING CHANGES

  • The minimum version of Node.js is 16

Bug Fixes

  • the signature of waitForEventEmitter (723d15c)

0.5.3 (2022-11-01)

Features

0.5.2 (2022-11-01)

0.5.1 (2022-06-09)

Features

  • add waitForAllMacrotasksProcessed, waitForAllMicrotasksProcessed (2ab3882)

0.5.0 (2022-06-08)

⚠ BREAKING CHANGES

  • waitForEventEmitter, waitForEventTarget were rewritten

Features

  • add waitForEmitter (07846e9)
  • rewrite waitForEventEmitter, waitForEventTarget (cbe0002)

0.4.4 (2022-03-09)

Features

  • add waitForComplete, waitForInteractiveOrComplete (1ab39a6)

0.4.3 (2022-02-25)

Features

  • improve waitForFunction (933051d)

0.4.2 (2022-01-06)

0.4.1 (2021-12-17)

0.4.0 (2021-12-16)

⚠ BREAKING CHANGES

    • The minimum version is Node.js v16
  • upgrade dependencies (290ae7a)

0.3.5 (2021-12-05)

0.3.4 (2021-10-14)

0.3.3 (2021-07-13)

0.3.2 (2021-05-17)

0.3.1 (2021-05-16)

0.3.0 (2021-04-24)

⚠ BREAKING CHANGES

    • rename waitForSelectorAttached => waitForElementsMatchingSelectorAttacked
  • rename waitForSelectorDetached => waitForAllElementsMatchingSelectorDetached

  • use @blackglory/observe (a9f07b9)

0.2.13 (2021-04-24)

0.2.12 (2021-03-27)

0.2.11 (2021-03-17)

0.2.10 (2021-03-08)

0.2.9 (2021-02-25)

0.2.8 (2021-02-04)

0.2.7 (2021-02-03)

0.2.6 (2021-01-20)

Bug Fixes

0.2.5 (2021-01-20)

0.2.4 (2021-01-16)

0.2.3 (2021-01-15)

Bug Fixes

0.2.2 (2021-01-04)

0.2.1 (2020-11-18)

0.2.0 (2020-11-18)

⚠ BREAKING CHANGES

  • waitForEvent => waitForEventTarget

Features

  • add waitForEventEmitter (5dfee62)

0.1.5 (2020-10-10)