Socket
Socket
Sign inDemoInstall

@vueuse/shared

Package Overview
Dependencies
Maintainers
3
Versions
236
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@vueuse/shared - npm Package Compare versions

Comparing version 4.6.4 to 4.7.0

188

dist/index.cjs.js

@@ -541,6 +541,97 @@ 'use strict';

function until(r) {
let isNot = false;
function toMatch(condition, { flush = 'sync', deep = false, timeout, throwOnTimeout } = {}) {
let stop = null;
const watcher = new Promise((resolve) => {
stop = vueDemi.watch(r, (v) => {
if (condition(v) === !isNot) {
stop === null || stop === void 0 ? void 0 : stop();
resolve();
}
}, {
flush,
deep,
immediate: true,
});
});
const promises = [watcher];
if (timeout) {
promises.push(promiseTimeout(timeout, throwOnTimeout).finally(() => {
stop === null || stop === void 0 ? void 0 : stop();
}));
}
return Promise.race(promises);
}
function toBe(value, options) {
return toMatch(v => v === vueDemi.unref(value), options);
}
function toBeTruthy(options) {
return toMatch(v => Boolean(v), options);
}
function toBeNull(options) {
return toBe(null, options);
}
function toBeUndefined(options) {
return toBe(undefined, options);
}
function toBeNaN(options) {
return toMatch(Number.isNaN, options);
}
function toContains(value, options) {
return toMatch((v) => {
const array = Array.from(v);
return array.includes(value) || array.includes(vueDemi.unref(value));
}, options);
}
function changed(options) {
return changedTimes(1, options);
}
function changedTimes(n = 1, options) {
let count = -1; // skip the immediate check
return toMatch(() => {
count += 1;
return count >= n;
}, options);
}
if (Array.isArray(vueDemi.unref(r))) {
const instance = {
toMatch,
toContains,
changed,
changedTimes,
get not() {
isNot = !isNot;
return this;
},
};
return instance;
}
else {
const instance = {
toMatch,
toBe,
toBeTruthy,
toBeNull,
toBeNaN,
toBeUndefined,
changed,
changedTimes,
get not() {
isNot = !isNot;
return this;
},
};
return instance;
}
}
/**
* @deprecated `when` is renamed to `util`, use `until` instead. This will be removed in next major version.
*/
const when = until;
/**
* Basic counter with utility functions.
*
* @see {@link https://vueuse.org/useCounter}
* @link https://vueuse.org/useCounter
* @param [initialValue=0]

@@ -739,87 +830,10 @@ */

function when(r) {
let isNot = false;
function toMatch(condition, { flush = 'sync', deep = false, timeout, throwOnTimeout } = {}) {
let stop = null;
const watcher = new Promise((resolve) => {
stop = vueDemi.watch(r, (v) => {
if (condition(v) === !isNot) {
stop === null || stop === void 0 ? void 0 : stop();
resolve();
}
}, {
flush,
deep,
immediate: true,
});
});
const promises = [watcher];
if (timeout) {
promises.push(promiseTimeout(timeout, throwOnTimeout).finally(() => {
stop === null || stop === void 0 ? void 0 : stop();
}));
}
return Promise.race(promises);
}
function toBe(value, options) {
return toMatch(v => v === vueDemi.unref(value), options);
}
function toBeTruthy(options) {
return toMatch(v => Boolean(v), options);
}
function toBeNull(options) {
return toBe(null, options);
}
function toBeUndefined(options) {
return toBe(undefined, options);
}
function toBeNaN(options) {
return toMatch(Number.isNaN, options);
}
function toContains(value, options) {
return toMatch((v) => {
const array = Array.from(v);
return array.includes(value) || array.includes(vueDemi.unref(value));
}, options);
}
function changed(options) {
return changedTimes(1, options);
}
function changedTimes(n = 1, options) {
let count = -1; // skip the immediate check
return toMatch(() => {
count += 1;
return count >= n;
}, options);
}
if (Array.isArray(vueDemi.unref(r))) {
const instance = {
toMatch,
toContains,
changed,
changedTimes,
get not() {
isNot = !isNot;
return this;
},
};
return instance;
}
else {
const instance = {
toMatch,
toBe,
toBeTruthy,
toBeNull,
toBeNaN,
toBeUndefined,
changed,
changedTimes,
get not() {
isNot = !isNot;
return this;
},
};
return instance;
}
/**
* Shorthand for watching value to be truthy
*
* @link https://vueuse.js.org/whenever
*/
function whenever(source, cb, options) {
return vueDemi.watch(source, (v) => { if (v)
cb(); }, options);
}

@@ -865,2 +879,3 @@

exports.tryOnUnmounted = tryOnUnmounted;
exports.until = until;
exports.useCounter = useCounter;

@@ -878,1 +893,2 @@ exports.useDebounce = useDebounce;

exports.when = when;
exports.whenever = whenever;

@@ -319,6 +319,72 @@ import * as vue_demi from 'vue-demi';

interface UntilToMatchOptions {
/**
* Milseconds timeout for promise to resolve/reject if the when condition does not meet.
* 0 for never timed out
*
* @default 0
*/
timeout?: number;
/**
* Reject the promise when timeout
*
* @default false
*/
throwOnTimeout?: boolean;
/**
* `flush` option for internal watch
*
* @default 'sync'
*/
flush?: WatchOptions['flush'];
/**
* `deep` option for internal watch
*
* @default 'false'
*/
deep?: WatchOptions['deep'];
}
interface UntilBaseInstance<T> {
toMatch(condition: (v: T) => boolean, options?: UntilToMatchOptions): Promise<void>;
changed(options?: UntilToMatchOptions): Promise<void>;
changedTimes(n?: number, options?: UntilToMatchOptions): Promise<void>;
}
interface UntilValueInstance<T> extends UntilBaseInstance<T> {
readonly not: UntilValueInstance<T>;
toBe<P = T>(value: MaybeRef<T | P>, options?: UntilToMatchOptions): Promise<void>;
toBeTruthy(options?: UntilToMatchOptions): Promise<void>;
toBeNull(options?: UntilToMatchOptions): Promise<void>;
toBeUndefined(options?: UntilToMatchOptions): Promise<void>;
toBeNaN(options?: UntilToMatchOptions): Promise<void>;
}
interface UntilArrayInstance<T> extends UntilBaseInstance<T> {
readonly not: UntilArrayInstance<T>;
toContains(value: MaybeRef<ElementOf<ShallowUnwrapRef<T>>>, options?: UntilToMatchOptions): Promise<void>;
}
/**
* Promised one-time watch for changes
*
* @link https://vueuse.org/until
* @example
* ```
* const { count } = useCounter()
*
* await until(count).toMatch(v => v > 7)
*
* alert('Counter is now larger than 7!')
* ```
*/
declare function until<T extends unknown[]>(r: T): UntilArrayInstance<T>;
declare function until<T extends Ref<unknown[]>>(r: T): UntilArrayInstance<T>;
declare function until<T>(r: WatchSource<T>): UntilValueInstance<T>;
declare function until<T>(r: T): UntilValueInstance<T>;
/**
* @deprecated `when` is renamed to `util`, use `until` instead. This will be removed in next major version.
*/
declare const when: typeof until;
/**
* Basic counter with utility functions.
*
* @see {@link https://vueuse.org/useCounter}
* @link https://vueuse.org/useCounter
* @param [initialValue=0]

@@ -429,3 +495,3 @@ */

*
* @see {@link https://vueuse.org/useToggle}
* @link https://vueuse.org/useToggle
* @param [initialValue=false]

@@ -436,51 +502,9 @@ */

interface WhenToMatchOptions {
/**
* Milseconds timeout for promise to resolve/reject if the when condition does not meet.
* 0 for never timed out
*
* @default 0
*/
timeout?: number;
/**
* Reject the promise when timeout
*
* @default false
*/
throwOnTimeout?: boolean;
/**
* `flush` option for internal watch
*
* @default 'sync'
*/
flush?: WatchOptions['flush'];
/**
* `deep` option for internal watch
*
* @default 'false'
*/
deep?: WatchOptions['deep'];
}
interface BaseWhenInstance<T> {
toMatch(condition: (v: T) => boolean, options?: WhenToMatchOptions): Promise<void>;
changed(options?: WhenToMatchOptions): Promise<void>;
changedTimes(n?: number, options?: WhenToMatchOptions): Promise<void>;
}
interface ValueWhenInstance<T> extends BaseWhenInstance<T> {
readonly not: ValueWhenInstance<T>;
toBe<P = T>(value: MaybeRef<T | P>, options?: WhenToMatchOptions): Promise<void>;
toBeTruthy(options?: WhenToMatchOptions): Promise<void>;
toBeNull(options?: WhenToMatchOptions): Promise<void>;
toBeUndefined(options?: WhenToMatchOptions): Promise<void>;
toBeNaN(options?: WhenToMatchOptions): Promise<void>;
}
interface ArrayWhenInstance<T> extends BaseWhenInstance<T> {
readonly not: ArrayWhenInstance<T>;
toContains(value: MaybeRef<ElementOf<ShallowUnwrapRef<T>>>, options?: WhenToMatchOptions): Promise<void>;
}
declare function when<T extends unknown[]>(r: T): ArrayWhenInstance<T>;
declare function when<T extends Ref<unknown[]>>(r: T): ArrayWhenInstance<T>;
declare function when<T>(r: WatchSource<T>): ValueWhenInstance<T>;
declare function when<T>(r: T): ValueWhenInstance<T>;
/**
* Shorthand for watching value to be truthy
*
* @link https://vueuse.js.org/whenever
*/
declare function whenever<T = boolean>(source: WatchSource<T>, cb: Fn, options?: WatchOptions): vue_demi.WatchStopHandle;
export { ArrayWhenInstance, BaseWhenInstance, ConfigurableEventFilter, ConfigurableFlush, ConfigurableFlushSync, ControlledRefOptions, DebouncedWatchOptions, DeepMaybeRef, ElementOf, EventFilter, ExtendRefOptions, Fn, FunctionArgs, FunctionWrapperOptions, IgnorableWatchReturn, IgnoredUpdater, IntervalFnReturn, MapOldSources, MapSources, MaybeRef, Pausable, PausableWatchReturn, Reactify, ReactifyNested, ReactifyObjectOptions, ShallowUnwrapRef, SyncRefOptions, ThrottledWatchOptions, TimeoutFnResult, ValueWhenInstance, WatchWithFilterOptions, WhenToMatchOptions, assert, biSyncRef, bypassFilter, clamp, containsProp, controlledComputed, controlledRef, createFilterWrapper, debounceFilter, debouncedWatch, extendRef, get, ignorableWatch, increaseWithUnit, invoke, isBoolean, isClient, isDef, isFunction, isNumber, isObject, isString, isWindow, makeDestructurable, noop, now, pausableFilter, pausableWatch, promiseTimeout, reactify, reactifyObject, set, syncRef, throttleFilter, throttledWatch, timestamp, tryOnMounted, tryOnUnmounted, useCounter, useDebounce, useDebounceFn, useInterval, useIntervalFn, useThrottle, useThrottleFn, useTimeout, useTimeoutFn, useToggle, watchWithFilter, when };
export { ConfigurableEventFilter, ConfigurableFlush, ConfigurableFlushSync, ControlledRefOptions, DebouncedWatchOptions, DeepMaybeRef, ElementOf, EventFilter, ExtendRefOptions, Fn, FunctionArgs, FunctionWrapperOptions, IgnorableWatchReturn, IgnoredUpdater, IntervalFnReturn, MapOldSources, MapSources, MaybeRef, Pausable, PausableWatchReturn, Reactify, ReactifyNested, ReactifyObjectOptions, ShallowUnwrapRef, SyncRefOptions, ThrottledWatchOptions, TimeoutFnResult, UntilArrayInstance, UntilBaseInstance, UntilToMatchOptions, UntilValueInstance, WatchWithFilterOptions, assert, biSyncRef, bypassFilter, clamp, containsProp, controlledComputed, controlledRef, createFilterWrapper, debounceFilter, debouncedWatch, extendRef, get, ignorableWatch, increaseWithUnit, invoke, isBoolean, isClient, isDef, isFunction, isNumber, isObject, isString, isWindow, makeDestructurable, noop, now, pausableFilter, pausableWatch, promiseTimeout, reactify, reactifyObject, set, syncRef, throttleFilter, throttledWatch, timestamp, tryOnMounted, tryOnUnmounted, until, useCounter, useDebounce, useDebounceFn, useInterval, useIntervalFn, useThrottle, useThrottleFn, useTimeout, useTimeoutFn, useToggle, watchWithFilter, when, whenever };

@@ -537,6 +537,97 @@ import { watch, ref, customRef, isVue3, isRef, unref, computed, isVue2, getCurrentInstance, onMounted, nextTick, onUnmounted } from 'vue-demi';

function until(r) {
let isNot = false;
function toMatch(condition, { flush = 'sync', deep = false, timeout, throwOnTimeout } = {}) {
let stop = null;
const watcher = new Promise((resolve) => {
stop = watch(r, (v) => {
if (condition(v) === !isNot) {
stop === null || stop === void 0 ? void 0 : stop();
resolve();
}
}, {
flush,
deep,
immediate: true,
});
});
const promises = [watcher];
if (timeout) {
promises.push(promiseTimeout(timeout, throwOnTimeout).finally(() => {
stop === null || stop === void 0 ? void 0 : stop();
}));
}
return Promise.race(promises);
}
function toBe(value, options) {
return toMatch(v => v === unref(value), options);
}
function toBeTruthy(options) {
return toMatch(v => Boolean(v), options);
}
function toBeNull(options) {
return toBe(null, options);
}
function toBeUndefined(options) {
return toBe(undefined, options);
}
function toBeNaN(options) {
return toMatch(Number.isNaN, options);
}
function toContains(value, options) {
return toMatch((v) => {
const array = Array.from(v);
return array.includes(value) || array.includes(unref(value));
}, options);
}
function changed(options) {
return changedTimes(1, options);
}
function changedTimes(n = 1, options) {
let count = -1; // skip the immediate check
return toMatch(() => {
count += 1;
return count >= n;
}, options);
}
if (Array.isArray(unref(r))) {
const instance = {
toMatch,
toContains,
changed,
changedTimes,
get not() {
isNot = !isNot;
return this;
},
};
return instance;
}
else {
const instance = {
toMatch,
toBe,
toBeTruthy,
toBeNull,
toBeNaN,
toBeUndefined,
changed,
changedTimes,
get not() {
isNot = !isNot;
return this;
},
};
return instance;
}
}
/**
* @deprecated `when` is renamed to `util`, use `until` instead. This will be removed in next major version.
*/
const when = until;
/**
* Basic counter with utility functions.
*
* @see {@link https://vueuse.org/useCounter}
* @link https://vueuse.org/useCounter
* @param [initialValue=0]

@@ -735,89 +826,12 @@ */

function when(r) {
let isNot = false;
function toMatch(condition, { flush = 'sync', deep = false, timeout, throwOnTimeout } = {}) {
let stop = null;
const watcher = new Promise((resolve) => {
stop = watch(r, (v) => {
if (condition(v) === !isNot) {
stop === null || stop === void 0 ? void 0 : stop();
resolve();
}
}, {
flush,
deep,
immediate: true,
});
});
const promises = [watcher];
if (timeout) {
promises.push(promiseTimeout(timeout, throwOnTimeout).finally(() => {
stop === null || stop === void 0 ? void 0 : stop();
}));
}
return Promise.race(promises);
}
function toBe(value, options) {
return toMatch(v => v === unref(value), options);
}
function toBeTruthy(options) {
return toMatch(v => Boolean(v), options);
}
function toBeNull(options) {
return toBe(null, options);
}
function toBeUndefined(options) {
return toBe(undefined, options);
}
function toBeNaN(options) {
return toMatch(Number.isNaN, options);
}
function toContains(value, options) {
return toMatch((v) => {
const array = Array.from(v);
return array.includes(value) || array.includes(unref(value));
}, options);
}
function changed(options) {
return changedTimes(1, options);
}
function changedTimes(n = 1, options) {
let count = -1; // skip the immediate check
return toMatch(() => {
count += 1;
return count >= n;
}, options);
}
if (Array.isArray(unref(r))) {
const instance = {
toMatch,
toContains,
changed,
changedTimes,
get not() {
isNot = !isNot;
return this;
},
};
return instance;
}
else {
const instance = {
toMatch,
toBe,
toBeTruthy,
toBeNull,
toBeNaN,
toBeUndefined,
changed,
changedTimes,
get not() {
isNot = !isNot;
return this;
},
};
return instance;
}
/**
* Shorthand for watching value to be truthy
*
* @link https://vueuse.js.org/whenever
*/
function whenever(source, cb, options) {
return watch(source, (v) => { if (v)
cb(); }, options);
}
export { assert, biSyncRef, bypassFilter, clamp, containsProp, controlledComputed, controlledRef, createFilterWrapper, debounceFilter, debouncedWatch, extendRef, get, ignorableWatch, increaseWithUnit, invoke, isBoolean, isClient, isDef, isFunction, isNumber, isObject, isString, isWindow, makeDestructurable, noop, now, pausableFilter, pausableWatch, promiseTimeout, reactify, reactifyObject, set, syncRef, throttleFilter, throttledWatch, timestamp, tryOnMounted, tryOnUnmounted, useCounter, useDebounce, useDebounceFn, useInterval, useIntervalFn, useThrottle, useThrottleFn, useTimeout, useTimeoutFn, useToggle, watchWithFilter, when };
export { assert, biSyncRef, bypassFilter, clamp, containsProp, controlledComputed, controlledRef, createFilterWrapper, debounceFilter, debouncedWatch, extendRef, get, ignorableWatch, increaseWithUnit, invoke, isBoolean, isClient, isDef, isFunction, isNumber, isObject, isString, isWindow, makeDestructurable, noop, now, pausableFilter, pausableWatch, promiseTimeout, reactify, reactifyObject, set, syncRef, throttleFilter, throttledWatch, timestamp, tryOnMounted, tryOnUnmounted, until, useCounter, useDebounce, useDebounceFn, useInterval, useIntervalFn, useThrottle, useThrottleFn, useTimeout, useTimeoutFn, useToggle, watchWithFilter, when, whenever };

@@ -599,6 +599,97 @@ ;(function (window) {

function until(r) {
let isNot = false;
function toMatch(condition, { flush = 'sync', deep = false, timeout, throwOnTimeout } = {}) {
let stop = null;
const watcher = new Promise((resolve) => {
stop = vueDemi.watch(r, (v) => {
if (condition(v) === !isNot) {
stop === null || stop === void 0 ? void 0 : stop();
resolve();
}
}, {
flush,
deep,
immediate: true,
});
});
const promises = [watcher];
if (timeout) {
promises.push(promiseTimeout(timeout, throwOnTimeout).finally(() => {
stop === null || stop === void 0 ? void 0 : stop();
}));
}
return Promise.race(promises);
}
function toBe(value, options) {
return toMatch(v => v === vueDemi.unref(value), options);
}
function toBeTruthy(options) {
return toMatch(v => Boolean(v), options);
}
function toBeNull(options) {
return toBe(null, options);
}
function toBeUndefined(options) {
return toBe(undefined, options);
}
function toBeNaN(options) {
return toMatch(Number.isNaN, options);
}
function toContains(value, options) {
return toMatch((v) => {
const array = Array.from(v);
return array.includes(value) || array.includes(vueDemi.unref(value));
}, options);
}
function changed(options) {
return changedTimes(1, options);
}
function changedTimes(n = 1, options) {
let count = -1; // skip the immediate check
return toMatch(() => {
count += 1;
return count >= n;
}, options);
}
if (Array.isArray(vueDemi.unref(r))) {
const instance = {
toMatch,
toContains,
changed,
changedTimes,
get not() {
isNot = !isNot;
return this;
},
};
return instance;
}
else {
const instance = {
toMatch,
toBe,
toBeTruthy,
toBeNull,
toBeNaN,
toBeUndefined,
changed,
changedTimes,
get not() {
isNot = !isNot;
return this;
},
};
return instance;
}
}
/**
* @deprecated `when` is renamed to `util`, use `until` instead. This will be removed in next major version.
*/
const when = until;
/**
* Basic counter with utility functions.
*
* @see {@link https://vueuse.org/useCounter}
* @link https://vueuse.org/useCounter
* @param [initialValue=0]

@@ -797,87 +888,10 @@ */

function when(r) {
let isNot = false;
function toMatch(condition, { flush = 'sync', deep = false, timeout, throwOnTimeout } = {}) {
let stop = null;
const watcher = new Promise((resolve) => {
stop = vueDemi.watch(r, (v) => {
if (condition(v) === !isNot) {
stop === null || stop === void 0 ? void 0 : stop();
resolve();
}
}, {
flush,
deep,
immediate: true,
});
});
const promises = [watcher];
if (timeout) {
promises.push(promiseTimeout(timeout, throwOnTimeout).finally(() => {
stop === null || stop === void 0 ? void 0 : stop();
}));
}
return Promise.race(promises);
}
function toBe(value, options) {
return toMatch(v => v === vueDemi.unref(value), options);
}
function toBeTruthy(options) {
return toMatch(v => Boolean(v), options);
}
function toBeNull(options) {
return toBe(null, options);
}
function toBeUndefined(options) {
return toBe(undefined, options);
}
function toBeNaN(options) {
return toMatch(Number.isNaN, options);
}
function toContains(value, options) {
return toMatch((v) => {
const array = Array.from(v);
return array.includes(value) || array.includes(vueDemi.unref(value));
}, options);
}
function changed(options) {
return changedTimes(1, options);
}
function changedTimes(n = 1, options) {
let count = -1; // skip the immediate check
return toMatch(() => {
count += 1;
return count >= n;
}, options);
}
if (Array.isArray(vueDemi.unref(r))) {
const instance = {
toMatch,
toContains,
changed,
changedTimes,
get not() {
isNot = !isNot;
return this;
},
};
return instance;
}
else {
const instance = {
toMatch,
toBe,
toBeTruthy,
toBeNull,
toBeNaN,
toBeUndefined,
changed,
changedTimes,
get not() {
isNot = !isNot;
return this;
},
};
return instance;
}
/**
* Shorthand for watching value to be truthy
*
* @link https://vueuse.js.org/whenever
*/
function whenever(source, cb, options) {
return vueDemi.watch(source, (v) => { if (v)
cb(); }, options);
}

@@ -923,2 +937,3 @@

exports.tryOnUnmounted = tryOnUnmounted;
exports.until = until;
exports.useCounter = useCounter;

@@ -936,2 +951,3 @@ exports.useDebounce = useDebounce;

exports.when = when;
exports.whenever = whenever;

@@ -938,0 +954,0 @@ Object.defineProperty(exports, '__esModule', { value: true });

@@ -1,1 +0,1 @@

!function(e){if(!e.VueDemi){var t={},n=e.Vue;if(n)if("2."===n.version.slice(0,2)){var u=e.VueCompositionAPI;if(u){for(var r in u)t[r]=u[r];t.isVue2=!0,t.isVue3=!1,t.install=function(){},t.Vue=n,t.Vue2=n,t.version=n.version}else console.error("[vue-demi] no VueCompositionAPI instance found, please be sure to import `@vue/composition-api` before `vue-demi`.")}else if("3."===n.version.slice(0,2)){for(var r in n)t[r]=n[r];t.isVue2=!1,t.isVue3=!0,t.install=function(){},t.Vue=n,t.Vue2=void 0,t.version=n.version,t.set=function(e,t,n){return Array.isArray(e)?(e.length=Math.max(e.length,t),e.splice(t,1,n),n):(e[t]=n,n)},t.del=function(e,t){Array.isArray(e)?e.splice(t,1):delete e[t]}}else console.error("[vue-demi] Vue version "+n.version+" is unsupported.");else console.error("[vue-demi] no Vue instance found, please be sure to import `vue` before `vue-demi`.");e.VueDemi=t}}(window),function(e,t){"use strict";function n(e,n,{enumerable:u=!1,unwrap:r=!0}={}){!function(e="this function"){if(!t.isVue3)throw new Error(`[VueUse] ${e} is only works on Vue 3.`)}();for(const[o,i]of Object.entries(n))"value"!==o&&(t.isRef(i)&&r?Object.defineProperty(e,o,{get:()=>i.value,set(e){i.value=e},enumerable:u}):Object.defineProperty(e,o,{value:i,enumerable:u}));return e}function u(e,t){var n={};for(var u in e)Object.prototype.hasOwnProperty.call(e,u)&&t.indexOf(u)<0&&(n[u]=e[u]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var r=0;for(u=Object.getOwnPropertySymbols(e);r<u.length;r++)t.indexOf(u[r])<0&&Object.prototype.propertyIsEnumerable.call(e,u[r])&&(n[u[r]]=e[u[r]])}return n}const r="undefined"!=typeof window,o=Object.prototype.toString;function i(e,t){return function(...n){e((()=>t.apply(this,n)),{fn:t,thisArg:this,args:n})}}const s=e=>e();function c(e){let n;return u=>{const r=t.unref(e);if(n&&clearTimeout(n),r<=0)return u();n=setTimeout(u,r)}}function l(e,n=!0){let u,r=0;const o=()=>{u&&(clearTimeout(u),u=void 0)};return i=>{const s=t.unref(e),c=Date.now()-r;if(o(),s<=0)return r=Date.now(),i();c>s?(r=Date.now(),i()):n&&(u=setTimeout((()=>{o(),i()}),s))}}function a(e=s){const n=t.ref(!0);return{isActive:n,pause:function(){n.value=!1},resume:function(){n.value=!0},eventFilter:(...t)=>{n.value&&e(...t)}}}function f(e,t=!1,n="Timeout"){return new Promise(((u,r)=>{t?setTimeout((()=>r(n)),e):setTimeout(u,e)}))}function v(e,n,r={}){const{eventFilter:o=s}=r,c=u(r,["eventFilter"]);return t.watch(e,i(o,n),c)}function m(e){return function(...n){return t.computed((()=>e.apply(this,n.map((e=>t.unref(e))))))}}function p(e){t.getCurrentInstance()&&t.onUnmounted(e)}function d(e,t=200){return i(c(t),e)}function h(e,n=1e3,u=!0){let o=null;const i=t.ref(!1);function s(){o&&(clearInterval(o),o=null)}function c(){i.value=!1,s()}function l(){n<=0||(i.value=!0,s(),o=setInterval(e,n))}return u&&r&&l(),p(c),{isActive:i,pause:c,resume:l,start:l,stop:c}}function b(e,t=200,n=!0){return i(l(t,n),e)}function y(e,n,u=!0){const o=t.ref(!1);let i=null;function s(){i&&(clearTimeout(i),i=null)}function c(){o.value=!1,s()}function l(...t){s(),o.value=!0,i=setTimeout((()=>{o.value=!1,i=null,e(...t)}),n)}return u&&(o.value=!0,r&&l()),p(c),{isPending:o,start:l,stop:c,isActive:o}}e.assert=(e,...t)=>{e||console.warn(...t)},e.biSyncRef=function(e,n){const u="sync",r=t.watch(e,(e=>{n.value=e}),{flush:u,immediate:!0}),o=t.watch(n,(t=>{e.value=t}),{flush:u,immediate:!0});return()=>{r(),o()}},e.bypassFilter=s,e.clamp=(e,t,n)=>Math.min(n,Math.max(t,e)),e.containsProp=function(e,...t){return t.some((t=>t in e))},e.controlledComputed=function(e,n){let u,r,o;const i=t.ref(!0);return t.watch(e,(()=>{i.value=!0,o()}),{flush:"sync"}),t.customRef(((e,t)=>(r=e,o=t,{get:()=>(i.value&&(u=n(),i.value=!1),r(),u),set(){}})))},e.controlledRef=function(e,u={}){let r,o,i=e;function s(e=!0){return e&&r(),i}function c(e,t=!0){var n,r;if(e===i)return;const s=i;!1!==(null===(n=u.onBeforeChange)||void 0===n?void 0:n.call(u,e,s))&&(i=e,null===(r=u.onChanged)||void 0===r||r.call(u,e,s),t&&o())}return n(t.customRef(((e,t)=>(r=e,o=t,{get:()=>s(),set(e){c(e)}}))),{get:s,set:c,untrackedGet:()=>s(!1),silentSet:e=>c(e,!1),peek:()=>s(!1),lay:e=>c(e,!1)},{enumerable:!0})},e.createFilterWrapper=i,e.debounceFilter=c,e.debouncedWatch=function(e,t,n={}){const{debounce:r=0}=n,o=u(n,["debounce"]);return v(e,t,Object.assign(Object.assign({},o),{eventFilter:c(r)}))},e.extendRef=n,e.get=function(e,n){return null==n?t.unref(e):t.unref(e)[n]},e.ignorableWatch=function(e,n,r={}){const{eventFilter:o=s}=r,c=u(r,["eventFilter"]),l=i(o,n);let a,f,v;if("sync"===c.flush){const n=t.ref(!1);f=()=>{},a=e=>{n.value=!0,e(),n.value=!1},v=t.watch(e,((...e)=>{n.value||l(...e)}),c)}else{const n=[],u=t.ref(0),r=t.ref(0);f=()=>{u.value=r.value},n.push(t.watch(e,(()=>{r.value++}),Object.assign(Object.assign({},c),{flush:"sync"}))),a=e=>{const t=r.value;e(),u.value+=r.value-t},n.push(t.watch(e,((...e)=>{const t=u.value>0&&u.value===r.value;u.value=0,r.value=0,t||l(...e)}),c)),v=()=>{n.forEach((e=>e()))}}return{stop:v,ignoreUpdates:a,ignorePrevAsyncUpdates:f}},e.increaseWithUnit=function(e,t){var n;if("number"==typeof e)return e+t;const u=(null===(n=e.match(/^-?[0-9]+\.?[0-9]*/))||void 0===n?void 0:n[0])||"",r=e.slice(u.length),o=parseFloat(u)+t;return Number.isNaN(o)?e:o+r},e.invoke=function(e){return e()},e.isBoolean=e=>"boolean"==typeof e,e.isClient=r,e.isDef=e=>void 0!==e,e.isFunction=e=>"function"==typeof e,e.isNumber=e=>"number"==typeof e,e.isObject=e=>"[object Object]"===o.call(e),e.isString=e=>"string"==typeof e,e.isWindow=e=>"undefined"!=typeof window&&"[object Window]"===o.call(e),e.makeDestructurable=function(e,t){if("undefined"!=typeof Symbol){const n=Object.assign({},e);return Object.defineProperty(n,Symbol.iterator,{enumerable:!1,value(){let e=0;return{next:()=>({value:t[e++],done:e>t.length})}}}),n}return Object.assign([...t],e)},e.noop=()=>{},e.now=()=>Date.now(),e.pausableFilter=a,e.pausableWatch=function(e,t,n={}){const{eventFilter:r}=n,o=u(n,["eventFilter"]),{eventFilter:i,pause:s,resume:c,isActive:l}=a(r);return{stop:v(e,t,Object.assign(Object.assign({},o),{eventFilter:i})),pause:s,resume:c,isActive:l}},e.promiseTimeout=f,e.reactify=m,e.reactifyObject=function(e,t={}){let n=[];if(Array.isArray(t))n=t;else{const{includeOwnProperties:u=!0}=t;n.push(...Object.keys(e)),u&&n.push(...Object.getOwnPropertyNames(e))}return Object.fromEntries(n.map((t=>{const n=e[t];return[t,"function"==typeof n?m(n.bind(e)):n]})))},e.set=function(...e){if(2===e.length){const[t,n]=e;t.value=n}if(3===e.length)if(t.isVue2)require("vue-demi").set(...e);else{const[t,n,u]=e;t[n]=u}},e.syncRef=function(e,n,{flush:u="sync",deep:r=!1,immediate:o=!0}={}){return Array.isArray(n)||(n=[n]),t.watch(e,(e=>{n.forEach((t=>t.value=e))}),{flush:u,deep:r,immediate:o})},e.throttleFilter=l,e.throttledWatch=function(e,t,n={}){const{throttle:r=0}=n,o=u(n,["throttle"]);return v(e,t,Object.assign(Object.assign({},o),{eventFilter:l(r)}))},e.timestamp=()=>+Date.now(),e.tryOnMounted=function(e,n=!0){t.getCurrentInstance()?t.onMounted(e):n?e():t.nextTick(e)},e.tryOnUnmounted=p,e.useCounter=function(e=0){const n=t.ref(e),u=e=>n.value=e;return{count:n,inc:(e=1)=>n.value+=e,dec:(e=1)=>n.value-=e,get:()=>n.value,set:u,reset:(t=e)=>(e=t,u(t))}},e.useDebounce=function(e,n=200){if(n<=0)return e;const u=t.ref(e.value),r=d((()=>{u.value=e.value}),n);return t.watch(e,(()=>r())),u},e.useDebounceFn=d,e.useInterval=function(e=1e3,n=!0){const u=t.ref(0);return Object.assign({counter:u},h((()=>u.value+=1),e,n))},e.useIntervalFn=h,e.useThrottle=function(e,n=200){if(n<=0)return e;const u=t.ref(e.value),r=b((()=>{u.value=e.value}),n);return t.watch(e,(()=>r())),u},e.useThrottleFn=b,e.useTimeout=function(e=1e3,n=!0){const u=t.ref(!1),r=y((()=>u.value=!0),e,n);return{ready:u,isActive:r.isActive,start:function(){u.value=!1,r.start()},stop:function(){u.value=!1,r.stop()}}},e.useTimeoutFn=y,e.useToggle=function(e=!1){if(t.isRef(e))return()=>e.value=!e.value;{const n=t.ref(e),u=()=>n.value=!n.value;return[n,u]}},e.watchWithFilter=v,e.when=function(e){let n=!1;function u(u,{flush:r="sync",deep:o=!1,timeout:i,throwOnTimeout:s}={}){let c=null;const l=[new Promise((i=>{c=t.watch(e,(e=>{u(e)===!n&&(null==c||c(),i())}),{flush:r,deep:o,immediate:!0})}))];return i&&l.push(f(i,s).finally((()=>{null==c||c()}))),Promise.race(l)}function r(e,n){return u((n=>n===t.unref(e)),n)}function o(e){return i(1,e)}function i(e=1,t){let n=-1;return u((()=>(n+=1,n>=e)),t)}if(Array.isArray(t.unref(e))){return{toMatch:u,toContains:function(e,n){return u((n=>{const u=Array.from(n);return u.includes(e)||u.includes(t.unref(e))}),n)},changed:o,changedTimes:i,get not(){return n=!n,this}}}return{toMatch:u,toBe:r,toBeTruthy:function(e){return u((e=>Boolean(e)),e)},toBeNull:function(e){return r(null,e)},toBeNaN:function(e){return u(Number.isNaN,e)},toBeUndefined:function(e){return r(void 0,e)},changed:o,changedTimes:i,get not(){return n=!n,this}}},Object.defineProperty(e,"__esModule",{value:!0})}(this.VueUse=this.VueUse||{},VueDemi);
!function(e){if(!e.VueDemi){var t={},n=e.Vue;if(n)if("2."===n.version.slice(0,2)){var u=e.VueCompositionAPI;if(u){for(var r in u)t[r]=u[r];t.isVue2=!0,t.isVue3=!1,t.install=function(){},t.Vue=n,t.Vue2=n,t.version=n.version}else console.error("[vue-demi] no VueCompositionAPI instance found, please be sure to import `@vue/composition-api` before `vue-demi`.")}else if("3."===n.version.slice(0,2)){for(var r in n)t[r]=n[r];t.isVue2=!1,t.isVue3=!0,t.install=function(){},t.Vue=n,t.Vue2=void 0,t.version=n.version,t.set=function(e,t,n){return Array.isArray(e)?(e.length=Math.max(e.length,t),e.splice(t,1,n),n):(e[t]=n,n)},t.del=function(e,t){Array.isArray(e)?e.splice(t,1):delete e[t]}}else console.error("[vue-demi] Vue version "+n.version+" is unsupported.");else console.error("[vue-demi] no Vue instance found, please be sure to import `vue` before `vue-demi`.");e.VueDemi=t}}(window),function(e,t){"use strict";function n(e,n,{enumerable:u=!1,unwrap:r=!0}={}){!function(e="this function"){if(!t.isVue3)throw new Error(`[VueUse] ${e} is only works on Vue 3.`)}();for(const[o,i]of Object.entries(n))"value"!==o&&(t.isRef(i)&&r?Object.defineProperty(e,o,{get:()=>i.value,set(e){i.value=e},enumerable:u}):Object.defineProperty(e,o,{value:i,enumerable:u}));return e}function u(e,t){var n={};for(var u in e)Object.prototype.hasOwnProperty.call(e,u)&&t.indexOf(u)<0&&(n[u]=e[u]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var r=0;for(u=Object.getOwnPropertySymbols(e);r<u.length;r++)t.indexOf(u[r])<0&&Object.prototype.propertyIsEnumerable.call(e,u[r])&&(n[u[r]]=e[u[r]])}return n}const r="undefined"!=typeof window,o=Object.prototype.toString;function i(e,t){return function(...n){e((()=>t.apply(this,n)),{fn:t,thisArg:this,args:n})}}const s=e=>e();function c(e){let n;return u=>{const r=t.unref(e);if(n&&clearTimeout(n),r<=0)return u();n=setTimeout(u,r)}}function l(e,n=!0){let u,r=0;const o=()=>{u&&(clearTimeout(u),u=void 0)};return i=>{const s=t.unref(e),c=Date.now()-r;if(o(),s<=0)return r=Date.now(),i();c>s?(r=Date.now(),i()):n&&(u=setTimeout((()=>{o(),i()}),s))}}function a(e=s){const n=t.ref(!0);return{isActive:n,pause:function(){n.value=!1},resume:function(){n.value=!0},eventFilter:(...t)=>{n.value&&e(...t)}}}function f(e,t=!1,n="Timeout"){return new Promise(((u,r)=>{t?setTimeout((()=>r(n)),e):setTimeout(u,e)}))}function v(e,n,r={}){const{eventFilter:o=s}=r,c=u(r,["eventFilter"]);return t.watch(e,i(o,n),c)}function m(e){return function(...n){return t.computed((()=>e.apply(this,n.map((e=>t.unref(e))))))}}function p(e){t.getCurrentInstance()&&t.onUnmounted(e)}function d(e){let n=!1;function u(u,{flush:r="sync",deep:o=!1,timeout:i,throwOnTimeout:s}={}){let c=null;const l=[new Promise((i=>{c=t.watch(e,(e=>{u(e)===!n&&(null==c||c(),i())}),{flush:r,deep:o,immediate:!0})}))];return i&&l.push(f(i,s).finally((()=>{null==c||c()}))),Promise.race(l)}function r(e,n){return u((n=>n===t.unref(e)),n)}function o(e){return i(1,e)}function i(e=1,t){let n=-1;return u((()=>(n+=1,n>=e)),t)}if(Array.isArray(t.unref(e))){return{toMatch:u,toContains:function(e,n){return u((n=>{const u=Array.from(n);return u.includes(e)||u.includes(t.unref(e))}),n)},changed:o,changedTimes:i,get not(){return n=!n,this}}}return{toMatch:u,toBe:r,toBeTruthy:function(e){return u((e=>Boolean(e)),e)},toBeNull:function(e){return r(null,e)},toBeNaN:function(e){return u(Number.isNaN,e)},toBeUndefined:function(e){return r(void 0,e)},changed:o,changedTimes:i,get not(){return n=!n,this}}}const h=d;function b(e,t=200){return i(c(t),e)}function y(e,n=1e3,u=!0){let o=null;const i=t.ref(!1);function s(){o&&(clearInterval(o),o=null)}function c(){i.value=!1,s()}function l(){n<=0||(i.value=!0,s(),o=setInterval(e,n))}return u&&r&&l(),p(c),{isActive:i,pause:c,resume:l,start:l,stop:c}}function g(e,t=200,n=!0){return i(l(t,n),e)}function w(e,n,u=!0){const o=t.ref(!1);let i=null;function s(){i&&(clearTimeout(i),i=null)}function c(){o.value=!1,s()}function l(...t){s(),o.value=!0,i=setTimeout((()=>{o.value=!1,i=null,e(...t)}),n)}return u&&(o.value=!0,r&&l()),p(c),{isPending:o,start:l,stop:c,isActive:o}}e.assert=(e,...t)=>{e||console.warn(...t)},e.biSyncRef=function(e,n){const u="sync",r=t.watch(e,(e=>{n.value=e}),{flush:u,immediate:!0}),o=t.watch(n,(t=>{e.value=t}),{flush:u,immediate:!0});return()=>{r(),o()}},e.bypassFilter=s,e.clamp=(e,t,n)=>Math.min(n,Math.max(t,e)),e.containsProp=function(e,...t){return t.some((t=>t in e))},e.controlledComputed=function(e,n){let u,r,o;const i=t.ref(!0);return t.watch(e,(()=>{i.value=!0,o()}),{flush:"sync"}),t.customRef(((e,t)=>(r=e,o=t,{get:()=>(i.value&&(u=n(),i.value=!1),r(),u),set(){}})))},e.controlledRef=function(e,u={}){let r,o,i=e;function s(e=!0){return e&&r(),i}function c(e,t=!0){var n,r;if(e===i)return;const s=i;!1!==(null===(n=u.onBeforeChange)||void 0===n?void 0:n.call(u,e,s))&&(i=e,null===(r=u.onChanged)||void 0===r||r.call(u,e,s),t&&o())}return n(t.customRef(((e,t)=>(r=e,o=t,{get:()=>s(),set(e){c(e)}}))),{get:s,set:c,untrackedGet:()=>s(!1),silentSet:e=>c(e,!1),peek:()=>s(!1),lay:e=>c(e,!1)},{enumerable:!0})},e.createFilterWrapper=i,e.debounceFilter=c,e.debouncedWatch=function(e,t,n={}){const{debounce:r=0}=n,o=u(n,["debounce"]);return v(e,t,Object.assign(Object.assign({},o),{eventFilter:c(r)}))},e.extendRef=n,e.get=function(e,n){return null==n?t.unref(e):t.unref(e)[n]},e.ignorableWatch=function(e,n,r={}){const{eventFilter:o=s}=r,c=u(r,["eventFilter"]),l=i(o,n);let a,f,v;if("sync"===c.flush){const n=t.ref(!1);f=()=>{},a=e=>{n.value=!0,e(),n.value=!1},v=t.watch(e,((...e)=>{n.value||l(...e)}),c)}else{const n=[],u=t.ref(0),r=t.ref(0);f=()=>{u.value=r.value},n.push(t.watch(e,(()=>{r.value++}),Object.assign(Object.assign({},c),{flush:"sync"}))),a=e=>{const t=r.value;e(),u.value+=r.value-t},n.push(t.watch(e,((...e)=>{const t=u.value>0&&u.value===r.value;u.value=0,r.value=0,t||l(...e)}),c)),v=()=>{n.forEach((e=>e()))}}return{stop:v,ignoreUpdates:a,ignorePrevAsyncUpdates:f}},e.increaseWithUnit=function(e,t){var n;if("number"==typeof e)return e+t;const u=(null===(n=e.match(/^-?[0-9]+\.?[0-9]*/))||void 0===n?void 0:n[0])||"",r=e.slice(u.length),o=parseFloat(u)+t;return Number.isNaN(o)?e:o+r},e.invoke=function(e){return e()},e.isBoolean=e=>"boolean"==typeof e,e.isClient=r,e.isDef=e=>void 0!==e,e.isFunction=e=>"function"==typeof e,e.isNumber=e=>"number"==typeof e,e.isObject=e=>"[object Object]"===o.call(e),e.isString=e=>"string"==typeof e,e.isWindow=e=>"undefined"!=typeof window&&"[object Window]"===o.call(e),e.makeDestructurable=function(e,t){if("undefined"!=typeof Symbol){const n=Object.assign({},e);return Object.defineProperty(n,Symbol.iterator,{enumerable:!1,value(){let e=0;return{next:()=>({value:t[e++],done:e>t.length})}}}),n}return Object.assign([...t],e)},e.noop=()=>{},e.now=()=>Date.now(),e.pausableFilter=a,e.pausableWatch=function(e,t,n={}){const{eventFilter:r}=n,o=u(n,["eventFilter"]),{eventFilter:i,pause:s,resume:c,isActive:l}=a(r);return{stop:v(e,t,Object.assign(Object.assign({},o),{eventFilter:i})),pause:s,resume:c,isActive:l}},e.promiseTimeout=f,e.reactify=m,e.reactifyObject=function(e,t={}){let n=[];if(Array.isArray(t))n=t;else{const{includeOwnProperties:u=!0}=t;n.push(...Object.keys(e)),u&&n.push(...Object.getOwnPropertyNames(e))}return Object.fromEntries(n.map((t=>{const n=e[t];return[t,"function"==typeof n?m(n.bind(e)):n]})))},e.set=function(...e){if(2===e.length){const[t,n]=e;t.value=n}if(3===e.length)if(t.isVue2)require("vue-demi").set(...e);else{const[t,n,u]=e;t[n]=u}},e.syncRef=function(e,n,{flush:u="sync",deep:r=!1,immediate:o=!0}={}){return Array.isArray(n)||(n=[n]),t.watch(e,(e=>{n.forEach((t=>t.value=e))}),{flush:u,deep:r,immediate:o})},e.throttleFilter=l,e.throttledWatch=function(e,t,n={}){const{throttle:r=0}=n,o=u(n,["throttle"]);return v(e,t,Object.assign(Object.assign({},o),{eventFilter:l(r)}))},e.timestamp=()=>+Date.now(),e.tryOnMounted=function(e,n=!0){t.getCurrentInstance()?t.onMounted(e):n?e():t.nextTick(e)},e.tryOnUnmounted=p,e.until=d,e.useCounter=function(e=0){const n=t.ref(e),u=e=>n.value=e;return{count:n,inc:(e=1)=>n.value+=e,dec:(e=1)=>n.value-=e,get:()=>n.value,set:u,reset:(t=e)=>(e=t,u(t))}},e.useDebounce=function(e,n=200){if(n<=0)return e;const u=t.ref(e.value),r=b((()=>{u.value=e.value}),n);return t.watch(e,(()=>r())),u},e.useDebounceFn=b,e.useInterval=function(e=1e3,n=!0){const u=t.ref(0);return Object.assign({counter:u},y((()=>u.value+=1),e,n))},e.useIntervalFn=y,e.useThrottle=function(e,n=200){if(n<=0)return e;const u=t.ref(e.value),r=g((()=>{u.value=e.value}),n);return t.watch(e,(()=>r())),u},e.useThrottleFn=g,e.useTimeout=function(e=1e3,n=!0){const u=t.ref(!1),r=w((()=>u.value=!0),e,n);return{ready:u,isActive:r.isActive,start:function(){u.value=!1,r.start()},stop:function(){u.value=!1,r.stop()}}},e.useTimeoutFn=w,e.useToggle=function(e=!1){if(t.isRef(e))return()=>e.value=!e.value;{const n=t.ref(e),u=()=>n.value=!n.value;return[n,u]}},e.watchWithFilter=v,e.when=h,e.whenever=function(e,n,u){return t.watch(e,(e=>{e&&n()}),u)},Object.defineProperty(e,"__esModule",{value:!0})}(this.VueUse=this.VueUse||{},VueDemi);
{
"name": "@vueuse/shared",
"version": "4.6.4",
"version": "4.7.0",
"main": "./dist/index.cjs.js",

@@ -5,0 +5,0 @@ "types": "./dist/index.d.ts",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc