Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@vueuse/shared

Package Overview
Dependencies
Maintainers
1
Versions
237
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.0.0-beta.28 to 4.0.0-beta.29

163

dist/index.cjs.js

@@ -6,21 +6,4 @@ 'use strict';

var vueDemi = require('vue-demi');
var shared = require('@vueuse/shared');
const isClient = typeof window !== 'undefined';
const isDef = (val) => typeof val !== 'undefined';
const assert = (condition, ...infos) => {
if (!condition)
console.warn(...infos);
};
const toString = Object.prototype.toString;
const isBoolean = (val) => typeof val === 'boolean';
const isFunction = (val) => typeof val === 'function';
const isNumber = (val) => typeof val === 'number';
const isString = (val) => typeof val === 'string';
const isObject = (val) => toString.call(val) === '[object Object]';
const isWindow = (val) => typeof window !== 'undefined' && toString.call(val) === '[object Window]';
const now = () => Date.now();
const timestamp = () => +Date.now();
const clamp = (n, min, max) => Math.min(max, Math.max(min, n));
const noop = () => { };
/**

@@ -32,7 +15,52 @@ * Explicitly define the deps of computed

*/
function explicitComputed(source, fn) {
const v = vueDemi.reactive({ value: fn() });
function controlledComputed(source, fn) {
const v = vueDemi.ref(fn());
vueDemi.watch(source, () => v.value = fn());
return vueDemi.computed(() => v.value);
}
function extendRef(ref, extend, enumerable = true) {
for (const [key, value] of Object.entries(extend)) {
if (key === 'value')
continue;
if (vueDemi.isRef(value)) {
Object.defineProperty(ref, key, {
get() {
return value.value;
},
set(v) {
value.value = v;
},
enumerable,
});
}
else {
Object.defineProperty(ref, key, { value, enumerable });
}
}
return ref;
}
function makeDestructurable(obj, arr) {
if (typeof Symbol !== 'undefined') {
const clone = Object.assign({}, obj);
Object.defineProperty(clone, Symbol.iterator, {
enumerable: false,
value() {
let index = 0;
return {
next: () => ({
value: arr[index++],
done: index > arr.length,
}),
};
},
});
return clone;
}
else {
return Object.assign([...arr], obj);
}
}
/**

@@ -52,2 +80,3 @@ * Call onMounted() if it's inside a component lifecycle, if not, run just call the function

}
/**

@@ -62,2 +91,21 @@ * Call onUnmounted() if it's inside a component lifecycle, if not, do nothing

}
const isClient = typeof window !== 'undefined';
const isDef = (val) => typeof val !== 'undefined';
const assert = (condition, ...infos) => {
if (!condition)
console.warn(...infos);
};
const toString = Object.prototype.toString;
const isBoolean = (val) => typeof val === 'boolean';
const isFunction = (val) => typeof val === 'function';
const isNumber = (val) => typeof val === 'number';
const isString = (val) => typeof val === 'string';
const isObject = (val) => toString.call(val) === '[object Object]';
const isWindow = (val) => typeof window !== 'undefined' && toString.call(val) === '[object Window]';
const now = () => Date.now();
const timestamp = () => +Date.now();
const clamp = (n, min, max) => Math.min(max, Math.max(min, n));
const noop = () => { };
function promiseTimeout(ms, throwOnTimeout = false, reason = 'Timeout') {

@@ -75,5 +123,76 @@ return new Promise((resolve, reject) => {

function when(r) {
let isNot = false;
function toMatch(condition, { flush = 'sync', 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,
immediate: true,
});
});
const promises = [watcher];
if (timeout) {
promises.push(shared.promiseTimeout(timeout, throwOnTimeout)
.finally(() => { stop === null || stop === void 0 ? void 0 : stop(); }));
}
return Promise.race(promises);
}
function toBe(value, options) {
return toMatch(v => v === 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 toContain(value, options) {
return toMatch((v) => {
const array = Array.from(v);
return array.includes(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);
}
return {
toMatch,
toBe,
toBeTruthy,
toBeNull,
toBeNaN,
toBeUndefined,
toContain,
changed,
changedTimes,
get not() {
isNot = !isNot;
return this;
},
};
}
exports.assert = assert;
exports.clamp = clamp;
exports.explicitComputed = explicitComputed;
exports.controlledComputed = controlledComputed;
exports.extendRef = extendRef;
exports.invoke = invoke;

@@ -88,2 +207,3 @@ exports.isBoolean = isBoolean;

exports.isWindow = isWindow;
exports.makeDestructurable = makeDestructurable;
exports.noop = noop;

@@ -95,1 +215,2 @@ exports.now = now;

exports.tryOnUnmounted = tryOnUnmounted;
exports.when = when;

62

dist/index.d.ts
import { ComputedRef } from 'vue-demi';
import { Ref, WatchSource } from 'vue-demi';
import { WatchSource, Ref, ShallowUnwrapRef, WatchOptions } from 'vue-demi';
declare const isClient: boolean;
declare const isDef: <T = any>(val?: T | undefined) => val is T;
declare const assert: (condition: boolean, ...infos: any[]) => void;
declare const isBoolean: (val: any) => val is boolean;
declare const isFunction: <T = Function>(val: any) => val is T;
declare const isNumber: (val: any) => val is number;
declare const isString: (val: unknown) => val is string;
declare const isObject: (val: any) => val is object;
declare const isWindow: (val: any) => val is Window;
declare const now: () => number;
declare const timestamp: () => number;
declare const clamp: (n: number, min: number, max: number) => number;
declare const noop: () => void;
declare type MaybeRef<T> = T | Ref<T>;
/**

@@ -25,3 +10,8 @@ * Explicitly define the deps of computed

*/
declare function explicitComputed<T, S>(source: WatchSource<S>, fn: () => T): ComputedRef<T>;
declare function controlledComputed<T, S>(source: WatchSource<S>, fn: () => T): ComputedRef<T>;
declare function extendRef<R extends Ref<any>, Extend extends object>(ref: R, extend: Extend, enumerable?: boolean): ShallowUnwrapRef<Extend> & R;
declare function makeDestructurable<T extends Record<string, unknown>, A extends readonly any[]>(obj: T, arr: A): T & A;
/**

@@ -34,2 +24,3 @@ * Call onMounted() if it's inside a component lifecycle, if not, run just call the function

declare function tryOnMounted(fn: () => void, sync?: boolean): void;
/**

@@ -41,5 +32,40 @@ * Call onUnmounted() if it's inside a component lifecycle, if not, do nothing

declare function tryOnUnmounted(fn: () => void): void;
declare const isClient: boolean;
declare const isDef: <T = any>(val?: T | undefined) => val is T;
declare const assert: (condition: boolean, ...infos: any[]) => void;
declare const isBoolean: (val: any) => val is boolean;
declare const isFunction: <T = Function>(val: any) => val is T;
declare const isNumber: (val: any) => val is number;
declare const isString: (val: unknown) => val is string;
declare const isObject: (val: any) => val is object;
declare const isWindow: (val: any) => val is Window;
declare const now: () => number;
declare const timestamp: () => number;
declare const clamp: (n: number, min: number, max: number) => number;
declare const noop: () => void;
declare type MaybeRef<T> = T | Ref<T>;
declare function promiseTimeout(ms: number, throwOnTimeout?: boolean, reason?: string): Promise<void>;
declare function invoke<T>(fn: () => T): T;
export { MaybeRef, assert, clamp, explicitComputed, invoke, isBoolean, isClient, isDef, isFunction, isNumber, isObject, isString, isWindow, noop, now, promiseTimeout, timestamp, tryOnMounted, tryOnUnmounted };
interface WhenToMatchOptions {
flush?: WatchOptions['flush'];
timeout?: number;
throwOnTimeout?: boolean;
}
interface WhenInstance<T> {
readonly not: WhenInstance<T>;
toMatch(condition: (v: T | object) => boolean, options?: WhenToMatchOptions): Promise<void>;
toBe<P>(value: P | T, options?: WhenToMatchOptions): Promise<void>;
toBeTruthy(options?: WhenToMatchOptions): Promise<void>;
toBeNull(options?: WhenToMatchOptions): Promise<void>;
toBeUndefined(options?: WhenToMatchOptions): Promise<void>;
toBeNaN(options?: WhenToMatchOptions): Promise<void>;
toContain<P>(value: P, options?: WhenToMatchOptions): Promise<void>;
changed(options?: WhenToMatchOptions): Promise<void>;
changedTimes(n?: number, options?: WhenToMatchOptions): Promise<void>;
}
declare function when<T>(r: WatchSource<T> | object): WhenInstance<T>;
export { MaybeRef, WhenInstance, WhenToMatchOptions, assert, clamp, controlledComputed, extendRef, invoke, isBoolean, isClient, isDef, isFunction, isNumber, isObject, isString, isWindow, makeDestructurable, noop, now, promiseTimeout, timestamp, tryOnMounted, tryOnUnmounted, when };

@@ -1,21 +0,4 @@

import { reactive, watch, computed, getCurrentInstance, onMounted, nextTick, onUnmounted } from 'vue-demi';
import { ref, watch, computed, isRef, getCurrentInstance, onMounted, nextTick, onUnmounted } from 'vue-demi';
import { promiseTimeout as promiseTimeout$1 } from '@vueuse/shared';
const isClient = typeof window !== 'undefined';
const isDef = (val) => typeof val !== 'undefined';
const assert = (condition, ...infos) => {
if (!condition)
console.warn(...infos);
};
const toString = Object.prototype.toString;
const isBoolean = (val) => typeof val === 'boolean';
const isFunction = (val) => typeof val === 'function';
const isNumber = (val) => typeof val === 'number';
const isString = (val) => typeof val === 'string';
const isObject = (val) => toString.call(val) === '[object Object]';
const isWindow = (val) => typeof window !== 'undefined' && toString.call(val) === '[object Window]';
const now = () => Date.now();
const timestamp = () => +Date.now();
const clamp = (n, min, max) => Math.min(max, Math.max(min, n));
const noop = () => { };
/**

@@ -27,7 +10,52 @@ * Explicitly define the deps of computed

*/
function explicitComputed(source, fn) {
const v = reactive({ value: fn() });
function controlledComputed(source, fn) {
const v = ref(fn());
watch(source, () => v.value = fn());
return computed(() => v.value);
}
function extendRef(ref, extend, enumerable = true) {
for (const [key, value] of Object.entries(extend)) {
if (key === 'value')
continue;
if (isRef(value)) {
Object.defineProperty(ref, key, {
get() {
return value.value;
},
set(v) {
value.value = v;
},
enumerable,
});
}
else {
Object.defineProperty(ref, key, { value, enumerable });
}
}
return ref;
}
function makeDestructurable(obj, arr) {
if (typeof Symbol !== 'undefined') {
const clone = Object.assign({}, obj);
Object.defineProperty(clone, Symbol.iterator, {
enumerable: false,
value() {
let index = 0;
return {
next: () => ({
value: arr[index++],
done: index > arr.length,
}),
};
},
});
return clone;
}
else {
return Object.assign([...arr], obj);
}
}
/**

@@ -47,2 +75,3 @@ * Call onMounted() if it's inside a component lifecycle, if not, run just call the function

}
/**

@@ -57,2 +86,21 @@ * Call onUnmounted() if it's inside a component lifecycle, if not, do nothing

}
const isClient = typeof window !== 'undefined';
const isDef = (val) => typeof val !== 'undefined';
const assert = (condition, ...infos) => {
if (!condition)
console.warn(...infos);
};
const toString = Object.prototype.toString;
const isBoolean = (val) => typeof val === 'boolean';
const isFunction = (val) => typeof val === 'function';
const isNumber = (val) => typeof val === 'number';
const isString = (val) => typeof val === 'string';
const isObject = (val) => toString.call(val) === '[object Object]';
const isWindow = (val) => typeof window !== 'undefined' && toString.call(val) === '[object Window]';
const now = () => Date.now();
const timestamp = () => +Date.now();
const clamp = (n, min, max) => Math.min(max, Math.max(min, n));
const noop = () => { };
function promiseTimeout(ms, throwOnTimeout = false, reason = 'Timeout') {

@@ -70,2 +118,72 @@ return new Promise((resolve, reject) => {

export { assert, clamp, explicitComputed, invoke, isBoolean, isClient, isDef, isFunction, isNumber, isObject, isString, isWindow, noop, now, promiseTimeout, timestamp, tryOnMounted, tryOnUnmounted };
function when(r) {
let isNot = false;
function toMatch(condition, { flush = 'sync', 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,
immediate: true,
});
});
const promises = [watcher];
if (timeout) {
promises.push(promiseTimeout$1(timeout, throwOnTimeout)
.finally(() => { stop === null || stop === void 0 ? void 0 : stop(); }));
}
return Promise.race(promises);
}
function toBe(value, options) {
return toMatch(v => v === 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 toContain(value, options) {
return toMatch((v) => {
const array = Array.from(v);
return array.includes(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);
}
return {
toMatch,
toBe,
toBeTruthy,
toBeNull,
toBeNaN,
toBeUndefined,
toContain,
changed,
changedTimes,
get not() {
isNot = !isNot;
return this;
},
};
}
export { assert, clamp, controlledComputed, extendRef, invoke, isBoolean, isClient, isDef, isFunction, isNumber, isObject, isString, isWindow, makeDestructurable, noop, now, promiseTimeout, timestamp, tryOnMounted, tryOnUnmounted, when };
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('vue-demi')) :
typeof define === 'function' && define.amd ? define(['exports', 'vue-demi'], factory) :
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global['VueUseShared utilities'] = {}, global.VueDemi));
}(this, (function (exports, vueDemi) { 'use strict';
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('vue-demi'), require('@vueuse/shared')) :
typeof define === 'function' && define.amd ? define(['exports', 'vue-demi', '@vueuse/shared'], factory) :
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global['VueUseShared utilities'] = {}, global.VueDemi, global.VueUseShared));
}(this, (function (exports, vueDemi, shared) { 'use strict';
const isClient = typeof window !== 'undefined';
const isDef = (val) => typeof val !== 'undefined';
const assert = (condition, ...infos) => {
if (!condition)
console.warn(...infos);
};
const toString = Object.prototype.toString;
const isBoolean = (val) => typeof val === 'boolean';
const isFunction = (val) => typeof val === 'function';
const isNumber = (val) => typeof val === 'number';
const isString = (val) => typeof val === 'string';
const isObject = (val) => toString.call(val) === '[object Object]';
const isWindow = (val) => typeof window !== 'undefined' && toString.call(val) === '[object Window]';
const now = () => Date.now();
const timestamp = () => +Date.now();
const clamp = (n, min, max) => Math.min(max, Math.max(min, n));
const noop = () => { };
/**

@@ -31,7 +13,52 @@ * Explicitly define the deps of computed

*/
function explicitComputed(source, fn) {
const v = vueDemi.reactive({ value: fn() });
function controlledComputed(source, fn) {
const v = vueDemi.ref(fn());
vueDemi.watch(source, () => v.value = fn());
return vueDemi.computed(() => v.value);
}
function extendRef(ref, extend, enumerable = true) {
for (const [key, value] of Object.entries(extend)) {
if (key === 'value')
continue;
if (vueDemi.isRef(value)) {
Object.defineProperty(ref, key, {
get() {
return value.value;
},
set(v) {
value.value = v;
},
enumerable,
});
}
else {
Object.defineProperty(ref, key, { value, enumerable });
}
}
return ref;
}
function makeDestructurable(obj, arr) {
if (typeof Symbol !== 'undefined') {
const clone = Object.assign({}, obj);
Object.defineProperty(clone, Symbol.iterator, {
enumerable: false,
value() {
let index = 0;
return {
next: () => ({
value: arr[index++],
done: index > arr.length,
}),
};
},
});
return clone;
}
else {
return Object.assign([...arr], obj);
}
}
/**

@@ -51,2 +78,3 @@ * Call onMounted() if it's inside a component lifecycle, if not, run just call the function

}
/**

@@ -61,2 +89,21 @@ * Call onUnmounted() if it's inside a component lifecycle, if not, do nothing

}
const isClient = typeof window !== 'undefined';
const isDef = (val) => typeof val !== 'undefined';
const assert = (condition, ...infos) => {
if (!condition)
console.warn(...infos);
};
const toString = Object.prototype.toString;
const isBoolean = (val) => typeof val === 'boolean';
const isFunction = (val) => typeof val === 'function';
const isNumber = (val) => typeof val === 'number';
const isString = (val) => typeof val === 'string';
const isObject = (val) => toString.call(val) === '[object Object]';
const isWindow = (val) => typeof window !== 'undefined' && toString.call(val) === '[object Window]';
const now = () => Date.now();
const timestamp = () => +Date.now();
const clamp = (n, min, max) => Math.min(max, Math.max(min, n));
const noop = () => { };
function promiseTimeout(ms, throwOnTimeout = false, reason = 'Timeout') {

@@ -74,5 +121,76 @@ return new Promise((resolve, reject) => {

function when(r) {
let isNot = false;
function toMatch(condition, { flush = 'sync', 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,
immediate: true,
});
});
const promises = [watcher];
if (timeout) {
promises.push(shared.promiseTimeout(timeout, throwOnTimeout)
.finally(() => { stop === null || stop === void 0 ? void 0 : stop(); }));
}
return Promise.race(promises);
}
function toBe(value, options) {
return toMatch(v => v === 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 toContain(value, options) {
return toMatch((v) => {
const array = Array.from(v);
return array.includes(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);
}
return {
toMatch,
toBe,
toBeTruthy,
toBeNull,
toBeNaN,
toBeUndefined,
toContain,
changed,
changedTimes,
get not() {
isNot = !isNot;
return this;
},
};
}
exports.assert = assert;
exports.clamp = clamp;
exports.explicitComputed = explicitComputed;
exports.controlledComputed = controlledComputed;
exports.extendRef = extendRef;
exports.invoke = invoke;

@@ -87,2 +205,3 @@ exports.isBoolean = isBoolean;

exports.isWindow = isWindow;
exports.makeDestructurable = makeDestructurable;
exports.noop = noop;

@@ -94,2 +213,3 @@ exports.now = now;

exports.tryOnUnmounted = tryOnUnmounted;
exports.when = when;

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

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

!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("vue-demi")):"function"==typeof define&&define.amd?define(["exports","vue-demi"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self)["VueUseShared utilities"]={},e.VueDemi)}(this,(function(e,t){"use strict";const n="undefined"!=typeof window,o=Object.prototype.toString;e.assert=(e,...t)=>{e||console.warn(...t)},e.clamp=(e,t,n)=>Math.min(n,Math.max(t,e)),e.explicitComputed=function(e,n){const o=t.reactive({value:n()});return t.watch(e,(()=>o.value=n())),t.computed((()=>o.value))},e.invoke=function(e){return e()},e.isBoolean=e=>"boolean"==typeof e,e.isClient=n,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.noop=()=>{},e.now=()=>Date.now(),e.promiseTimeout=function(e,t=!1,n="Timeout"){return new Promise(((o,i)=>{t?setTimeout((()=>i(n)),e):setTimeout(o,e)}))},e.timestamp=()=>+Date.now(),e.tryOnMounted=function(e,n=!0){t.getCurrentInstance()?t.onMounted(e):n?e():t.nextTick(e)},e.tryOnUnmounted=function(e){t.getCurrentInstance()&&t.onUnmounted(e)},Object.defineProperty(e,"__esModule",{value:!0})}));
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("vue-demi"),require("@vueuse/shared")):"function"==typeof define&&define.amd?define(["exports","vue-demi","@vueuse/shared"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self)["VueUseShared utilities"]={},e.VueDemi,e.VueUseShared)}(this,(function(e,t,n){"use strict";const o="undefined"!=typeof window,u=Object.prototype.toString;e.assert=(e,...t)=>{e||console.warn(...t)},e.clamp=(e,t,n)=>Math.min(n,Math.max(t,e)),e.controlledComputed=function(e,n){const o=t.ref(n());return t.watch(e,(()=>o.value=n())),t.computed((()=>o.value))},e.extendRef=function(e,n,o=!0){for(const[u,i]of Object.entries(n))"value"!==u&&(t.isRef(i)?Object.defineProperty(e,u,{get:()=>i.value,set(e){i.value=e},enumerable:o}):Object.defineProperty(e,u,{value:i,enumerable:o}));return e},e.invoke=function(e){return e()},e.isBoolean=e=>"boolean"==typeof e,e.isClient=o,e.isDef=e=>void 0!==e,e.isFunction=e=>"function"==typeof e,e.isNumber=e=>"number"==typeof e,e.isObject=e=>"[object Object]"===u.call(e),e.isString=e=>"string"==typeof e,e.isWindow=e=>"undefined"!=typeof window&&"[object Window]"===u.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.promiseTimeout=function(e,t=!1,n="Timeout"){return new Promise(((o,u)=>{t?setTimeout((()=>u(n)),e):setTimeout(o,e)}))},e.timestamp=()=>+Date.now(),e.tryOnMounted=function(e,n=!0){t.getCurrentInstance()?t.onMounted(e):n?e():t.nextTick(e)},e.tryOnUnmounted=function(e){t.getCurrentInstance()&&t.onUnmounted(e)},e.when=function(e){let o=!1;function u(u,{flush:i="sync",timeout:r,throwOnTimeout:s}={}){let c=null;const f=[new Promise((n=>{c=t.watch(e,(e=>{u(e)===!o&&(null==c||c(),n())}),{flush:i,immediate:!0})}))];return r&&f.push(n.promiseTimeout(r,s).finally((()=>{null==c||c()}))),Promise.race(f)}function i(e,t){return u((t=>t===e),t)}function r(e=1,t){let n=-1;return u((()=>(n+=1,n>=e)),t)}return{toMatch:u,toBe:i,toBeTruthy:function(e){return u((e=>Boolean(e)),e)},toBeNull:function(e){return i(null,e)},toBeNaN:function(e){return u(Number.isNaN,e)},toBeUndefined:function(e){return i(void 0,e)},toContain:function(e,t){return u((t=>Array.from(t).includes(e)),t)},changed:function(e){return r(1,e)},changedTimes:r,get not(){return o=!o,this}}},Object.defineProperty(e,"__esModule",{value:!0})}));
{
"name": "@vueuse/shared",
"version": "4.0.0-beta.28",
"version": "4.0.0-beta.29",
"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