Skip to content

API Overview ​

UntilJS provides a simple, Promise-based API for waiting on value changes.

Installation ​

bash
pnpm add untiljs
bash
npm install untiljs
bash
yarn add untiljs

Quick Reference ​

Functions ​

FunctionDescription
until()Main function to create an Until instance
createStore()Create a reactive store for use with until

Types ​

TypeDescription
WatchSourceTypes of values that can be watched
SubscribableInterface for subscribable objects
UntilToMatchOptionsOptions for wait methods

Methods ​

MethodDescription
toBe(value, options?)Wait until value equals target
toMatch(condition, options?)Wait until condition returns true
toBeTruthy(options?)Wait until value is truthy
toBeNull(options?)Wait until value is null
toBeUndefined(options?)Wait until value is undefined
toBeNaN(options?)Wait until value is NaN
changed(options?)Wait until value changes
changedTimes(n, options?)Wait until value changes n times
toContains(value, options?)Wait until array contains value
not.*Inverse of any method above

Basic Usage ​

typescript
import until from 'untiljs'

// Basic usage
let value = 0
setTimeout(() => { value = 5 }, 1000)

await until(() => value).toBe(5)

Return Value ​

All methods return a Promise that resolves to:

  • The current value when the condition is met
  • The current value on timeout (if throwOnTimeout is false)
  • Rejects on timeout (if throwOnTimeout is true)
typescript
const result = await until(() => value).toBe(5)
console.log(result) // 5

Released under the MIT License.