@cripty2001/utils 0.0.219 → 0.0.220

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.
@@ -217,18 +217,22 @@ export declare function useAsyncInput<C extends Record<string, JSONEncodable>, R
217
217
  * Called once immediately to seed the Whispr, then on every refresh.
218
218
  * @param interval - If provided, the Whispr will automatically re-poll `getData`
219
219
  * every `interval` milliseconds. Pass `null` to disable auto-refresh.
220
- * @returns A tuple of:
221
- * - The resulting `Whispr<T>`, seeded with the initial value from `getData`.
222
- * - A `refresh` function that manually re-reads `getData` and pushes the new
220
+ * @returns An object with:
221
+ * - `data`: The resulting `Whispr<T>`, seeded with the initial value from `getData`.
222
+ * - `refresh`: A function that manually re-reads `getData` and pushes the new
223
223
  * value into the Whispr. Hook this wherever you have a hint that the
224
224
  * external source may have changed.
225
225
  *
226
226
  * @example
227
- * const [windowSize, refreshSize] = whisprFromExternal(
227
+ * const { data: windowSize, refresh: refreshSize } = whisprFromExternal(
228
228
  * () => ({ width: window.innerWidth, height: window.innerHeight }),
229
229
  * null,
230
230
  * );
231
231
  *
232
232
  * window.addEventListener("resize", refreshSize);
233
233
  */
234
- export declare function whisprFromExternal<T>(getData: () => T, interval: number | null): [Whispr<T>, () => void];
234
+ export type WhisprFromExternalResult<T> = {
235
+ data: Whispr<T>;
236
+ refresh: () => void;
237
+ };
238
+ export declare function whisprFromExternal<T>(getData: () => T, interval: number | null): WhisprFromExternalResult<T>;
@@ -439,32 +439,6 @@ function useAsyncInput(value, setValue, handler, setPending = () => { }) {
439
439
  result,
440
440
  ];
441
441
  }
442
- /**
443
- * Creates a Whispr from an external (non-reactive) data source.
444
- *
445
- * Unlike `Whispr.from`, which derives state from other Whisprs, this function
446
- * bridges an arbitrary data generator into Whispr's reactive system — useful
447
- * when your source of truth lives outside the Whispr graph (e.g. a DOM API,
448
- * a global store, or a plain function).
449
- *
450
- * @param getData - A function that returns the current value of the external source.
451
- * Called once immediately to seed the Whispr, then on every refresh.
452
- * @param interval - If provided, the Whispr will automatically re-poll `getData`
453
- * every `interval` milliseconds. Pass `null` to disable auto-refresh.
454
- * @returns A tuple of:
455
- * - The resulting `Whispr<T>`, seeded with the initial value from `getData`.
456
- * - A `refresh` function that manually re-reads `getData` and pushes the new
457
- * value into the Whispr. Hook this wherever you have a hint that the
458
- * external source may have changed.
459
- *
460
- * @example
461
- * const [windowSize, refreshSize] = whisprFromExternal(
462
- * () => ({ width: window.innerWidth, height: window.innerHeight }),
463
- * null,
464
- * );
465
- *
466
- * window.addEventListener("resize", refreshSize);
467
- */
468
442
  function whisprFromExternal(getData, interval) {
469
443
  const intervalRef = (() => {
470
444
  return interval !== null ?
@@ -479,5 +453,8 @@ function whisprFromExternal(getData, interval) {
479
453
  }
480
454
  };
481
455
  const [value, setValue] = whispr_1.Whispr.create(getData(), cleanup);
482
- return [value, () => setValue(getData())];
456
+ return {
457
+ data: value,
458
+ refresh: () => setValue(getData()),
459
+ };
483
460
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cripty2001/utils",
3
- "version": "0.0.219",
3
+ "version": "0.0.220",
4
4
  "description": "Internal Set of utils. If you need them use them, otherwise go to the next package ;)",
5
5
  "homepage": "https://github.com/cripty2001/utils#readme",
6
6
  "bugs": {