@vueuse/shared 10.0.0-beta.4 → 10.0.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 +221 -234
- package/index.d.ts +4 -8
- package/index.iife.js +221 -234
- package/index.iife.min.js +1 -1
- package/index.mjs +222 -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,212 @@ 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 notNullish = (val) => val != null;
|
|
303
|
+
const assert = (condition, ...infos) => {
|
|
304
|
+
if (!condition)
|
|
305
|
+
console.warn(...infos);
|
|
306
|
+
};
|
|
307
|
+
const toString = Object.prototype.toString;
|
|
308
|
+
const isObject = (val) => toString.call(val) === "[object Object]";
|
|
309
|
+
const now = () => Date.now();
|
|
310
|
+
const timestamp = () => +Date.now();
|
|
311
|
+
const clamp = (n, min, max) => Math.min(max, Math.max(min, n));
|
|
312
|
+
const noop = () => {
|
|
313
|
+
};
|
|
314
|
+
const rand = (min, max) => {
|
|
315
|
+
min = Math.ceil(min);
|
|
316
|
+
max = Math.floor(max);
|
|
317
|
+
return Math.floor(Math.random() * (max - min + 1)) + min;
|
|
318
|
+
};
|
|
319
|
+
const hasOwn = (val, key) => Object.prototype.hasOwnProperty.call(val, key);
|
|
320
|
+
const isIOS = /* @__PURE__ */ getIsIOS();
|
|
321
|
+
function getIsIOS() {
|
|
322
|
+
var _a;
|
|
323
|
+
return isClient && ((_a = window == null ? void 0 : window.navigator) == null ? void 0 : _a.userAgent) && /* @__PURE__ */ /iP(ad|hone|od)/.test(window.navigator.userAgent);
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
function createFilterWrapper(filter, fn) {
|
|
327
|
+
function wrapper(...args) {
|
|
328
|
+
return new Promise((resolve, reject) => {
|
|
329
|
+
Promise.resolve(filter(() => fn.apply(this, args), { fn, thisArg: this, args })).then(resolve).catch(reject);
|
|
330
|
+
});
|
|
331
|
+
}
|
|
332
|
+
return wrapper;
|
|
333
|
+
}
|
|
334
|
+
const bypassFilter = (invoke) => {
|
|
335
|
+
return invoke();
|
|
336
|
+
};
|
|
337
|
+
function debounceFilter(ms, options = {}) {
|
|
338
|
+
let timer;
|
|
339
|
+
let maxTimer;
|
|
340
|
+
let lastRejector = noop;
|
|
341
|
+
const _clearTimeout = (timer2) => {
|
|
342
|
+
clearTimeout(timer2);
|
|
343
|
+
lastRejector();
|
|
344
|
+
lastRejector = noop;
|
|
345
|
+
};
|
|
346
|
+
const filter = (invoke) => {
|
|
347
|
+
const duration = toValue(ms);
|
|
348
|
+
const maxDuration = toValue(options.maxWait);
|
|
349
|
+
if (timer)
|
|
350
|
+
_clearTimeout(timer);
|
|
351
|
+
if (duration <= 0 || maxDuration !== void 0 && maxDuration <= 0) {
|
|
352
|
+
if (maxTimer) {
|
|
353
|
+
_clearTimeout(maxTimer);
|
|
354
|
+
maxTimer = null;
|
|
355
|
+
}
|
|
356
|
+
return Promise.resolve(invoke());
|
|
357
|
+
}
|
|
358
|
+
return new Promise((resolve, reject) => {
|
|
359
|
+
lastRejector = options.rejectOnCancel ? reject : resolve;
|
|
360
|
+
if (maxDuration && !maxTimer) {
|
|
361
|
+
maxTimer = setTimeout(() => {
|
|
362
|
+
if (timer)
|
|
363
|
+
_clearTimeout(timer);
|
|
364
|
+
maxTimer = null;
|
|
365
|
+
resolve(invoke());
|
|
366
|
+
}, maxDuration);
|
|
367
|
+
}
|
|
368
|
+
timer = setTimeout(() => {
|
|
369
|
+
if (maxTimer)
|
|
370
|
+
_clearTimeout(maxTimer);
|
|
371
|
+
maxTimer = null;
|
|
372
|
+
resolve(invoke());
|
|
373
|
+
}, duration);
|
|
374
|
+
});
|
|
375
|
+
};
|
|
376
|
+
return filter;
|
|
377
|
+
}
|
|
378
|
+
function throttleFilter(ms, trailing = true, leading = true, rejectOnCancel = false) {
|
|
379
|
+
let lastExec = 0;
|
|
380
|
+
let timer;
|
|
381
|
+
let isLeading = true;
|
|
382
|
+
let lastRejector = noop;
|
|
383
|
+
let lastValue;
|
|
384
|
+
const clear = () => {
|
|
385
|
+
if (timer) {
|
|
386
|
+
clearTimeout(timer);
|
|
387
|
+
timer = void 0;
|
|
388
|
+
lastRejector();
|
|
389
|
+
lastRejector = noop;
|
|
390
|
+
}
|
|
391
|
+
};
|
|
392
|
+
const filter = (_invoke) => {
|
|
393
|
+
const duration = toValue(ms);
|
|
394
|
+
const elapsed = Date.now() - lastExec;
|
|
395
|
+
const invoke = () => {
|
|
396
|
+
return lastValue = _invoke();
|
|
397
|
+
};
|
|
398
|
+
clear();
|
|
399
|
+
if (duration <= 0) {
|
|
400
|
+
lastExec = Date.now();
|
|
401
|
+
return invoke();
|
|
402
|
+
}
|
|
403
|
+
if (elapsed > duration && (leading || !isLeading)) {
|
|
404
|
+
lastExec = Date.now();
|
|
405
|
+
invoke();
|
|
406
|
+
} else if (trailing) {
|
|
407
|
+
lastValue = new Promise((resolve, reject) => {
|
|
408
|
+
lastRejector = rejectOnCancel ? reject : resolve;
|
|
409
|
+
timer = setTimeout(() => {
|
|
410
|
+
lastExec = Date.now();
|
|
411
|
+
isLeading = true;
|
|
412
|
+
resolve(invoke());
|
|
413
|
+
clear();
|
|
414
|
+
}, Math.max(0, duration - elapsed));
|
|
415
|
+
});
|
|
416
|
+
}
|
|
417
|
+
if (!leading && !timer)
|
|
418
|
+
timer = setTimeout(() => isLeading = true, duration);
|
|
419
|
+
isLeading = false;
|
|
420
|
+
return lastValue;
|
|
421
|
+
};
|
|
422
|
+
return filter;
|
|
423
|
+
}
|
|
424
|
+
function pausableFilter(extendFilter = bypassFilter) {
|
|
425
|
+
const isActive = vueDemi.ref(true);
|
|
426
|
+
function pause() {
|
|
427
|
+
isActive.value = false;
|
|
428
|
+
}
|
|
429
|
+
function resume() {
|
|
430
|
+
isActive.value = true;
|
|
431
|
+
}
|
|
432
|
+
const eventFilter = (...args) => {
|
|
433
|
+
if (isActive.value)
|
|
434
|
+
extendFilter(...args);
|
|
435
|
+
};
|
|
436
|
+
return { isActive: vueDemi.readonly(isActive), pause, resume, eventFilter };
|
|
437
|
+
}
|
|
438
|
+
|
|
439
|
+
const directiveHooks = {
|
|
440
|
+
mounted: vueDemi.isVue3 ? "mounted" : "inserted",
|
|
441
|
+
updated: vueDemi.isVue3 ? "updated" : "componentUpdated",
|
|
442
|
+
unmounted: vueDemi.isVue3 ? "unmounted" : "unbind"
|
|
443
|
+
};
|
|
444
|
+
|
|
445
|
+
function promiseTimeout(ms, throwOnTimeout = false, reason = "Timeout") {
|
|
446
|
+
return new Promise((resolve, reject) => {
|
|
447
|
+
if (throwOnTimeout)
|
|
448
|
+
setTimeout(() => reject(reason), ms);
|
|
449
|
+
else
|
|
450
|
+
setTimeout(resolve, ms);
|
|
451
|
+
});
|
|
452
|
+
}
|
|
453
|
+
function identity(arg) {
|
|
454
|
+
return arg;
|
|
455
|
+
}
|
|
456
|
+
function createSingletonPromise(fn) {
|
|
457
|
+
let _promise;
|
|
458
|
+
function wrapper() {
|
|
459
|
+
if (!_promise)
|
|
460
|
+
_promise = fn();
|
|
461
|
+
return _promise;
|
|
462
|
+
}
|
|
463
|
+
wrapper.reset = async () => {
|
|
464
|
+
const _prev = _promise;
|
|
465
|
+
_promise = void 0;
|
|
466
|
+
if (_prev)
|
|
467
|
+
await _prev;
|
|
468
|
+
};
|
|
469
|
+
return wrapper;
|
|
470
|
+
}
|
|
471
|
+
function invoke(fn) {
|
|
472
|
+
return fn();
|
|
473
|
+
}
|
|
474
|
+
function containsProp(obj, ...props) {
|
|
475
|
+
return props.some((k) => k in obj);
|
|
476
|
+
}
|
|
477
|
+
function increaseWithUnit(target, delta) {
|
|
478
|
+
var _a;
|
|
479
|
+
if (typeof target === "number")
|
|
480
|
+
return target + delta;
|
|
481
|
+
const value = ((_a = target.match(/^-?[0-9]+\.?[0-9]*/)) == null ? void 0 : _a[0]) || "";
|
|
482
|
+
const unit = target.slice(value.length);
|
|
483
|
+
const result = parseFloat(value) + delta;
|
|
484
|
+
if (Number.isNaN(result))
|
|
485
|
+
return target;
|
|
486
|
+
return result + unit;
|
|
487
|
+
}
|
|
488
|
+
function objectPick(obj, keys, omitUndefined = false) {
|
|
489
|
+
return keys.reduce((n, k) => {
|
|
490
|
+
if (k in obj) {
|
|
491
|
+
if (!omitUndefined || obj[k] !== void 0)
|
|
492
|
+
n[k] = obj[k];
|
|
493
|
+
}
|
|
494
|
+
return n;
|
|
495
|
+
}, {});
|
|
496
|
+
}
|
|
497
|
+
function objectOmit(obj, keys, omitUndefined = false) {
|
|
498
|
+
return Object.fromEntries(Object.entries(obj).filter(([key, value]) => {
|
|
499
|
+
return (!omitUndefined || value !== void 0) && !keys.includes(key);
|
|
500
|
+
}));
|
|
501
|
+
}
|
|
502
|
+
function objectEntries(obj) {
|
|
503
|
+
return Object.entries(obj);
|
|
504
|
+
}
|
|
505
|
+
|
|
513
506
|
function toRef(...args) {
|
|
514
507
|
if (args.length !== 1)
|
|
515
508
|
return vueDemi.toRef(...args);
|
|
@@ -910,7 +903,7 @@ function useArrayDifference(...args) {
|
|
|
910
903
|
const list = args[0];
|
|
911
904
|
const values = args[1];
|
|
912
905
|
let compareFn = (_a = args[2]) != null ? _a : defaultComparator;
|
|
913
|
-
if (
|
|
906
|
+
if (typeof compareFn === "string") {
|
|
914
907
|
const key = compareFn;
|
|
915
908
|
compareFn = (value, othVal) => value[key] === othVal[key];
|
|
916
909
|
}
|
|
@@ -1130,7 +1123,7 @@ function useIntervalFn(cb, interval = 1e3, options = {}) {
|
|
|
1130
1123
|
}
|
|
1131
1124
|
if (immediate && isClient)
|
|
1132
1125
|
resume();
|
|
1133
|
-
if (vueDemi.isRef(interval) ||
|
|
1126
|
+
if (vueDemi.isRef(interval) || typeof interval === "function") {
|
|
1134
1127
|
const stopWatch = vueDemi.watch(interval, () => {
|
|
1135
1128
|
if (isActive.value && isClient)
|
|
1136
1129
|
resume();
|
|
@@ -1793,8 +1786,6 @@ function whenever(source, cb, options) {
|
|
|
1793
1786
|
);
|
|
1794
1787
|
}
|
|
1795
1788
|
|
|
1796
|
-
exports.__onlyVue27Plus = __onlyVue27Plus;
|
|
1797
|
-
exports.__onlyVue3 = __onlyVue3;
|
|
1798
1789
|
exports.assert = assert;
|
|
1799
1790
|
exports.autoResetRef = refAutoReset;
|
|
1800
1791
|
exports.bypassFilter = bypassFilter;
|
|
@@ -1824,19 +1815,15 @@ exports.identity = identity;
|
|
|
1824
1815
|
exports.ignorableWatch = watchIgnorable;
|
|
1825
1816
|
exports.increaseWithUnit = increaseWithUnit;
|
|
1826
1817
|
exports.invoke = invoke;
|
|
1827
|
-
exports.isBoolean = isBoolean;
|
|
1828
1818
|
exports.isClient = isClient;
|
|
1829
1819
|
exports.isDef = isDef;
|
|
1830
1820
|
exports.isDefined = isDefined;
|
|
1831
|
-
exports.isFunction = isFunction;
|
|
1832
1821
|
exports.isIOS = isIOS;
|
|
1833
|
-
exports.isNumber = isNumber;
|
|
1834
1822
|
exports.isObject = isObject;
|
|
1835
|
-
exports.isString = isString;
|
|
1836
|
-
exports.isWindow = isWindow;
|
|
1837
1823
|
exports.makeDestructurable = makeDestructurable;
|
|
1838
1824
|
exports.noop = noop;
|
|
1839
1825
|
exports.normalizeDate = normalizeDate;
|
|
1826
|
+
exports.notNullish = notNullish;
|
|
1840
1827
|
exports.now = now;
|
|
1841
1828
|
exports.objectEntries = objectEntries;
|
|
1842
1829
|
exports.objectOmit = objectOmit;
|
package/index.d.ts
CHANGED
|
@@ -35,13 +35,9 @@ declare function createEventHook<T = any>(): EventHook<T>;
|
|
|
35
35
|
|
|
36
36
|
declare const isClient: boolean;
|
|
37
37
|
declare const isDef: <T = any>(val?: T | undefined) => val is T;
|
|
38
|
+
declare const notNullish: <T = any>(val?: T | null | undefined) => val is T;
|
|
38
39
|
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
40
|
declare const isObject: (val: any) => val is object;
|
|
44
|
-
declare const isWindow: (val: any) => val is Window;
|
|
45
41
|
declare const now: () => number;
|
|
46
42
|
declare const timestamp: () => number;
|
|
47
43
|
declare const clamp: (n: number, min: number, max: number) => number;
|
|
@@ -220,8 +216,6 @@ declare function pausableFilter(extendFilter?: EventFilter): Pausable & {
|
|
|
220
216
|
eventFilter: EventFilter;
|
|
221
217
|
};
|
|
222
218
|
|
|
223
|
-
declare function __onlyVue3(name?: string): void;
|
|
224
|
-
declare function __onlyVue27Plus(name?: string): void;
|
|
225
219
|
declare const directiveHooks: {
|
|
226
220
|
mounted: "mounted";
|
|
227
221
|
updated: "updated";
|
|
@@ -523,6 +517,8 @@ declare function toReactive<T extends object>(objectRef: MaybeRef<T>): T;
|
|
|
523
517
|
/**
|
|
524
518
|
* Normalize value/ref/getter to `ref` or `computed`.
|
|
525
519
|
*/
|
|
520
|
+
declare function toRef<T>(r: () => T): Readonly<Ref<T>>;
|
|
521
|
+
declare function toRef<T>(r: ComputedRef<T>): ComputedRef<T>;
|
|
526
522
|
declare function toRef<T>(r: MaybeRefOrGetter<T>): Ref<T>;
|
|
527
523
|
declare function toRef<T>(r: T): Ref<T>;
|
|
528
524
|
declare function toRef<T extends object, K extends keyof T>(object: T, key: K): ToRef<T[K]>;
|
|
@@ -1094,4 +1090,4 @@ declare function watchTriggerable<T extends object, FnReturnT>(source: T, cb: Wa
|
|
|
1094
1090
|
*/
|
|
1095
1091
|
declare function whenever<T>(source: WatchSource<T | false | null | undefined>, cb: WatchCallback<T>, options?: WatchOptions): vue_demi.WatchStopHandle;
|
|
1096
1092
|
|
|
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,
|
|
1093
|
+
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, notNullish, 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 };
|