@vueuse/shared 10.0.0-beta.4 → 10.0.0-beta.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/index.cjs +219 -234
- package/index.d.ts +1 -8
- package/index.iife.js +219 -234
- package/index.iife.min.js +1 -1
- package/index.mjs +221 -229
- package/package.json +2 -2
package/index.cjs
CHANGED
|
@@ -32,228 +32,6 @@ function computedEager(fn, options) {
|
|
|
32
32
|
return vueDemi.readonly(result);
|
|
33
33
|
}
|
|
34
34
|
|
|
35
|
-
var _a;
|
|
36
|
-
const isClient = typeof window !== "undefined";
|
|
37
|
-
const isDef = (val) => typeof val !== "undefined";
|
|
38
|
-
const assert = (condition, ...infos) => {
|
|
39
|
-
if (!condition)
|
|
40
|
-
console.warn(...infos);
|
|
41
|
-
};
|
|
42
|
-
const toString = Object.prototype.toString;
|
|
43
|
-
const isBoolean = (val) => typeof val === "boolean";
|
|
44
|
-
const isFunction = (val) => typeof val === "function";
|
|
45
|
-
const isNumber = (val) => typeof val === "number";
|
|
46
|
-
const isString = (val) => typeof val === "string";
|
|
47
|
-
const isObject = (val) => toString.call(val) === "[object Object]";
|
|
48
|
-
const isWindow = (val) => typeof window !== "undefined" && toString.call(val) === "[object Window]";
|
|
49
|
-
const now = () => Date.now();
|
|
50
|
-
const timestamp = () => +Date.now();
|
|
51
|
-
const clamp = (n, min, max) => Math.min(max, Math.max(min, n));
|
|
52
|
-
const noop = () => {
|
|
53
|
-
};
|
|
54
|
-
const rand = (min, max) => {
|
|
55
|
-
min = Math.ceil(min);
|
|
56
|
-
max = Math.floor(max);
|
|
57
|
-
return Math.floor(Math.random() * (max - min + 1)) + min;
|
|
58
|
-
};
|
|
59
|
-
const hasOwn = (val, key) => Object.prototype.hasOwnProperty.call(val, key);
|
|
60
|
-
const isIOS = isClient && ((_a = window == null ? void 0 : window.navigator) == null ? void 0 : _a.userAgent) && /iP(ad|hone|od)/.test(window.navigator.userAgent);
|
|
61
|
-
|
|
62
|
-
function toValue(r) {
|
|
63
|
-
return typeof r === "function" ? r() : vueDemi.unref(r);
|
|
64
|
-
}
|
|
65
|
-
const resolveUnref = toValue;
|
|
66
|
-
|
|
67
|
-
function createFilterWrapper(filter, fn) {
|
|
68
|
-
function wrapper(...args) {
|
|
69
|
-
return new Promise((resolve, reject) => {
|
|
70
|
-
Promise.resolve(filter(() => fn.apply(this, args), { fn, thisArg: this, args })).then(resolve).catch(reject);
|
|
71
|
-
});
|
|
72
|
-
}
|
|
73
|
-
return wrapper;
|
|
74
|
-
}
|
|
75
|
-
const bypassFilter = (invoke) => {
|
|
76
|
-
return invoke();
|
|
77
|
-
};
|
|
78
|
-
function debounceFilter(ms, options = {}) {
|
|
79
|
-
let timer;
|
|
80
|
-
let maxTimer;
|
|
81
|
-
let lastRejector = noop;
|
|
82
|
-
const _clearTimeout = (timer2) => {
|
|
83
|
-
clearTimeout(timer2);
|
|
84
|
-
lastRejector();
|
|
85
|
-
lastRejector = noop;
|
|
86
|
-
};
|
|
87
|
-
const filter = (invoke) => {
|
|
88
|
-
const duration = toValue(ms);
|
|
89
|
-
const maxDuration = toValue(options.maxWait);
|
|
90
|
-
if (timer)
|
|
91
|
-
_clearTimeout(timer);
|
|
92
|
-
if (duration <= 0 || maxDuration !== void 0 && maxDuration <= 0) {
|
|
93
|
-
if (maxTimer) {
|
|
94
|
-
_clearTimeout(maxTimer);
|
|
95
|
-
maxTimer = null;
|
|
96
|
-
}
|
|
97
|
-
return Promise.resolve(invoke());
|
|
98
|
-
}
|
|
99
|
-
return new Promise((resolve, reject) => {
|
|
100
|
-
lastRejector = options.rejectOnCancel ? reject : resolve;
|
|
101
|
-
if (maxDuration && !maxTimer) {
|
|
102
|
-
maxTimer = setTimeout(() => {
|
|
103
|
-
if (timer)
|
|
104
|
-
_clearTimeout(timer);
|
|
105
|
-
maxTimer = null;
|
|
106
|
-
resolve(invoke());
|
|
107
|
-
}, maxDuration);
|
|
108
|
-
}
|
|
109
|
-
timer = setTimeout(() => {
|
|
110
|
-
if (maxTimer)
|
|
111
|
-
_clearTimeout(maxTimer);
|
|
112
|
-
maxTimer = null;
|
|
113
|
-
resolve(invoke());
|
|
114
|
-
}, duration);
|
|
115
|
-
});
|
|
116
|
-
};
|
|
117
|
-
return filter;
|
|
118
|
-
}
|
|
119
|
-
function throttleFilter(ms, trailing = true, leading = true, rejectOnCancel = false) {
|
|
120
|
-
let lastExec = 0;
|
|
121
|
-
let timer;
|
|
122
|
-
let isLeading = true;
|
|
123
|
-
let lastRejector = noop;
|
|
124
|
-
let lastValue;
|
|
125
|
-
const clear = () => {
|
|
126
|
-
if (timer) {
|
|
127
|
-
clearTimeout(timer);
|
|
128
|
-
timer = void 0;
|
|
129
|
-
lastRejector();
|
|
130
|
-
lastRejector = noop;
|
|
131
|
-
}
|
|
132
|
-
};
|
|
133
|
-
const filter = (_invoke) => {
|
|
134
|
-
const duration = toValue(ms);
|
|
135
|
-
const elapsed = Date.now() - lastExec;
|
|
136
|
-
const invoke = () => {
|
|
137
|
-
return lastValue = _invoke();
|
|
138
|
-
};
|
|
139
|
-
clear();
|
|
140
|
-
if (duration <= 0) {
|
|
141
|
-
lastExec = Date.now();
|
|
142
|
-
return invoke();
|
|
143
|
-
}
|
|
144
|
-
if (elapsed > duration && (leading || !isLeading)) {
|
|
145
|
-
lastExec = Date.now();
|
|
146
|
-
invoke();
|
|
147
|
-
} else if (trailing) {
|
|
148
|
-
lastValue = new Promise((resolve, reject) => {
|
|
149
|
-
lastRejector = rejectOnCancel ? reject : resolve;
|
|
150
|
-
timer = setTimeout(() => {
|
|
151
|
-
lastExec = Date.now();
|
|
152
|
-
isLeading = true;
|
|
153
|
-
resolve(invoke());
|
|
154
|
-
clear();
|
|
155
|
-
}, Math.max(0, duration - elapsed));
|
|
156
|
-
});
|
|
157
|
-
}
|
|
158
|
-
if (!leading && !timer)
|
|
159
|
-
timer = setTimeout(() => isLeading = true, duration);
|
|
160
|
-
isLeading = false;
|
|
161
|
-
return lastValue;
|
|
162
|
-
};
|
|
163
|
-
return filter;
|
|
164
|
-
}
|
|
165
|
-
function pausableFilter(extendFilter = bypassFilter) {
|
|
166
|
-
const isActive = vueDemi.ref(true);
|
|
167
|
-
function pause() {
|
|
168
|
-
isActive.value = false;
|
|
169
|
-
}
|
|
170
|
-
function resume() {
|
|
171
|
-
isActive.value = true;
|
|
172
|
-
}
|
|
173
|
-
const eventFilter = (...args) => {
|
|
174
|
-
if (isActive.value)
|
|
175
|
-
extendFilter(...args);
|
|
176
|
-
};
|
|
177
|
-
return { isActive: vueDemi.readonly(isActive), pause, resume, eventFilter };
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
function __onlyVue3(name = "this function") {
|
|
181
|
-
if (vueDemi.isVue3)
|
|
182
|
-
return;
|
|
183
|
-
throw new Error(`[VueUse] ${name} is only works on Vue 3.`);
|
|
184
|
-
}
|
|
185
|
-
function __onlyVue27Plus(name = "this function") {
|
|
186
|
-
if (vueDemi.isVue3 || vueDemi.version.startsWith("2.7."))
|
|
187
|
-
return;
|
|
188
|
-
throw new Error(`[VueUse] ${name} is only works on Vue 2.7 or above.`);
|
|
189
|
-
}
|
|
190
|
-
const directiveHooks = {
|
|
191
|
-
mounted: vueDemi.isVue3 ? "mounted" : "inserted",
|
|
192
|
-
updated: vueDemi.isVue3 ? "updated" : "componentUpdated",
|
|
193
|
-
unmounted: vueDemi.isVue3 ? "unmounted" : "unbind"
|
|
194
|
-
};
|
|
195
|
-
|
|
196
|
-
function promiseTimeout(ms, throwOnTimeout = false, reason = "Timeout") {
|
|
197
|
-
return new Promise((resolve, reject) => {
|
|
198
|
-
if (throwOnTimeout)
|
|
199
|
-
setTimeout(() => reject(reason), ms);
|
|
200
|
-
else
|
|
201
|
-
setTimeout(resolve, ms);
|
|
202
|
-
});
|
|
203
|
-
}
|
|
204
|
-
function identity(arg) {
|
|
205
|
-
return arg;
|
|
206
|
-
}
|
|
207
|
-
function createSingletonPromise(fn) {
|
|
208
|
-
let _promise;
|
|
209
|
-
function wrapper() {
|
|
210
|
-
if (!_promise)
|
|
211
|
-
_promise = fn();
|
|
212
|
-
return _promise;
|
|
213
|
-
}
|
|
214
|
-
wrapper.reset = async () => {
|
|
215
|
-
const _prev = _promise;
|
|
216
|
-
_promise = void 0;
|
|
217
|
-
if (_prev)
|
|
218
|
-
await _prev;
|
|
219
|
-
};
|
|
220
|
-
return wrapper;
|
|
221
|
-
}
|
|
222
|
-
function invoke(fn) {
|
|
223
|
-
return fn();
|
|
224
|
-
}
|
|
225
|
-
function containsProp(obj, ...props) {
|
|
226
|
-
return props.some((k) => k in obj);
|
|
227
|
-
}
|
|
228
|
-
function increaseWithUnit(target, delta) {
|
|
229
|
-
var _a;
|
|
230
|
-
if (typeof target === "number")
|
|
231
|
-
return target + delta;
|
|
232
|
-
const value = ((_a = target.match(/^-?[0-9]+\.?[0-9]*/)) == null ? void 0 : _a[0]) || "";
|
|
233
|
-
const unit = target.slice(value.length);
|
|
234
|
-
const result = parseFloat(value) + delta;
|
|
235
|
-
if (Number.isNaN(result))
|
|
236
|
-
return target;
|
|
237
|
-
return result + unit;
|
|
238
|
-
}
|
|
239
|
-
function objectPick(obj, keys, omitUndefined = false) {
|
|
240
|
-
return keys.reduce((n, k) => {
|
|
241
|
-
if (k in obj) {
|
|
242
|
-
if (!omitUndefined || obj[k] !== void 0)
|
|
243
|
-
n[k] = obj[k];
|
|
244
|
-
}
|
|
245
|
-
return n;
|
|
246
|
-
}, {});
|
|
247
|
-
}
|
|
248
|
-
function objectOmit(obj, keys, omitUndefined = false) {
|
|
249
|
-
return Object.fromEntries(Object.entries(obj).filter(([key, value]) => {
|
|
250
|
-
return (!omitUndefined || value !== void 0) && !keys.includes(key);
|
|
251
|
-
}));
|
|
252
|
-
}
|
|
253
|
-
function objectEntries(obj) {
|
|
254
|
-
return Object.entries(obj);
|
|
255
|
-
}
|
|
256
|
-
|
|
257
35
|
function computedWithControl(source, fn) {
|
|
258
36
|
let v = void 0;
|
|
259
37
|
let track;
|
|
@@ -264,8 +42,8 @@ function computedWithControl(source, fn) {
|
|
|
264
42
|
trigger();
|
|
265
43
|
};
|
|
266
44
|
vueDemi.watch(source, update, { flush: "sync" });
|
|
267
|
-
const get =
|
|
268
|
-
const set =
|
|
45
|
+
const get = typeof fn === "function" ? fn : fn.get;
|
|
46
|
+
const set = typeof fn === "function" ? void 0 : fn.set;
|
|
269
47
|
const result = vueDemi.customRef((_track, _trigger) => {
|
|
270
48
|
track = _track;
|
|
271
49
|
trigger = _trigger;
|
|
@@ -367,7 +145,11 @@ function createSharedComposable(composable) {
|
|
|
367
145
|
}
|
|
368
146
|
|
|
369
147
|
function extendRef(ref, extend, { enumerable = false, unwrap = true } = {}) {
|
|
370
|
-
|
|
148
|
+
if (!vueDemi.isVue3 && !vueDemi.version.startsWith("2.7.")) {
|
|
149
|
+
if (process.env.NODE_ENV !== "production")
|
|
150
|
+
throw new Error("[VueUse] extendRef only works in Vue 2.7 or above.");
|
|
151
|
+
return;
|
|
152
|
+
}
|
|
371
153
|
for (const [key, value] of Object.entries(extend)) {
|
|
372
154
|
if (key === "value")
|
|
373
155
|
continue;
|
|
@@ -435,6 +217,11 @@ function makeDestructurable(obj, arr) {
|
|
|
435
217
|
}
|
|
436
218
|
}
|
|
437
219
|
|
|
220
|
+
function toValue(r) {
|
|
221
|
+
return typeof r === "function" ? r() : vueDemi.unref(r);
|
|
222
|
+
}
|
|
223
|
+
const resolveUnref = toValue;
|
|
224
|
+
|
|
438
225
|
function reactify(fn, options) {
|
|
439
226
|
const unrefFn = (options == null ? void 0 : options.computedGetter) === false ? vueDemi.unref : toValue;
|
|
440
227
|
return function(...args) {
|
|
@@ -510,6 +297,211 @@ function reactiveOmit(obj, ...keys) {
|
|
|
510
297
|
);
|
|
511
298
|
}
|
|
512
299
|
|
|
300
|
+
const isClient = typeof window !== "undefined";
|
|
301
|
+
const isDef = (val) => typeof val !== "undefined";
|
|
302
|
+
const assert = (condition, ...infos) => {
|
|
303
|
+
if (!condition)
|
|
304
|
+
console.warn(...infos);
|
|
305
|
+
};
|
|
306
|
+
const toString = Object.prototype.toString;
|
|
307
|
+
const isObject = (val) => toString.call(val) === "[object Object]";
|
|
308
|
+
const now = () => Date.now();
|
|
309
|
+
const timestamp = () => +Date.now();
|
|
310
|
+
const clamp = (n, min, max) => Math.min(max, Math.max(min, n));
|
|
311
|
+
const noop = () => {
|
|
312
|
+
};
|
|
313
|
+
const rand = (min, max) => {
|
|
314
|
+
min = Math.ceil(min);
|
|
315
|
+
max = Math.floor(max);
|
|
316
|
+
return Math.floor(Math.random() * (max - min + 1)) + min;
|
|
317
|
+
};
|
|
318
|
+
const hasOwn = (val, key) => Object.prototype.hasOwnProperty.call(val, key);
|
|
319
|
+
const isIOS = /* @__PURE__ */ getIsIOS();
|
|
320
|
+
function getIsIOS() {
|
|
321
|
+
var _a;
|
|
322
|
+
return isClient && ((_a = window == null ? void 0 : window.navigator) == null ? void 0 : _a.userAgent) && /iP(ad|hone|od)/.test(window.navigator.userAgent);
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
function createFilterWrapper(filter, fn) {
|
|
326
|
+
function wrapper(...args) {
|
|
327
|
+
return new Promise((resolve, reject) => {
|
|
328
|
+
Promise.resolve(filter(() => fn.apply(this, args), { fn, thisArg: this, args })).then(resolve).catch(reject);
|
|
329
|
+
});
|
|
330
|
+
}
|
|
331
|
+
return wrapper;
|
|
332
|
+
}
|
|
333
|
+
const bypassFilter = (invoke) => {
|
|
334
|
+
return invoke();
|
|
335
|
+
};
|
|
336
|
+
function debounceFilter(ms, options = {}) {
|
|
337
|
+
let timer;
|
|
338
|
+
let maxTimer;
|
|
339
|
+
let lastRejector = noop;
|
|
340
|
+
const _clearTimeout = (timer2) => {
|
|
341
|
+
clearTimeout(timer2);
|
|
342
|
+
lastRejector();
|
|
343
|
+
lastRejector = noop;
|
|
344
|
+
};
|
|
345
|
+
const filter = (invoke) => {
|
|
346
|
+
const duration = toValue(ms);
|
|
347
|
+
const maxDuration = toValue(options.maxWait);
|
|
348
|
+
if (timer)
|
|
349
|
+
_clearTimeout(timer);
|
|
350
|
+
if (duration <= 0 || maxDuration !== void 0 && maxDuration <= 0) {
|
|
351
|
+
if (maxTimer) {
|
|
352
|
+
_clearTimeout(maxTimer);
|
|
353
|
+
maxTimer = null;
|
|
354
|
+
}
|
|
355
|
+
return Promise.resolve(invoke());
|
|
356
|
+
}
|
|
357
|
+
return new Promise((resolve, reject) => {
|
|
358
|
+
lastRejector = options.rejectOnCancel ? reject : resolve;
|
|
359
|
+
if (maxDuration && !maxTimer) {
|
|
360
|
+
maxTimer = setTimeout(() => {
|
|
361
|
+
if (timer)
|
|
362
|
+
_clearTimeout(timer);
|
|
363
|
+
maxTimer = null;
|
|
364
|
+
resolve(invoke());
|
|
365
|
+
}, maxDuration);
|
|
366
|
+
}
|
|
367
|
+
timer = setTimeout(() => {
|
|
368
|
+
if (maxTimer)
|
|
369
|
+
_clearTimeout(maxTimer);
|
|
370
|
+
maxTimer = null;
|
|
371
|
+
resolve(invoke());
|
|
372
|
+
}, duration);
|
|
373
|
+
});
|
|
374
|
+
};
|
|
375
|
+
return filter;
|
|
376
|
+
}
|
|
377
|
+
function throttleFilter(ms, trailing = true, leading = true, rejectOnCancel = false) {
|
|
378
|
+
let lastExec = 0;
|
|
379
|
+
let timer;
|
|
380
|
+
let isLeading = true;
|
|
381
|
+
let lastRejector = noop;
|
|
382
|
+
let lastValue;
|
|
383
|
+
const clear = () => {
|
|
384
|
+
if (timer) {
|
|
385
|
+
clearTimeout(timer);
|
|
386
|
+
timer = void 0;
|
|
387
|
+
lastRejector();
|
|
388
|
+
lastRejector = noop;
|
|
389
|
+
}
|
|
390
|
+
};
|
|
391
|
+
const filter = (_invoke) => {
|
|
392
|
+
const duration = toValue(ms);
|
|
393
|
+
const elapsed = Date.now() - lastExec;
|
|
394
|
+
const invoke = () => {
|
|
395
|
+
return lastValue = _invoke();
|
|
396
|
+
};
|
|
397
|
+
clear();
|
|
398
|
+
if (duration <= 0) {
|
|
399
|
+
lastExec = Date.now();
|
|
400
|
+
return invoke();
|
|
401
|
+
}
|
|
402
|
+
if (elapsed > duration && (leading || !isLeading)) {
|
|
403
|
+
lastExec = Date.now();
|
|
404
|
+
invoke();
|
|
405
|
+
} else if (trailing) {
|
|
406
|
+
lastValue = new Promise((resolve, reject) => {
|
|
407
|
+
lastRejector = rejectOnCancel ? reject : resolve;
|
|
408
|
+
timer = setTimeout(() => {
|
|
409
|
+
lastExec = Date.now();
|
|
410
|
+
isLeading = true;
|
|
411
|
+
resolve(invoke());
|
|
412
|
+
clear();
|
|
413
|
+
}, Math.max(0, duration - elapsed));
|
|
414
|
+
});
|
|
415
|
+
}
|
|
416
|
+
if (!leading && !timer)
|
|
417
|
+
timer = setTimeout(() => isLeading = true, duration);
|
|
418
|
+
isLeading = false;
|
|
419
|
+
return lastValue;
|
|
420
|
+
};
|
|
421
|
+
return filter;
|
|
422
|
+
}
|
|
423
|
+
function pausableFilter(extendFilter = bypassFilter) {
|
|
424
|
+
const isActive = vueDemi.ref(true);
|
|
425
|
+
function pause() {
|
|
426
|
+
isActive.value = false;
|
|
427
|
+
}
|
|
428
|
+
function resume() {
|
|
429
|
+
isActive.value = true;
|
|
430
|
+
}
|
|
431
|
+
const eventFilter = (...args) => {
|
|
432
|
+
if (isActive.value)
|
|
433
|
+
extendFilter(...args);
|
|
434
|
+
};
|
|
435
|
+
return { isActive: vueDemi.readonly(isActive), pause, resume, eventFilter };
|
|
436
|
+
}
|
|
437
|
+
|
|
438
|
+
const directiveHooks = {
|
|
439
|
+
mounted: vueDemi.isVue3 ? "mounted" : "inserted",
|
|
440
|
+
updated: vueDemi.isVue3 ? "updated" : "componentUpdated",
|
|
441
|
+
unmounted: vueDemi.isVue3 ? "unmounted" : "unbind"
|
|
442
|
+
};
|
|
443
|
+
|
|
444
|
+
function promiseTimeout(ms, throwOnTimeout = false, reason = "Timeout") {
|
|
445
|
+
return new Promise((resolve, reject) => {
|
|
446
|
+
if (throwOnTimeout)
|
|
447
|
+
setTimeout(() => reject(reason), ms);
|
|
448
|
+
else
|
|
449
|
+
setTimeout(resolve, ms);
|
|
450
|
+
});
|
|
451
|
+
}
|
|
452
|
+
function identity(arg) {
|
|
453
|
+
return arg;
|
|
454
|
+
}
|
|
455
|
+
function createSingletonPromise(fn) {
|
|
456
|
+
let _promise;
|
|
457
|
+
function wrapper() {
|
|
458
|
+
if (!_promise)
|
|
459
|
+
_promise = fn();
|
|
460
|
+
return _promise;
|
|
461
|
+
}
|
|
462
|
+
wrapper.reset = async () => {
|
|
463
|
+
const _prev = _promise;
|
|
464
|
+
_promise = void 0;
|
|
465
|
+
if (_prev)
|
|
466
|
+
await _prev;
|
|
467
|
+
};
|
|
468
|
+
return wrapper;
|
|
469
|
+
}
|
|
470
|
+
function invoke(fn) {
|
|
471
|
+
return fn();
|
|
472
|
+
}
|
|
473
|
+
function containsProp(obj, ...props) {
|
|
474
|
+
return props.some((k) => k in obj);
|
|
475
|
+
}
|
|
476
|
+
function increaseWithUnit(target, delta) {
|
|
477
|
+
var _a;
|
|
478
|
+
if (typeof target === "number")
|
|
479
|
+
return target + delta;
|
|
480
|
+
const value = ((_a = target.match(/^-?[0-9]+\.?[0-9]*/)) == null ? void 0 : _a[0]) || "";
|
|
481
|
+
const unit = target.slice(value.length);
|
|
482
|
+
const result = parseFloat(value) + delta;
|
|
483
|
+
if (Number.isNaN(result))
|
|
484
|
+
return target;
|
|
485
|
+
return result + unit;
|
|
486
|
+
}
|
|
487
|
+
function objectPick(obj, keys, omitUndefined = false) {
|
|
488
|
+
return keys.reduce((n, k) => {
|
|
489
|
+
if (k in obj) {
|
|
490
|
+
if (!omitUndefined || obj[k] !== void 0)
|
|
491
|
+
n[k] = obj[k];
|
|
492
|
+
}
|
|
493
|
+
return n;
|
|
494
|
+
}, {});
|
|
495
|
+
}
|
|
496
|
+
function objectOmit(obj, keys, omitUndefined = false) {
|
|
497
|
+
return Object.fromEntries(Object.entries(obj).filter(([key, value]) => {
|
|
498
|
+
return (!omitUndefined || value !== void 0) && !keys.includes(key);
|
|
499
|
+
}));
|
|
500
|
+
}
|
|
501
|
+
function objectEntries(obj) {
|
|
502
|
+
return Object.entries(obj);
|
|
503
|
+
}
|
|
504
|
+
|
|
513
505
|
function toRef(...args) {
|
|
514
506
|
if (args.length !== 1)
|
|
515
507
|
return vueDemi.toRef(...args);
|
|
@@ -910,7 +902,7 @@ function useArrayDifference(...args) {
|
|
|
910
902
|
const list = args[0];
|
|
911
903
|
const values = args[1];
|
|
912
904
|
let compareFn = (_a = args[2]) != null ? _a : defaultComparator;
|
|
913
|
-
if (
|
|
905
|
+
if (typeof compareFn === "string") {
|
|
914
906
|
const key = compareFn;
|
|
915
907
|
compareFn = (value, othVal) => value[key] === othVal[key];
|
|
916
908
|
}
|
|
@@ -1130,7 +1122,7 @@ function useIntervalFn(cb, interval = 1e3, options = {}) {
|
|
|
1130
1122
|
}
|
|
1131
1123
|
if (immediate && isClient)
|
|
1132
1124
|
resume();
|
|
1133
|
-
if (vueDemi.isRef(interval) ||
|
|
1125
|
+
if (vueDemi.isRef(interval) || typeof interval === "function") {
|
|
1134
1126
|
const stopWatch = vueDemi.watch(interval, () => {
|
|
1135
1127
|
if (isActive.value && isClient)
|
|
1136
1128
|
resume();
|
|
@@ -1793,8 +1785,6 @@ function whenever(source, cb, options) {
|
|
|
1793
1785
|
);
|
|
1794
1786
|
}
|
|
1795
1787
|
|
|
1796
|
-
exports.__onlyVue27Plus = __onlyVue27Plus;
|
|
1797
|
-
exports.__onlyVue3 = __onlyVue3;
|
|
1798
1788
|
exports.assert = assert;
|
|
1799
1789
|
exports.autoResetRef = refAutoReset;
|
|
1800
1790
|
exports.bypassFilter = bypassFilter;
|
|
@@ -1824,16 +1814,11 @@ exports.identity = identity;
|
|
|
1824
1814
|
exports.ignorableWatch = watchIgnorable;
|
|
1825
1815
|
exports.increaseWithUnit = increaseWithUnit;
|
|
1826
1816
|
exports.invoke = invoke;
|
|
1827
|
-
exports.isBoolean = isBoolean;
|
|
1828
1817
|
exports.isClient = isClient;
|
|
1829
1818
|
exports.isDef = isDef;
|
|
1830
1819
|
exports.isDefined = isDefined;
|
|
1831
|
-
exports.isFunction = isFunction;
|
|
1832
1820
|
exports.isIOS = isIOS;
|
|
1833
|
-
exports.isNumber = isNumber;
|
|
1834
1821
|
exports.isObject = isObject;
|
|
1835
|
-
exports.isString = isString;
|
|
1836
|
-
exports.isWindow = isWindow;
|
|
1837
1822
|
exports.makeDestructurable = makeDestructurable;
|
|
1838
1823
|
exports.noop = noop;
|
|
1839
1824
|
exports.normalizeDate = normalizeDate;
|
package/index.d.ts
CHANGED
|
@@ -36,12 +36,7 @@ declare function createEventHook<T = any>(): EventHook<T>;
|
|
|
36
36
|
declare const isClient: boolean;
|
|
37
37
|
declare const isDef: <T = any>(val?: T | undefined) => val is T;
|
|
38
38
|
declare const assert: (condition: boolean, ...infos: any[]) => void;
|
|
39
|
-
declare const isBoolean: (val: any) => val is boolean;
|
|
40
|
-
declare const isFunction: <T extends Function>(val: any) => val is T;
|
|
41
|
-
declare const isNumber: (val: any) => val is number;
|
|
42
|
-
declare const isString: (val: unknown) => val is string;
|
|
43
39
|
declare const isObject: (val: any) => val is object;
|
|
44
|
-
declare const isWindow: (val: any) => val is Window;
|
|
45
40
|
declare const now: () => number;
|
|
46
41
|
declare const timestamp: () => number;
|
|
47
42
|
declare const clamp: (n: number, min: number, max: number) => number;
|
|
@@ -220,8 +215,6 @@ declare function pausableFilter(extendFilter?: EventFilter): Pausable & {
|
|
|
220
215
|
eventFilter: EventFilter;
|
|
221
216
|
};
|
|
222
217
|
|
|
223
|
-
declare function __onlyVue3(name?: string): void;
|
|
224
|
-
declare function __onlyVue27Plus(name?: string): void;
|
|
225
218
|
declare const directiveHooks: {
|
|
226
219
|
mounted: "mounted";
|
|
227
220
|
updated: "updated";
|
|
@@ -1094,4 +1087,4 @@ declare function watchTriggerable<T extends object, FnReturnT>(source: T, cb: Wa
|
|
|
1094
1087
|
*/
|
|
1095
1088
|
declare function whenever<T>(source: WatchSource<T | false | null | undefined>, cb: WatchCallback<T>, options?: WatchOptions): vue_demi.WatchStopHandle;
|
|
1096
1089
|
|
|
1097
|
-
export { AnyFn, ArgumentsType, Arrayable, Awaitable, ComputedRefWithControl, ComputedWithControlRefExtra, ConfigurableEventFilter, ConfigurableFlush, ConfigurableFlushSync, ControlledRefOptions, DateLike, DebounceFilterOptions, DeepMaybeRef, ElementOf, EventFilter, EventHook, EventHookOff, EventHookOn, EventHookTrigger, ExtendRefOptions, Fn, FunctionArgs, FunctionWrapperOptions, IgnoredUpdater, MapOldSources, MapSources, MaybeRef, MaybeRefOrGetter, Mutable, Pausable, PromisifyFn, Reactified, ReactifyNested, ReactifyObjectOptions, ReactifyOptions, ReactiveOmitPredicate, ReactivePickPredicate, ReadonlyRefOrGetter, RemovableRef, ShallowUnwrapRef, SingletonPromiseReturn, Stoppable, SyncRefOptions, SyncRefsOptions, UntilArrayInstance, UntilBaseInstance, UntilToMatchOptions, UntilValueInstance, UseArrayIncludesComparatorFn, UseArrayIncludesOptions, UseArrayReducer, UseCounterOptions, UseDateFormatOptions, UseDateFormatReturn, UseIntervalControls, UseIntervalFnOptions, UseIntervalOptions, UseLastChangedOptions, UseTimeoutFnOptions, UseTimeoutOptions, UseToNumberOptions, UseToggleOptions, WatchArrayCallback, WatchAtMostOptions, WatchAtMostReturn, WatchDebouncedOptions, WatchIgnorableReturn, WatchPausableReturn, WatchThrottledOptions, WatchTriggerableCallback, WatchTriggerableReturn, WatchWithFilterOptions, WritableComputedRefWithControl,
|
|
1090
|
+
export { AnyFn, ArgumentsType, Arrayable, Awaitable, ComputedRefWithControl, ComputedWithControlRefExtra, ConfigurableEventFilter, ConfigurableFlush, ConfigurableFlushSync, ControlledRefOptions, DateLike, DebounceFilterOptions, DeepMaybeRef, ElementOf, EventFilter, EventHook, EventHookOff, EventHookOn, EventHookTrigger, ExtendRefOptions, Fn, FunctionArgs, FunctionWrapperOptions, IgnoredUpdater, MapOldSources, MapSources, MaybeRef, MaybeRefOrGetter, Mutable, Pausable, PromisifyFn, Reactified, ReactifyNested, ReactifyObjectOptions, ReactifyOptions, ReactiveOmitPredicate, ReactivePickPredicate, ReadonlyRefOrGetter, RemovableRef, ShallowUnwrapRef, SingletonPromiseReturn, Stoppable, SyncRefOptions, SyncRefsOptions, UntilArrayInstance, UntilBaseInstance, UntilToMatchOptions, UntilValueInstance, UseArrayIncludesComparatorFn, UseArrayIncludesOptions, UseArrayReducer, UseCounterOptions, UseDateFormatOptions, UseDateFormatReturn, UseIntervalControls, UseIntervalFnOptions, UseIntervalOptions, UseLastChangedOptions, UseTimeoutFnOptions, UseTimeoutOptions, UseToNumberOptions, UseToggleOptions, WatchArrayCallback, WatchAtMostOptions, WatchAtMostReturn, WatchDebouncedOptions, WatchIgnorableReturn, WatchPausableReturn, WatchThrottledOptions, WatchTriggerableCallback, WatchTriggerableReturn, WatchWithFilterOptions, WritableComputedRefWithControl, assert, refAutoReset as autoResetRef, bypassFilter, clamp, computedEager, computedWithControl, containsProp, computedWithControl as controlledComputed, controlledRef, createEventHook, createFilterWrapper, createGlobalState, createInjectionState, reactify as createReactiveFn, createSharedComposable, createSingletonPromise, debounceFilter, refDebounced as debouncedRef, watchDebounced as debouncedWatch, directiveHooks, computedEager as eagerComputed, extendRef, formatDate, get, hasOwn, identity, watchIgnorable as ignorableWatch, increaseWithUnit, invoke, isClient, isDef, isDefined, isIOS, isObject, makeDestructurable, noop, normalizeDate, now, objectEntries, objectOmit, objectPick, pausableFilter, watchPausable as pausableWatch, promiseTimeout, 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 };
|