@vueuse/shared 12.2.0 → 12.4.0

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/index.cjs CHANGED
@@ -9,13 +9,13 @@ function computedEager(fn, options) {
9
9
  result.value = fn();
10
10
  }, {
11
11
  ...options,
12
- flush: (_a = options == null ? void 0 : options.flush) != null ? _a : "sync"
12
+ flush: (_a = options == null ? undefined : options.flush) != null ? _a : "sync"
13
13
  });
14
14
  return vue.readonly(result);
15
15
  }
16
16
 
17
17
  function computedWithControl(source, fn) {
18
- let v = void 0;
18
+ let v = undefined;
19
19
  let track;
20
20
  let trigger;
21
21
  const dirty = vue.ref(true);
@@ -25,7 +25,7 @@ function computedWithControl(source, fn) {
25
25
  };
26
26
  vue.watch(source, update, { flush: "sync" });
27
27
  const get = typeof fn === "function" ? fn : fn.get;
28
- const set = typeof fn === "function" ? void 0 : fn.set;
28
+ const set = typeof fn === "function" ? undefined : fn.set;
29
29
  const result = vue.customRef((_track, _trigger) => {
30
30
  track = _track;
31
31
  trigger = _trigger;
@@ -39,7 +39,7 @@ function computedWithControl(source, fn) {
39
39
  return v;
40
40
  },
41
41
  set(v2) {
42
- set == null ? void 0 : set(v2);
42
+ set == null ? undefined : set(v2);
43
43
  }
44
44
  };
45
45
  });
@@ -101,7 +101,7 @@ const localProvidedStateMap = /* @__PURE__ */ new WeakMap();
101
101
  const injectLocal = (...args) => {
102
102
  var _a;
103
103
  const key = args[0];
104
- const instance = (_a = vue.getCurrentInstance()) == null ? void 0 : _a.proxy;
104
+ const instance = (_a = vue.getCurrentInstance()) == null ? undefined : _a.proxy;
105
105
  if (instance == null && !vue.hasInjectionContext())
106
106
  throw new Error("injectLocal must be called in setup");
107
107
  if (instance && localProvidedStateMap.has(instance) && key in localProvidedStateMap.get(instance))
@@ -111,7 +111,7 @@ const injectLocal = (...args) => {
111
111
 
112
112
  const provideLocal = (key, value) => {
113
113
  var _a;
114
- const instance = (_a = vue.getCurrentInstance()) == null ? void 0 : _a.proxy;
114
+ const instance = (_a = vue.getCurrentInstance()) == null ? undefined : _a.proxy;
115
115
  if (instance == null)
116
116
  throw new Error("provideLocal must be called in setup");
117
117
  if (!localProvidedStateMap.has(instance))
@@ -122,8 +122,8 @@ const provideLocal = (key, value) => {
122
122
  };
123
123
 
124
124
  function createInjectionState(composable, options) {
125
- const key = (options == null ? void 0 : options.injectionKey) || Symbol(composable.name || "InjectionState");
126
- const defaultValue = options == null ? void 0 : options.defaultValue;
125
+ const key = (options == null ? undefined : options.injectionKey) || Symbol(composable.name || "InjectionState");
126
+ const defaultValue = options == null ? undefined : options.defaultValue;
127
127
  const useProvidingState = (...args) => {
128
128
  const state = composable(...args);
129
129
  provideLocal(key, state);
@@ -141,8 +141,8 @@ function createSharedComposable(composable) {
141
141
  subscribers -= 1;
142
142
  if (scope && subscribers <= 0) {
143
143
  scope.stop();
144
- state = void 0;
145
- scope = void 0;
144
+ state = undefined;
145
+ scope = undefined;
146
146
  }
147
147
  };
148
148
  return (...args) => {
@@ -208,13 +208,8 @@ function makeDestructurable(obj, arr) {
208
208
  }
209
209
  }
210
210
 
211
- function toValue(r) {
212
- return typeof r === "function" ? r() : vue.unref(r);
213
- }
214
- const resolveUnref = toValue;
215
-
216
211
  function reactify(fn, options) {
217
- const unrefFn = (options == null ? void 0 : options.computedGetter) === false ? vue.unref : toValue;
212
+ const unrefFn = (options == null ? undefined : options.computedGetter) === false ? vue.unref : vue.toValue;
218
213
  return function(...args) {
219
214
  return vue.computed(() => fn.apply(this, args.map((i) => unrefFn(i))));
220
215
  };
@@ -283,7 +278,7 @@ function reactiveComputed(fn) {
283
278
  function reactiveOmit(obj, ...keys) {
284
279
  const flatKeys = keys.flat();
285
280
  const predicate = flatKeys[0];
286
- return reactiveComputed(() => typeof predicate === "function" ? Object.fromEntries(Object.entries(vue.toRefs(obj)).filter(([k, v]) => !predicate(toValue(v), k))) : Object.fromEntries(Object.entries(vue.toRefs(obj)).filter((e) => !flatKeys.includes(e[0]))));
281
+ return reactiveComputed(() => typeof predicate === "function" ? Object.fromEntries(Object.entries(vue.toRefs(obj)).filter(([k, v]) => !predicate(vue.toValue(v), k))) : Object.fromEntries(Object.entries(vue.toRefs(obj)).filter((e) => !flatKeys.includes(e[0]))));
287
282
  }
288
283
 
289
284
  const isClient = typeof window !== "undefined" && typeof document !== "undefined";
@@ -310,7 +305,7 @@ const hasOwn = (val, key) => Object.prototype.hasOwnProperty.call(val, key);
310
305
  const isIOS = /* @__PURE__ */ getIsIOS();
311
306
  function getIsIOS() {
312
307
  var _a, _b;
313
- return isClient && ((_a = window == null ? void 0 : window.navigator) == null ? void 0 : _a.userAgent) && (/iP(?:ad|hone|od)/.test(window.navigator.userAgent) || ((_b = window == null ? void 0 : window.navigator) == null ? void 0 : _b.maxTouchPoints) > 2 && /iPad|Macintosh/.test(window == null ? void 0 : window.navigator.userAgent));
308
+ return isClient && ((_a = window == null ? undefined : window.navigator) == null ? undefined : _a.userAgent) && (/iP(?:ad|hone|od)/.test(window.navigator.userAgent) || ((_b = window == null ? undefined : window.navigator) == null ? undefined : _b.maxTouchPoints) > 2 && /iPad|Macintosh/.test(window == null ? undefined : window.navigator.userAgent));
314
309
  }
315
310
 
316
311
  function createFilterWrapper(filter, fn) {
@@ -334,11 +329,11 @@ function debounceFilter(ms, options = {}) {
334
329
  lastRejector = noop;
335
330
  };
336
331
  const filter = (invoke) => {
337
- const duration = toValue(ms);
338
- const maxDuration = toValue(options.maxWait);
332
+ const duration = vue.toValue(ms);
333
+ const maxDuration = vue.toValue(options.maxWait);
339
334
  if (timer)
340
335
  _clearTimeout(timer);
341
- if (duration <= 0 || maxDuration !== void 0 && maxDuration <= 0) {
336
+ if (duration <= 0 || maxDuration !== undefined && maxDuration <= 0) {
342
337
  if (maxTimer) {
343
338
  _clearTimeout(maxTimer);
344
339
  maxTimer = null;
@@ -382,13 +377,13 @@ function throttleFilter(...args) {
382
377
  const clear = () => {
383
378
  if (timer) {
384
379
  clearTimeout(timer);
385
- timer = void 0;
380
+ timer = undefined;
386
381
  lastRejector();
387
382
  lastRejector = noop;
388
383
  }
389
384
  };
390
385
  const filter = (_invoke) => {
391
- const duration = toValue(ms);
386
+ const duration = vue.toValue(ms);
392
387
  const elapsed = Date.now() - lastExec;
393
388
  const invoke = () => {
394
389
  return lastValue = _invoke();
@@ -468,7 +463,7 @@ function createSingletonPromise(fn) {
468
463
  }
469
464
  wrapper.reset = async () => {
470
465
  const _prev = _promise;
471
- _promise = void 0;
466
+ _promise = undefined;
472
467
  if (_prev)
473
468
  await _prev;
474
469
  };
@@ -484,7 +479,7 @@ function increaseWithUnit(target, delta) {
484
479
  var _a;
485
480
  if (typeof target === "number")
486
481
  return target + delta;
487
- const value = ((_a = target.match(/^-?\d+\.?\d*/)) == null ? void 0 : _a[0]) || "";
482
+ const value = ((_a = target.match(/^-?\d+\.?\d*/)) == null ? undefined : _a[0]) || "";
488
483
  const unit = target.slice(value.length);
489
484
  const result = Number.parseFloat(value) + delta;
490
485
  if (Number.isNaN(result))
@@ -497,7 +492,7 @@ function pxValue(px) {
497
492
  function objectPick(obj, keys, omitUndefined = false) {
498
493
  return keys.reduce((n, k) => {
499
494
  if (k in obj) {
500
- if (!omitUndefined || obj[k] !== void 0)
495
+ if (!omitUndefined || obj[k] !== undefined)
501
496
  n[k] = obj[k];
502
497
  }
503
498
  return n;
@@ -505,7 +500,7 @@ function objectPick(obj, keys, omitUndefined = false) {
505
500
  }
506
501
  function objectOmit(obj, keys, omitUndefined = false) {
507
502
  return Object.fromEntries(Object.entries(obj).filter(([key, value]) => {
508
- return (!omitUndefined || value !== void 0) && !keys.includes(key);
503
+ return (!omitUndefined || value !== undefined) && !keys.includes(key);
509
504
  }));
510
505
  }
511
506
  function objectEntries(obj) {
@@ -514,6 +509,9 @@ function objectEntries(obj) {
514
509
  function getLifeCycleTarget(target) {
515
510
  return target || vue.getCurrentInstance();
516
511
  }
512
+ function toArray(value) {
513
+ return Array.isArray(value) ? value : [value];
514
+ }
517
515
 
518
516
  function toRef(...args) {
519
517
  if (args.length !== 1)
@@ -526,17 +524,17 @@ const resolveRef = toRef;
526
524
  function reactivePick(obj, ...keys) {
527
525
  const flatKeys = keys.flat();
528
526
  const predicate = flatKeys[0];
529
- return reactiveComputed(() => typeof predicate === "function" ? Object.fromEntries(Object.entries(vue.toRefs(obj)).filter(([k, v]) => predicate(toValue(v), k))) : Object.fromEntries(flatKeys.map((k) => [k, toRef(obj, k)])));
527
+ return reactiveComputed(() => typeof predicate === "function" ? Object.fromEntries(Object.entries(vue.toRefs(obj)).filter(([k, v]) => predicate(vue.toValue(v), k))) : Object.fromEntries(flatKeys.map((k) => [k, toRef(obj, k)])));
530
528
  }
531
529
 
532
530
  function refAutoReset(defaultValue, afterMs = 1e4) {
533
531
  return vue.customRef((track, trigger) => {
534
- let value = toValue(defaultValue);
532
+ let value = vue.toValue(defaultValue);
535
533
  let timer;
536
534
  const resetAfter = () => setTimeout(() => {
537
- value = toValue(defaultValue);
535
+ value = vue.toValue(defaultValue);
538
536
  trigger();
539
- }, toValue(afterMs));
537
+ }, vue.toValue(afterMs));
540
538
  tryOnScopeDispose(() => {
541
539
  clearTimeout(timer);
542
540
  });
@@ -627,10 +625,10 @@ function refWithControl(initial, options = {}) {
627
625
  if (value === source)
628
626
  return;
629
627
  const old = source;
630
- if (((_a = options.onBeforeChange) == null ? void 0 : _a.call(options, value, old)) === false)
628
+ if (((_a = options.onBeforeChange) == null ? undefined : _a.call(options, value, old)) === false)
631
629
  return;
632
630
  source = value;
633
- (_b = options.onChanged) == null ? void 0 : _b.call(options, value, old);
631
+ (_b = options.onChanged) == null ? undefined : _b.call(options, value, old);
634
632
  if (triggering)
635
633
  trigger();
636
634
  }
@@ -741,8 +739,7 @@ function syncRefs(source, targets, options = {}) {
741
739
  deep = false,
742
740
  immediate = true
743
741
  } = options;
744
- if (!Array.isArray(targets))
745
- targets = [targets];
742
+ targets = toArray(targets);
746
743
  return vue.watch(
747
744
  source,
748
745
  (newValue) => targets.forEach((target) => target.value = newValue),
@@ -761,7 +758,7 @@ function toRefs(objectRef, options = {}) {
761
758
  },
762
759
  set(v) {
763
760
  var _a;
764
- const replaceRef = (_a = toValue(options.replaceRef)) != null ? _a : true;
761
+ const replaceRef = (_a = vue.toValue(options.replaceRef)) != null ? _a : true;
765
762
  if (replaceRef) {
766
763
  if (Array.isArray(objectRef.value)) {
767
764
  const copy = [...objectRef.value];
@@ -781,6 +778,9 @@ function toRefs(objectRef, options = {}) {
781
778
  return result;
782
779
  }
783
780
 
781
+ const toValue = vue.toValue;
782
+ const resolveUnref = vue.toValue;
783
+
784
784
  function tryOnBeforeMount(fn, sync = true, target) {
785
785
  const instance = getLifeCycleTarget(target);
786
786
  if (instance)
@@ -824,7 +824,7 @@ function createUntil(r, isNot = false) {
824
824
  if (stop)
825
825
  stop();
826
826
  else
827
- vue.nextTick(() => stop == null ? void 0 : stop());
827
+ vue.nextTick(() => stop == null ? undefined : stop());
828
828
  resolve(v);
829
829
  }
830
830
  },
@@ -838,7 +838,7 @@ function createUntil(r, isNot = false) {
838
838
  const promises = [watcher];
839
839
  if (timeout != null) {
840
840
  promises.push(
841
- promiseTimeout(timeout, throwOnTimeout).then(() => toValue(r)).finally(() => stop == null ? void 0 : stop())
841
+ promiseTimeout(timeout, throwOnTimeout).then(() => vue.toValue(r)).finally(() => stop == null ? undefined : stop())
842
842
  );
843
843
  }
844
844
  return Promise.race(promises);
@@ -856,7 +856,7 @@ function createUntil(r, isNot = false) {
856
856
  if (stop)
857
857
  stop();
858
858
  else
859
- vue.nextTick(() => stop == null ? void 0 : stop());
859
+ vue.nextTick(() => stop == null ? undefined : stop());
860
860
  resolve(v1);
861
861
  }
862
862
  },
@@ -870,9 +870,9 @@ function createUntil(r, isNot = false) {
870
870
  const promises = [watcher];
871
871
  if (timeout != null) {
872
872
  promises.push(
873
- promiseTimeout(timeout, throwOnTimeout).then(() => toValue(r)).finally(() => {
874
- stop == null ? void 0 : stop();
875
- return toValue(r);
873
+ promiseTimeout(timeout, throwOnTimeout).then(() => vue.toValue(r)).finally(() => {
874
+ stop == null ? undefined : stop();
875
+ return vue.toValue(r);
876
876
  })
877
877
  );
878
878
  }
@@ -885,7 +885,7 @@ function createUntil(r, isNot = false) {
885
885
  return toBe(null, options);
886
886
  }
887
887
  function toBeUndefined(options) {
888
- return toBe(void 0, options);
888
+ return toBe(undefined, options);
889
889
  }
890
890
  function toBeNaN(options) {
891
891
  return toMatch(Number.isNaN, options);
@@ -893,7 +893,7 @@ function createUntil(r, isNot = false) {
893
893
  function toContains(value, options) {
894
894
  return toMatch((v) => {
895
895
  const array = Array.from(v);
896
- return array.includes(value) || array.includes(toValue(value));
896
+ return array.includes(value) || array.includes(vue.toValue(value));
897
897
  }, options);
898
898
  }
899
899
  function changed(options) {
@@ -906,7 +906,7 @@ function createUntil(r, isNot = false) {
906
906
  return count >= n;
907
907
  }, options);
908
908
  }
909
- if (Array.isArray(toValue(r))) {
909
+ if (Array.isArray(vue.toValue(r))) {
910
910
  const instance = {
911
911
  toMatch,
912
912
  toContains,
@@ -953,31 +953,31 @@ function useArrayDifference(...args) {
953
953
  const key = compareFn;
954
954
  compareFn = (value, othVal) => value[key] === othVal[key];
955
955
  }
956
- const diff1 = vue.computed(() => toValue(list).filter((x) => toValue(values).findIndex((y) => compareFn(x, y)) === -1));
956
+ const diff1 = vue.computed(() => vue.toValue(list).filter((x) => vue.toValue(values).findIndex((y) => compareFn(x, y)) === -1));
957
957
  if (symmetric) {
958
- const diff2 = vue.computed(() => toValue(values).filter((x) => toValue(list).findIndex((y) => compareFn(x, y)) === -1));
959
- return vue.computed(() => symmetric ? [...toValue(diff1), ...toValue(diff2)] : toValue(diff1));
958
+ const diff2 = vue.computed(() => vue.toValue(values).filter((x) => vue.toValue(list).findIndex((y) => compareFn(x, y)) === -1));
959
+ return vue.computed(() => symmetric ? [...vue.toValue(diff1), ...vue.toValue(diff2)] : vue.toValue(diff1));
960
960
  } else {
961
961
  return diff1;
962
962
  }
963
963
  }
964
964
 
965
965
  function useArrayEvery(list, fn) {
966
- return vue.computed(() => toValue(list).every((element, index, array) => fn(toValue(element), index, array)));
966
+ return vue.computed(() => vue.toValue(list).every((element, index, array) => fn(vue.toValue(element), index, array)));
967
967
  }
968
968
 
969
969
  function useArrayFilter(list, fn) {
970
- return vue.computed(() => toValue(list).map((i) => toValue(i)).filter(fn));
970
+ return vue.computed(() => vue.toValue(list).map((i) => vue.toValue(i)).filter(fn));
971
971
  }
972
972
 
973
973
  function useArrayFind(list, fn) {
974
- return vue.computed(() => toValue(
975
- toValue(list).find((element, index, array) => fn(toValue(element), index, array))
974
+ return vue.computed(() => vue.toValue(
975
+ vue.toValue(list).find((element, index, array) => fn(vue.toValue(element), index, array))
976
976
  ));
977
977
  }
978
978
 
979
979
  function useArrayFindIndex(list, fn) {
980
- return vue.computed(() => toValue(list).findIndex((element, index, array) => fn(toValue(element), index, array)));
980
+ return vue.computed(() => vue.toValue(list).findIndex((element, index, array) => fn(vue.toValue(element), index, array)));
981
981
  }
982
982
 
983
983
  function findLast(arr, cb) {
@@ -986,11 +986,11 @@ function findLast(arr, cb) {
986
986
  if (cb(arr[index], index, arr))
987
987
  return arr[index];
988
988
  }
989
- return void 0;
989
+ return undefined;
990
990
  }
991
991
  function useArrayFindLast(list, fn) {
992
- return vue.computed(() => toValue(
993
- !Array.prototype.findLast ? findLast(toValue(list), (element, index, array) => fn(toValue(element), index, array)) : toValue(list).findLast((element, index, array) => fn(toValue(element), index, array))
992
+ return vue.computed(() => vue.toValue(
993
+ !Array.prototype.findLast ? findLast(vue.toValue(list), (element, index, array) => fn(vue.toValue(element), index, array)) : vue.toValue(list).findLast((element, index, array) => fn(vue.toValue(element), index, array))
994
994
  ));
995
995
  }
996
996
 
@@ -1009,35 +1009,35 @@ function useArrayIncludes(...args) {
1009
1009
  }
1010
1010
  if (typeof comparator === "string") {
1011
1011
  const key = comparator;
1012
- comparator = (element, value2) => element[key] === toValue(value2);
1012
+ comparator = (element, value2) => element[key] === vue.toValue(value2);
1013
1013
  }
1014
- comparator = comparator != null ? comparator : (element, value2) => element === toValue(value2);
1015
- return vue.computed(() => toValue(list).slice(formIndex).some((element, index, array) => comparator(
1016
- toValue(element),
1017
- toValue(value),
1014
+ comparator = comparator != null ? comparator : (element, value2) => element === vue.toValue(value2);
1015
+ return vue.computed(() => vue.toValue(list).slice(formIndex).some((element, index, array) => comparator(
1016
+ vue.toValue(element),
1017
+ vue.toValue(value),
1018
1018
  index,
1019
- toValue(array)
1019
+ vue.toValue(array)
1020
1020
  )));
1021
1021
  }
1022
1022
 
1023
1023
  function useArrayJoin(list, separator) {
1024
- return vue.computed(() => toValue(list).map((i) => toValue(i)).join(toValue(separator)));
1024
+ return vue.computed(() => vue.toValue(list).map((i) => vue.toValue(i)).join(vue.toValue(separator)));
1025
1025
  }
1026
1026
 
1027
1027
  function useArrayMap(list, fn) {
1028
- return vue.computed(() => toValue(list).map((i) => toValue(i)).map(fn));
1028
+ return vue.computed(() => vue.toValue(list).map((i) => vue.toValue(i)).map(fn));
1029
1029
  }
1030
1030
 
1031
1031
  function useArrayReduce(list, reducer, ...args) {
1032
- const reduceCallback = (sum, value, index) => reducer(toValue(sum), toValue(value), index);
1032
+ const reduceCallback = (sum, value, index) => reducer(vue.toValue(sum), vue.toValue(value), index);
1033
1033
  return vue.computed(() => {
1034
- const resolved = toValue(list);
1035
- return args.length ? resolved.reduce(reduceCallback, typeof args[0] === "function" ? toValue(args[0]()) : toValue(args[0])) : resolved.reduce(reduceCallback);
1034
+ const resolved = vue.toValue(list);
1035
+ return args.length ? resolved.reduce(reduceCallback, typeof args[0] === "function" ? vue.toValue(args[0]()) : vue.toValue(args[0])) : resolved.reduce(reduceCallback);
1036
1036
  });
1037
1037
  }
1038
1038
 
1039
1039
  function useArraySome(list, fn) {
1040
- return vue.computed(() => toValue(list).some((element, index, array) => fn(toValue(element), index, array)));
1040
+ return vue.computed(() => vue.toValue(list).some((element, index, array) => fn(vue.toValue(element), index, array)));
1041
1041
  }
1042
1042
 
1043
1043
  function uniq(array) {
@@ -1052,7 +1052,7 @@ function uniqueElementsBy(array, fn) {
1052
1052
  }
1053
1053
  function useArrayUnique(list, compareFn) {
1054
1054
  return vue.computed(() => {
1055
- const resolvedList = toValue(list).map((element) => toValue(element));
1055
+ const resolvedList = vue.toValue(list).map((element) => vue.toValue(element));
1056
1056
  return compareFn ? uniqueElementsBy(resolvedList, compareFn) : uniq(resolvedList);
1057
1057
  });
1058
1058
  }
@@ -1106,8 +1106,8 @@ function formatDate(date, formatStr, options = {}) {
1106
1106
  M: () => month + 1,
1107
1107
  Mo: () => formatOrdinal(month + 1),
1108
1108
  MM: () => `${month + 1}`.padStart(2, "0"),
1109
- MMM: () => date.toLocaleDateString(toValue(options.locales), { month: "short" }),
1110
- MMMM: () => date.toLocaleDateString(toValue(options.locales), { month: "long" }),
1109
+ MMM: () => date.toLocaleDateString(vue.toValue(options.locales), { month: "short" }),
1110
+ MMMM: () => date.toLocaleDateString(vue.toValue(options.locales), { month: "long" }),
1111
1111
  D: () => String(days),
1112
1112
  Do: () => formatOrdinal(days),
1113
1113
  DD: () => `${days}`.padStart(2, "0"),
@@ -1125,9 +1125,9 @@ function formatDate(date, formatStr, options = {}) {
1125
1125
  ss: () => `${seconds}`.padStart(2, "0"),
1126
1126
  SSS: () => `${milliseconds}`.padStart(3, "0"),
1127
1127
  d: () => day,
1128
- dd: () => date.toLocaleDateString(toValue(options.locales), { weekday: "narrow" }),
1129
- ddd: () => date.toLocaleDateString(toValue(options.locales), { weekday: "short" }),
1130
- dddd: () => date.toLocaleDateString(toValue(options.locales), { weekday: "long" }),
1128
+ dd: () => date.toLocaleDateString(vue.toValue(options.locales), { weekday: "narrow" }),
1129
+ ddd: () => date.toLocaleDateString(vue.toValue(options.locales), { weekday: "short" }),
1130
+ dddd: () => date.toLocaleDateString(vue.toValue(options.locales), { weekday: "long" }),
1131
1131
  A: () => meridiem(hours, minutes),
1132
1132
  AA: () => meridiem(hours, minutes, false, true),
1133
1133
  a: () => meridiem(hours, minutes, true),
@@ -1135,13 +1135,13 @@ function formatDate(date, formatStr, options = {}) {
1135
1135
  };
1136
1136
  return formatStr.replace(REGEX_FORMAT, (match, $1) => {
1137
1137
  var _a2, _b;
1138
- return (_b = $1 != null ? $1 : (_a2 = matches[match]) == null ? void 0 : _a2.call(matches)) != null ? _b : match;
1138
+ return (_b = $1 != null ? $1 : (_a2 = matches[match]) == null ? undefined : _a2.call(matches)) != null ? _b : match;
1139
1139
  });
1140
1140
  }
1141
1141
  function normalizeDate(date) {
1142
1142
  if (date === null)
1143
1143
  return new Date(Number.NaN);
1144
- if (date === void 0)
1144
+ if (date === undefined)
1145
1145
  return /* @__PURE__ */ new Date();
1146
1146
  if (date instanceof Date)
1147
1147
  return new Date(date);
@@ -1156,7 +1156,7 @@ function normalizeDate(date) {
1156
1156
  return new Date(date);
1157
1157
  }
1158
1158
  function useDateFormat(date, formatStr = "HH:mm:ss", options = {}) {
1159
- return vue.computed(() => formatDate(normalizeDate(toValue(date)), toValue(formatStr), options));
1159
+ return vue.computed(() => formatDate(normalizeDate(vue.toValue(date)), vue.toValue(formatStr), options));
1160
1160
  }
1161
1161
 
1162
1162
  function useIntervalFn(cb, interval = 1e3, options = {}) {
@@ -1177,7 +1177,7 @@ function useIntervalFn(cb, interval = 1e3, options = {}) {
1177
1177
  clean();
1178
1178
  }
1179
1179
  function resume() {
1180
- const intervalValue = toValue(interval);
1180
+ const intervalValue = vue.toValue(interval);
1181
1181
  if (intervalValue <= 0)
1182
1182
  return;
1183
1183
  isActive.value = true;
@@ -1268,7 +1268,7 @@ function useTimeoutFn(cb, interval, options = {}) {
1268
1268
  isPending.value = false;
1269
1269
  timer = null;
1270
1270
  cb(...args);
1271
- }, toValue(interval));
1271
+ }, vue.toValue(interval));
1272
1272
  }
1273
1273
  if (immediate) {
1274
1274
  isPending.value = true;
@@ -1311,8 +1311,10 @@ function useToNumber(value, options = {}) {
1311
1311
  nanToZero
1312
1312
  } = options;
1313
1313
  return vue.computed(() => {
1314
- let resolved = toValue(value);
1315
- if (typeof resolved === "string")
1314
+ let resolved = vue.toValue(value);
1315
+ if (typeof method === "function")
1316
+ resolved = method(resolved);
1317
+ else if (typeof resolved === "string")
1316
1318
  resolved = Number[method](resolved, radix);
1317
1319
  if (nanToZero && Number.isNaN(resolved))
1318
1320
  resolved = 0;
@@ -1321,7 +1323,7 @@ function useToNumber(value, options = {}) {
1321
1323
  }
1322
1324
 
1323
1325
  function useToString(value) {
1324
- return vue.computed(() => `${toValue(value)}`);
1326
+ return vue.computed(() => `${vue.toValue(value)}`);
1325
1327
  }
1326
1328
 
1327
1329
  function useToggle(initialValue = false, options = {}) {
@@ -1336,8 +1338,8 @@ function useToggle(initialValue = false, options = {}) {
1336
1338
  _value.value = value;
1337
1339
  return _value.value;
1338
1340
  } else {
1339
- const truthy = toValue(truthyValue);
1340
- _value.value = _value.value === truthy ? toValue(falsyValue) : truthy;
1341
+ const truthy = vue.toValue(truthyValue);
1342
+ _value.value = _value.value === truthy ? vue.toValue(falsyValue) : truthy;
1341
1343
  return _value.value;
1342
1344
  }
1343
1345
  }
@@ -1348,7 +1350,7 @@ function useToggle(initialValue = false, options = {}) {
1348
1350
  }
1349
1351
 
1350
1352
  function watchArray(source, cb, options) {
1351
- let oldList = (options == null ? void 0 : options.immediate) ? [] : [...source instanceof Function ? source() : Array.isArray(source) ? source : toValue(source)];
1353
+ let oldList = (options == null ? undefined : options.immediate) ? [] : [...source instanceof Function ? source() : Array.isArray(source) ? source : vue.toValue(source)];
1352
1354
  return vue.watch(source, (newList, _, onCleanup) => {
1353
1355
  const oldListRemains = Array.from({ length: oldList.length });
1354
1356
  const added = [];
@@ -1380,7 +1382,7 @@ function watchAtMost(source, cb, options) {
1380
1382
  source,
1381
1383
  (...args) => {
1382
1384
  current.value += 1;
1383
- if (current.value >= toValue(count))
1385
+ if (current.value >= vue.toValue(count))
1384
1386
  vue.nextTick(() => stop());
1385
1387
  cb(...args);
1386
1388
  },
@@ -1392,7 +1394,7 @@ function watchAtMost(source, cb, options) {
1392
1394
  function watchDebounced(source, cb, options = {}) {
1393
1395
  const {
1394
1396
  debounce = 0,
1395
- maxWait = void 0,
1397
+ maxWait = undefined,
1396
1398
  ...watchOptions
1397
1399
  } = options;
1398
1400
  return watchWithFilter(
@@ -1529,7 +1531,7 @@ function watchTriggerable(source, cb, options = {}) {
1529
1531
  if (!cleanupFn)
1530
1532
  return;
1531
1533
  const fn = cleanupFn;
1532
- cleanupFn = void 0;
1534
+ cleanupFn = undefined;
1533
1535
  fn();
1534
1536
  }
1535
1537
  function onCleanup(callback) {
@@ -1557,11 +1559,11 @@ function getWatchSources(sources) {
1557
1559
  if (vue.isReactive(sources))
1558
1560
  return sources;
1559
1561
  if (Array.isArray(sources))
1560
- return sources.map((item) => toValue(item));
1561
- return toValue(sources);
1562
+ return sources.map((item) => vue.toValue(item));
1563
+ return vue.toValue(sources);
1562
1564
  }
1563
1565
  function getOldValue(source) {
1564
- return Array.isArray(source) ? source.map(() => void 0) : void 0;
1566
+ return Array.isArray(source) ? source.map(() => undefined) : undefined;
1565
1567
  }
1566
1568
 
1567
1569
  function whenever(source, cb, options) {
@@ -1569,7 +1571,7 @@ function whenever(source, cb, options) {
1569
1571
  source,
1570
1572
  (v, ov, onInvalidate) => {
1571
1573
  if (v) {
1572
- if (options == null ? void 0 : options.once)
1574
+ if (options == null ? undefined : options.once)
1573
1575
  vue.nextTick(() => stop());
1574
1576
  cb(v, ov, onInvalidate);
1575
1577
  }
@@ -1653,6 +1655,7 @@ exports.throttleFilter = throttleFilter;
1653
1655
  exports.throttledRef = refThrottled;
1654
1656
  exports.throttledWatch = watchThrottled;
1655
1657
  exports.timestamp = timestamp;
1658
+ exports.toArray = toArray;
1656
1659
  exports.toReactive = toReactive;
1657
1660
  exports.toRef = toRef;
1658
1661
  exports.toRefs = toRefs;
package/index.d.cts CHANGED
@@ -1,5 +1,5 @@
1
1
  import * as vue from 'vue';
2
- import { WatchOptionsBase, Ref, ComputedRef, WritableComputedRef, WatchSource, ComputedGetter, WritableComputedOptions, MaybeRef, WatchOptions, MaybeRefOrGetter, InjectionKey, ShallowUnwrapRef as ShallowUnwrapRef$1, inject, provide, UnwrapNestedRefs, UnwrapRef, ToRef, ToRefs, WatchCallback, WatchStopHandle } from 'vue';
2
+ import { WatchOptionsBase, Ref, ComputedRef, WritableComputedRef, WatchSource, ComputedGetter, WritableComputedOptions, MaybeRef, WatchOptions, MaybeRefOrGetter, InjectionKey, ShallowUnwrapRef as ShallowUnwrapRef$1, inject, provide, UnwrapNestedRefs, UnwrapRef, ToRef, ToRefs, toValue as toValue$1, WatchCallback, WatchStopHandle } from 'vue';
3
3
  export { MaybeRef, MaybeRefOrGetter } from 'vue';
4
4
 
5
5
  /**
@@ -301,6 +301,7 @@ declare function objectPick<O extends object, T extends keyof O>(obj: O, keys: T
301
301
  declare function objectOmit<O extends object, T extends keyof O>(obj: O, keys: T[], omitUndefined?: boolean): Omit<O, T>;
302
302
  declare function objectEntries<T extends object>(obj: T): Array<[keyof T, T[keyof T]]>;
303
303
  declare function getLifeCycleTarget(target?: any): any;
304
+ declare function toArray<T>(value: T): T extends readonly any[] ? T : [T];
304
305
 
305
306
  /**
306
307
  * Keep states in the global scope to be reusable across Vue instances.
@@ -644,12 +645,14 @@ declare function toRefs<T extends object>(objectRef: MaybeRef<T>, options?: ToRe
644
645
 
645
646
  /**
646
647
  * Get the value of value/ref/getter.
648
+ *
649
+ * @deprecated use `toValue` from `vue` instead
647
650
  */
648
- declare function toValue<T>(r: MaybeRefOrGetter<T>): T;
651
+ declare const toValue: typeof toValue$1;
649
652
  /**
650
653
  * @deprecated use `toValue` instead
651
654
  */
652
- declare const resolveUnref: typeof toValue;
655
+ declare const resolveUnref: typeof toValue$1;
653
656
 
654
657
  /**
655
658
  * Call onBeforeMount() if it's inside a component lifecycle, if not, just call the function
@@ -1091,9 +1094,11 @@ interface UseToNumberOptions {
1091
1094
  /**
1092
1095
  * Method to use to convert the value to a number.
1093
1096
  *
1097
+ * Or a custom function for the conversion.
1098
+ *
1094
1099
  * @default 'parseFloat'
1095
1100
  */
1096
- method?: 'parseFloat' | 'parseInt';
1101
+ method?: 'parseFloat' | 'parseInt' | ((value: string | number) => number);
1097
1102
  /**
1098
1103
  * The base in mathematical numeral systems passed to `parseInt`.
1099
1104
  * Only works with `method: 'parseInt'`
@@ -1220,4 +1225,4 @@ interface WheneverOptions extends WatchOptions {
1220
1225
  */
1221
1226
  declare function whenever<T>(source: WatchSource<T | false | null | undefined>, cb: WatchCallback<T>, options?: WheneverOptions): vue.WatchHandle;
1222
1227
 
1223
- export { type AnyFn, type ArgumentsType, type Arrayable, type Awaitable, type Awaited, type ComputedRefWithControl, type ComputedWithControlRefExtra, type ConfigurableEventFilter, type ConfigurableFlush, type ConfigurableFlushSync, type ControlledRefOptions, type CreateInjectionStateOptions, type DateLike, type DebounceFilterOptions, type DeepMaybeRef, type ElementOf, type EventFilter, type EventHook, type EventHookOff, type EventHookOn, type EventHookTrigger, type ExtendRefOptions, type Fn, type FunctionArgs, type FunctionWrapperOptions, type IfAny, type IgnoredUpdater, type IsAny, type MapOldSources, type MapSources, type MultiWatchSources, type Mutable, type Pausable, type Promisify, type PromisifyFn, type Reactified, type ReactifyNested, type ReactifyObjectOptions, type ReactifyOptions, type ReactiveOmitPredicate, type ReactivePickPredicate, type ReadonlyRefOrGetter, type RemovableRef, type ShallowUnwrapRef, type SingletonPromiseReturn, type Stoppable, type SyncRefOptions, type SyncRefsOptions, type ThrottleFilterOptions, type ToRefsOptions, type UntilArrayInstance, type UntilBaseInstance, type UntilToMatchOptions, type UntilValueInstance, type UseArrayDifferenceOptions, type UseArrayIncludesComparatorFn, type UseArrayIncludesOptions, type UseArrayReducer, type UseCounterOptions, type UseDateFormatOptions, type UseDateFormatReturn, type UseIntervalControls, type UseIntervalFnOptions, type UseIntervalOptions, type UseLastChangedOptions, type UseTimeoutFnOptions, type UseTimeoutOptions, type UseToNumberOptions, type UseToggleOptions, type WatchArrayCallback, type WatchAtMostOptions, type WatchAtMostReturn, type WatchDebouncedOptions, type WatchIgnorableReturn, type WatchPausableReturn, type WatchThrottledOptions, type WatchTriggerableCallback, type WatchTriggerableReturn, type WatchWithFilterOptions, type WheneverOptions, type WritableComputedRefWithControl, assert, refAutoReset as autoResetRef, bypassFilter, camelize, clamp, computedEager, computedWithControl, containsProp, computedWithControl as controlledComputed, controlledRef, createEventHook, createFilterWrapper, createGlobalState, createInjectionState, reactify as createReactiveFn, createSharedComposable, createSingletonPromise, debounceFilter, refDebounced as debouncedRef, watchDebounced as debouncedWatch, computedEager as eagerComputed, extendRef, formatDate, get, getLifeCycleTarget, hasOwn, hyphenate, identity, watchIgnorable as ignorableWatch, increaseWithUnit, injectLocal, invoke, isClient, isDef, isDefined, isIOS, isObject, isWorker, makeDestructurable, noop, normalizeDate, notNullish, now, objectEntries, objectOmit, objectPick, pausableFilter, watchPausable as pausableWatch, promiseTimeout, provideLocal, pxValue, rand, reactify, reactifyObject, reactiveComputed, reactiveOmit, reactivePick, refAutoReset, refDebounced, refDefault, refThrottled, refWithControl, resolveRef, resolveUnref, set, syncRef, syncRefs, throttleFilter, refThrottled as throttledRef, watchThrottled as throttledWatch, timestamp, toReactive, toRef, toRefs, toValue, tryOnBeforeMount, tryOnBeforeUnmount, tryOnMounted, tryOnScopeDispose, tryOnUnmounted, until, useArrayDifference, useArrayEvery, useArrayFilter, useArrayFind, useArrayFindIndex, useArrayFindLast, useArrayIncludes, useArrayJoin, useArrayMap, useArrayReduce, useArraySome, useArrayUnique, useCounter, useDateFormat, refDebounced as useDebounce, useDebounceFn, useInterval, useIntervalFn, useLastChanged, refThrottled as useThrottle, useThrottleFn, useTimeout, useTimeoutFn, useToNumber, useToString, useToggle, watchArray, watchAtMost, watchDebounced, watchDeep, watchIgnorable, watchImmediate, watchOnce, watchPausable, watchThrottled, watchTriggerable, watchWithFilter, whenever };
1228
+ export { type AnyFn, type ArgumentsType, type Arrayable, type Awaitable, type Awaited, type ComputedRefWithControl, type ComputedWithControlRefExtra, type ConfigurableEventFilter, type ConfigurableFlush, type ConfigurableFlushSync, type ControlledRefOptions, type CreateInjectionStateOptions, type DateLike, type DebounceFilterOptions, type DeepMaybeRef, type ElementOf, type EventFilter, type EventHook, type EventHookOff, type EventHookOn, type EventHookTrigger, type ExtendRefOptions, type Fn, type FunctionArgs, type FunctionWrapperOptions, type IfAny, type IgnoredUpdater, type IsAny, type MapOldSources, type MapSources, type MultiWatchSources, type Mutable, type Pausable, type Promisify, type PromisifyFn, type Reactified, type ReactifyNested, type ReactifyObjectOptions, type ReactifyOptions, type ReactiveOmitPredicate, type ReactivePickPredicate, type ReadonlyRefOrGetter, type RemovableRef, type ShallowUnwrapRef, type SingletonPromiseReturn, type Stoppable, type SyncRefOptions, type SyncRefsOptions, type ThrottleFilterOptions, type ToRefsOptions, type UntilArrayInstance, type UntilBaseInstance, type UntilToMatchOptions, type UntilValueInstance, type UseArrayDifferenceOptions, type UseArrayIncludesComparatorFn, type UseArrayIncludesOptions, type UseArrayReducer, type UseCounterOptions, type UseDateFormatOptions, type UseDateFormatReturn, type UseIntervalControls, type UseIntervalFnOptions, type UseIntervalOptions, type UseLastChangedOptions, type UseTimeoutFnOptions, type UseTimeoutOptions, type UseToNumberOptions, type UseToggleOptions, type WatchArrayCallback, type WatchAtMostOptions, type WatchAtMostReturn, type WatchDebouncedOptions, type WatchIgnorableReturn, type WatchPausableReturn, type WatchThrottledOptions, type WatchTriggerableCallback, type WatchTriggerableReturn, type WatchWithFilterOptions, type WheneverOptions, type WritableComputedRefWithControl, assert, refAutoReset as autoResetRef, bypassFilter, camelize, clamp, computedEager, computedWithControl, containsProp, computedWithControl as controlledComputed, controlledRef, createEventHook, createFilterWrapper, createGlobalState, createInjectionState, reactify as createReactiveFn, createSharedComposable, createSingletonPromise, debounceFilter, refDebounced as debouncedRef, watchDebounced as debouncedWatch, computedEager as eagerComputed, extendRef, formatDate, get, getLifeCycleTarget, hasOwn, hyphenate, identity, watchIgnorable as ignorableWatch, increaseWithUnit, injectLocal, invoke, isClient, isDef, isDefined, isIOS, isObject, isWorker, makeDestructurable, noop, normalizeDate, notNullish, now, objectEntries, objectOmit, objectPick, pausableFilter, watchPausable as pausableWatch, promiseTimeout, provideLocal, pxValue, rand, reactify, reactifyObject, reactiveComputed, reactiveOmit, reactivePick, refAutoReset, refDebounced, refDefault, refThrottled, refWithControl, resolveRef, resolveUnref, set, syncRef, syncRefs, throttleFilter, refThrottled as throttledRef, watchThrottled as throttledWatch, timestamp, toArray, toReactive, toRef, toRefs, toValue, tryOnBeforeMount, tryOnBeforeUnmount, tryOnMounted, tryOnScopeDispose, tryOnUnmounted, until, useArrayDifference, useArrayEvery, useArrayFilter, useArrayFind, useArrayFindIndex, useArrayFindLast, useArrayIncludes, useArrayJoin, useArrayMap, useArrayReduce, useArraySome, useArrayUnique, useCounter, useDateFormat, refDebounced as useDebounce, useDebounceFn, useInterval, useIntervalFn, useLastChanged, refThrottled as useThrottle, useThrottleFn, useTimeout, useTimeoutFn, useToNumber, useToString, useToggle, watchArray, watchAtMost, watchDebounced, watchDeep, watchIgnorable, watchImmediate, watchOnce, watchPausable, watchThrottled, watchTriggerable, watchWithFilter, whenever };