New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@alwatr/wait

Package Overview
Dependencies
Maintainers
0
Versions
17
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@alwatr/wait - npm Package Compare versions

Comparing version 1.1.12 to 1.1.13

6

CHANGELOG.md

@@ -6,2 +6,8 @@ # Change Log

## [1.1.13](https://github.com/Alwatr/nanolib/compare/@alwatr/wait@1.1.12...@alwatr/wait@1.1.13) (2024-08-31)
### Dependencies update
* update all dependencies ([1e0c30e](https://github.com/Alwatr/nanolib/commit/1e0c30e6a3a8e19deb5185814e24ab6c08dca573)) by @AliMD
## [1.1.12](https://github.com/Alwatr/nanolib/compare/@alwatr/wait@1.1.11...@alwatr/wait@1.1.12) (2024-07-04)

@@ -8,0 +14,0 @@

14

package.json
{
"name": "@alwatr/wait",
"version": "1.1.12",
"version": "1.1.13",
"description": "Comprehensive toolkit for managing asynchronous operations.",

@@ -69,13 +69,13 @@ "author": "S. Ali Mihandoost <ali.mihandoost@gmail.com>",

"dependencies": {
"@alwatr/global-scope": "^1.1.17"
"@alwatr/global-scope": "^1.1.18"
},
"devDependencies": {
"@alwatr/nano-build": "^1.3.7",
"@alwatr/nano-build": "^1.3.8",
"@alwatr/prettier-config": "^1.0.4",
"@alwatr/tsconfig-base": "^1.2.0",
"@alwatr/type-helper": "^1.2.4",
"@types/node": "^20.14.9",
"typescript": "^5.5.3"
"@alwatr/type-helper": "^1.2.5",
"@types/node": "^22.5.1",
"typescript": "^5.5.4"
},
"gitHead": "98b9c29f927d9487d318d109556c873b13ea2056"
"gitHead": "5d81b77988089edb24aa6853d0a98fdeb85dbf77"
}

@@ -1,10 +0,12 @@

# Wait
# @alwatr/wait
Comprehensive toolkit for managing asynchronous operations in JavaScript.
`@alwatr/wait` offers a collection of utility functions to handle asynchronous execution flow effectively. It allows you to pause your code until specific conditions are met or certain events occur. This functionality aids in managing complex asynchronous scenarios and crafting intricate flows with ease. The functions can be used independently or combined for robust control over asynchronous operations.
It comprises a set of utility functions, each designed to pause execution until specific conditions are met or certain events occur. This feature makes these utilities particularly useful for controlling the flow of asynchronous code, allowing developers to handle complex scenarios with ease. The functions can be used individually or combined to create intricate asynchronous flows, providing a robust solution for various programming needs.
## Installation
```bash
npm install @alwatr/wait
```
```bash
yarn add @alwatr/wait

@@ -15,6 +17,85 @@ ```

```typescript
import {waitForTime} from '@alwatr/wait';
Each function within `@alwatr/wait` returns a Promise that resolves when the specified waiting condition is met. Here's a breakdown of the available functions:
await waitForTime(2000);
```
* **waitForTimeout(duration: number): Promise<void>**
* Waits for a specified duration (in milliseconds) before resolving.
* Example:
```typescript
import { waitForTimeout } from '@alwatr/wait';
await waitForTimeout(1000); // Waits for 1 second
```
* **waitForAnimationFrame(): Promise<DOMHighResTimeStamp>**
* Pauses execution until the next animation frame is scheduled, resolving with the current timestamp.
* Useful for synchronizing UI updates with browser rendering.
* Example:
```typescript
import { waitForAnimationFrame } from '@alwatr/wait';
await waitForAnimationFrame(); // Waits for next animation frame
```
* **waitForIdle(timeout?: number): Promise<IdleDeadline>**
* Waits for the next idle period (when the browser is not busy), resolving with an `IdleDeadline` object.
* Optionally accepts a timeout value (in milliseconds) for maximum waiting time.
* Ideal for executing tasks that don't impact user experience.
* Example:
```typescript
import { waitForIdle } from '@alwatr/wait';
await waitForIdle(); // Waits for next idle period
```
* **waitForDomEvent<T extends keyof HTMLElementEventMap>(element: HTMLElement, eventName: T): Promise<HTMLElementEventMap[T]>**
* Pauses execution until a specific DOM event is triggered on a provided element, resolving with the event object.
* Example:
```typescript
import { waitForDomEvent } from '@alwatr/wait';
const button = document.getElementById('myButton');
await waitForDomEvent(button, 'click'); // Waits for click event on button
```
* **waitForEvent(target: HasAddEventListener, eventName: string): Promise<Event>**
* More generic version of `waitForDomEvent`, allowing waiting for any event on any object with an `addEventListener` method.
* Example:
```typescript
import { waitForEvent } from '@alwatr/wait';
const server = http.createServer();
await waitForEvent(server, 'request'); // Waits for request event on server
```
* **waitForImmediate(): Promise<void>**
* Executes the next task in the microtask queue immediately after the current task finishes.
* Example:
```typescript
import { waitForImmediate } from '@alwatr/wait';
await waitForImmediate(); // Executes next microtask
```
* **waitForMicrotask(): Promise<void>**
* Similar to `waitForImmediate`, but waits specifically for the next microtask queue.
* Example:
```typescript
import { waitForMicrotask } from '@alwatr/wait';
await waitForMicrotask(); // Waits for next microtask queue
```
## Contributing
We welcome contributions to improve this package! Feel free to open bug reports, suggest new features, or submit pull requests following our [contribution guidelines](https://github.com/Alwatr/.github/blob/next/CONTRIBUTING.md).
**License:**
This package is distributed under the [MIT License](https://alimd.mit-license.org/).

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc