timeout-flow 0.0.3 → 0.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +8 -8
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -146,13 +146,13 @@ import { debounce, throttle, retry, waitFor } from 'timeout-flow';
|
|
|
146
146
|
|
|
147
147
|
---
|
|
148
148
|
|
|
149
|
-
##
|
|
149
|
+
## Frame-Based Timing (RAF Utilities)
|
|
150
150
|
|
|
151
151
|
These helpers use `requestAnimationFrame` under the hood to provide smooth, energy-efficient timing. Ideal for visual UI flows, canvas apps, scroll/resize behavior, and performance-sensitive interactions.
|
|
152
152
|
|
|
153
153
|
All `raf` utilities automatically **pause in background tabs**, unlike timers.
|
|
154
154
|
|
|
155
|
-
###
|
|
155
|
+
### API Summary
|
|
156
156
|
|
|
157
157
|
| Function | Purpose | Best For |
|
|
158
158
|
| -------------------------- | ------------------------------------------------------------------- | -------------------------------------------------- |
|
|
@@ -164,12 +164,12 @@ All `raf` utilities automatically **pause in background tabs**, unlike timers.
|
|
|
164
164
|
| `throttleRaf(fn, 2)` | Throttles to once every 3 frames (`frameSkip = 2`). | Advanced visuals, slower sync without timers |
|
|
165
165
|
| `waitForRaf()` | Waits for a condition to become true using a frame-based loop. | DOM readiness, layout stability, visibility checks |
|
|
166
166
|
|
|
167
|
-
###
|
|
167
|
+
### Key Advantages
|
|
168
168
|
|
|
169
|
-
*
|
|
170
|
-
*
|
|
171
|
-
*
|
|
172
|
-
*
|
|
169
|
+
* **Frame-sync**: Triggered in sync with visual updates (60Hz or higher)
|
|
170
|
+
* **Background-tab safe**: No CPU use when inactive
|
|
171
|
+
* **Energy efficient**: Great for battery-conscious apps
|
|
172
|
+
* **Smoother UX**: Especially under load or heavy visuals
|
|
173
173
|
|
|
174
174
|
### 🛠 Example Usage
|
|
175
175
|
|
|
@@ -217,7 +217,7 @@ import { waitForRaf } from 'timeout-flow';
|
|
|
217
217
|
await waitForRaf(() => document.querySelector('#panel')?.offsetHeight > 0);
|
|
218
218
|
```
|
|
219
219
|
|
|
220
|
-
###
|
|
220
|
+
### File Locations
|
|
221
221
|
|
|
222
222
|
| File | Description |
|
|
223
223
|
| -------------------- | ------------------------------------------------------ |
|
package/package.json
CHANGED