timeout-flow 0.0.3 → 0.0.5
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 +11 -8
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -9,6 +9,9 @@
|
|
|
9
9
|
|
|
10
10
|
TimeoutFlow makes working with time-based logic intuitive — think of it as a modern, composable upgrade to `setTimeout` and `setInterval`, with added powers like chaining, conditional logic, pause/resume, retries, and more.
|
|
11
11
|
|
|
12
|
+
* Minified: 6.64 KB
|
|
13
|
+
* Gzipped: 2.6 KB
|
|
14
|
+
|
|
12
15
|
---
|
|
13
16
|
|
|
14
17
|
## Philosophy
|
|
@@ -146,13 +149,13 @@ import { debounce, throttle, retry, waitFor } from 'timeout-flow';
|
|
|
146
149
|
|
|
147
150
|
---
|
|
148
151
|
|
|
149
|
-
##
|
|
152
|
+
## Frame-Based Timing (RAF Utilities)
|
|
150
153
|
|
|
151
154
|
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
155
|
|
|
153
156
|
All `raf` utilities automatically **pause in background tabs**, unlike timers.
|
|
154
157
|
|
|
155
|
-
###
|
|
158
|
+
### API Summary
|
|
156
159
|
|
|
157
160
|
| Function | Purpose | Best For |
|
|
158
161
|
| -------------------------- | ------------------------------------------------------------------- | -------------------------------------------------- |
|
|
@@ -164,12 +167,12 @@ All `raf` utilities automatically **pause in background tabs**, unlike timers.
|
|
|
164
167
|
| `throttleRaf(fn, 2)` | Throttles to once every 3 frames (`frameSkip = 2`). | Advanced visuals, slower sync without timers |
|
|
165
168
|
| `waitForRaf()` | Waits for a condition to become true using a frame-based loop. | DOM readiness, layout stability, visibility checks |
|
|
166
169
|
|
|
167
|
-
###
|
|
170
|
+
### Key Advantages
|
|
168
171
|
|
|
169
|
-
*
|
|
170
|
-
*
|
|
171
|
-
*
|
|
172
|
-
*
|
|
172
|
+
* **Frame-sync**: Triggered in sync with visual updates (60Hz or higher)
|
|
173
|
+
* **Background-tab safe**: No CPU use when inactive
|
|
174
|
+
* **Energy efficient**: Great for battery-conscious apps
|
|
175
|
+
* **Smoother UX**: Especially under load or heavy visuals
|
|
173
176
|
|
|
174
177
|
### 🛠 Example Usage
|
|
175
178
|
|
|
@@ -217,7 +220,7 @@ import { waitForRaf } from 'timeout-flow';
|
|
|
217
220
|
await waitForRaf(() => document.querySelector('#panel')?.offsetHeight > 0);
|
|
218
221
|
```
|
|
219
222
|
|
|
220
|
-
###
|
|
223
|
+
### File Locations
|
|
221
224
|
|
|
222
225
|
| File | Description |
|
|
223
226
|
| -------------------- | ------------------------------------------------------ |
|
package/package.json
CHANGED