@vueuse/shared
Advanced tools
Comparing version 4.0.0-rc.10 to 4.0.0-rc.11
@@ -559,3 +559,3 @@ 'use strict'; | ||
let isNot = false; | ||
function toMatch(condition, { flush = 'sync', timeout, throwOnTimeout } = {}) { | ||
function toMatch(condition, { flush = 'sync', deep = false, timeout, throwOnTimeout } = {}) { | ||
let stop = null; | ||
@@ -570,2 +570,3 @@ const watcher = new Promise((resolve) => { | ||
flush, | ||
deep, | ||
immediate: true, | ||
@@ -572,0 +573,0 @@ }); |
@@ -345,2 +345,8 @@ import { Ref, WatchSource, ComputedRef as ComputedRef$1, WatchOptions, WatchCallback, WatchStopHandle, ShallowUnwrapRef as ShallowUnwrapRef$1 } from 'vue-demi'; | ||
flush?: WatchOptions['flush']; | ||
/** | ||
* `deep` option for internal watch | ||
* | ||
* @default 'false' | ||
*/ | ||
deep?: WatchOptions['deep']; | ||
} | ||
@@ -347,0 +353,0 @@ interface BaseWhenInstance<T> { |
@@ -555,3 +555,3 @@ import { watch, ref, computed, isRef, getCurrentInstance, onMounted, nextTick, onUnmounted, unref } from 'vue-demi'; | ||
let isNot = false; | ||
function toMatch(condition, { flush = 'sync', timeout, throwOnTimeout } = {}) { | ||
function toMatch(condition, { flush = 'sync', deep = false, timeout, throwOnTimeout } = {}) { | ||
let stop = null; | ||
@@ -566,2 +566,3 @@ const watcher = new Promise((resolve) => { | ||
flush, | ||
deep, | ||
immediate: true, | ||
@@ -568,0 +569,0 @@ }); |
@@ -559,3 +559,3 @@ (function (global, factory) { | ||
let isNot = false; | ||
function toMatch(condition, { flush = 'sync', timeout, throwOnTimeout } = {}) { | ||
function toMatch(condition, { flush = 'sync', deep = false, timeout, throwOnTimeout } = {}) { | ||
let stop = null; | ||
@@ -570,2 +570,3 @@ const watcher = new Promise((resolve) => { | ||
flush, | ||
deep, | ||
immediate: true, | ||
@@ -572,0 +573,0 @@ }); |
@@ -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";function n(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 u="undefined"!=typeof window,r=Object.prototype.toString;function o(e,t){return function(...n){e((()=>t.apply(this,n)),{fn:t,thisArg:this,args:n})}}const i=e=>e();function c(e){if(e<=0)return i;let t;return n=>{t&&clearTimeout(t),t=setTimeout(n,e)}}function s(e,t=!0){if(e<=0)return i;let n,u=0;const r=()=>{n&&(clearTimeout(n),n=void 0)};return o=>{const i=Date.now()-u;r(),i>e?(u=Date.now(),o()):t&&(n=setTimeout((()=>{r(),o()}),e))}}function l(e=i){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 a(e,t=!1,n="Timeout"){return new Promise(((u,r)=>{t?setTimeout((()=>r(n)),e):setTimeout(u,e)}))}function f(e,u,r={}){const{eventFilter:c=i}=r,s=n(r,["eventFilter"]);return t.watch(e,o(c,u),s)}function v(e){t.getCurrentInstance()&&t.onUnmounted(e)}function d(e,t=200){return o(c(t),e)}function m(e,n=1e3,u=!0){let r=null;const o=t.ref(!1);function i(){r&&(clearInterval(r),r=null)}function c(){o.value=!1,i()}function s(){o.value=!0,i(),r=setInterval(e,n)}return u&&s(),v(c),{isActive:o,pause:c,resume:s,start:s,stop:c}}function p(e,t=200,n=!0){return o(s(t,n),e)}function h(e,n,u){const r=t.ref(!1);let o=null;function i(){o&&(clearTimeout(o),o=null)}function c(){r.value=!1,i()}function s(){i(),r.value=!0,o=setTimeout((()=>{o=null,e()}),n)}return u&&s(),v(c),{isActive:r,start:s,stop:c}}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=i,e.clamp=(e,t,n)=>Math.min(n,Math.max(t,e)),e.controlledComputed=function(e,n){const u=t.ref(n());return t.watch(e,(()=>u.value=n()),{flush:"sync"}),t.computed((()=>u.value))},e.createFilterWrapper=o,e.debounceFilter=c,e.debouncedWatch=function(e,t,u={}){const{debounce:r=0}=u,o=n(u,["debounce"]);return f(e,t,Object.assign(Object.assign({},o),{eventFilter:c(r)}))},e.extendRef=function(e,n,{enumerable:u=!1,unwrap:r=!0}={}){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},e.ignorableWatch=function(e,u,r={}){const{eventFilter:c=i}=r,s=n(r,["eventFilter"]),l=o(c,u);let a,f,v;if("sync"===s.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)}),s)}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({},s),{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)}),s)),v=()=>{n.forEach((e=>e()))}}return{stop:v,ignoreUpdates:a,ignorePrevAsyncUpdates:f}},e.invoke=function(e){return e()},e.isBoolean=e=>"boolean"==typeof e,e.isClient=u,e.isDef=e=>void 0!==e,e.isFunction=e=>"function"==typeof e,e.isNumber=e=>"number"==typeof e,e.isObject=e=>"[object Object]"===r.call(e),e.isString=e=>"string"==typeof e,e.isWindow=e=>"undefined"!=typeof window&&"[object Window]"===r.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=l,e.pausableWatch=function(e,t,u={}){const{eventFilter:r}=u,o=n(u,["eventFilter"]),{eventFilter:i,pause:c,resume:s,isActive:a}=l(r);return{stop:f(e,t,Object.assign(Object.assign({},o),{eventFilter:i})),pause:c,resume:s,isActive:a}},e.promiseTimeout=a,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=s,e.throttledWatch=function(e,t,u={}){const{throttle:r=0}=u,o=n(u,["throttle"]);return f(e,t,Object.assign(Object.assign({},o),{eventFilter:s(r)}))},e.timestamp=()=>+Date.now(),e.tryOnMounted=function(e,n=!0){t.getCurrentInstance()?t.onMounted(e):n?e():t.nextTick(e)},e.tryOnUnmounted=v,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},m((()=>u.value+=1),e,n))},e.useIntervalFn=m,e.useThrottle=function(e,n=200){if(n<=0)return e;const u=t.ref(e.value),r=p((()=>{u.value=e.value}),n);return t.watch(e,(()=>r())),u},e.useThrottleFn=p,e.useTimeout=function(e=1e3,n=!0){const u=t.ref(!1),r=h((()=>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=h,e.useToggle=function(e=!1){const n=t.ref(e);return[n,()=>n.value=!n.value]},e.watchWithFilter=f,e.when=function(e){let n=!1;function u(u,{flush:r="sync",timeout:o,throwOnTimeout:i}={}){let c=null;const s=[new Promise((o=>{c=t.watch(e,(e=>{u(e)===!n&&(null==c||c(),o())}),{flush:r,immediate:!0})}))];return o&&s.push(a(o,i).finally((()=>{null==c||c()}))),Promise.race(s)}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})})); | ||
!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";function n(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 u="undefined"!=typeof window,r=Object.prototype.toString;function o(e,t){return function(...n){e((()=>t.apply(this,n)),{fn:t,thisArg:this,args:n})}}const i=e=>e();function c(e){if(e<=0)return i;let t;return n=>{t&&clearTimeout(t),t=setTimeout(n,e)}}function s(e,t=!0){if(e<=0)return i;let n,u=0;const r=()=>{n&&(clearTimeout(n),n=void 0)};return o=>{const i=Date.now()-u;r(),i>e?(u=Date.now(),o()):t&&(n=setTimeout((()=>{r(),o()}),e))}}function l(e=i){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 a(e,t=!1,n="Timeout"){return new Promise(((u,r)=>{t?setTimeout((()=>r(n)),e):setTimeout(u,e)}))}function f(e,u,r={}){const{eventFilter:c=i}=r,s=n(r,["eventFilter"]);return t.watch(e,o(c,u),s)}function v(e){t.getCurrentInstance()&&t.onUnmounted(e)}function d(e,t=200){return o(c(t),e)}function p(e,n=1e3,u=!0){let r=null;const o=t.ref(!1);function i(){r&&(clearInterval(r),r=null)}function c(){o.value=!1,i()}function s(){o.value=!0,i(),r=setInterval(e,n)}return u&&s(),v(c),{isActive:o,pause:c,resume:s,start:s,stop:c}}function m(e,t=200,n=!0){return o(s(t,n),e)}function h(e,n,u){const r=t.ref(!1);let o=null;function i(){o&&(clearTimeout(o),o=null)}function c(){r.value=!1,i()}function s(){i(),r.value=!0,o=setTimeout((()=>{o=null,e()}),n)}return u&&s(),v(c),{isActive:r,start:s,stop:c}}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=i,e.clamp=(e,t,n)=>Math.min(n,Math.max(t,e)),e.controlledComputed=function(e,n){const u=t.ref(n());return t.watch(e,(()=>u.value=n()),{flush:"sync"}),t.computed((()=>u.value))},e.createFilterWrapper=o,e.debounceFilter=c,e.debouncedWatch=function(e,t,u={}){const{debounce:r=0}=u,o=n(u,["debounce"]);return f(e,t,Object.assign(Object.assign({},o),{eventFilter:c(r)}))},e.extendRef=function(e,n,{enumerable:u=!1,unwrap:r=!0}={}){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},e.ignorableWatch=function(e,u,r={}){const{eventFilter:c=i}=r,s=n(r,["eventFilter"]),l=o(c,u);let a,f,v;if("sync"===s.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)}),s)}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({},s),{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)}),s)),v=()=>{n.forEach((e=>e()))}}return{stop:v,ignoreUpdates:a,ignorePrevAsyncUpdates:f}},e.invoke=function(e){return e()},e.isBoolean=e=>"boolean"==typeof e,e.isClient=u,e.isDef=e=>void 0!==e,e.isFunction=e=>"function"==typeof e,e.isNumber=e=>"number"==typeof e,e.isObject=e=>"[object Object]"===r.call(e),e.isString=e=>"string"==typeof e,e.isWindow=e=>"undefined"!=typeof window&&"[object Window]"===r.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=l,e.pausableWatch=function(e,t,u={}){const{eventFilter:r}=u,o=n(u,["eventFilter"]),{eventFilter:i,pause:c,resume:s,isActive:a}=l(r);return{stop:f(e,t,Object.assign(Object.assign({},o),{eventFilter:i})),pause:c,resume:s,isActive:a}},e.promiseTimeout=a,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=s,e.throttledWatch=function(e,t,u={}){const{throttle:r=0}=u,o=n(u,["throttle"]);return f(e,t,Object.assign(Object.assign({},o),{eventFilter:s(r)}))},e.timestamp=()=>+Date.now(),e.tryOnMounted=function(e,n=!0){t.getCurrentInstance()?t.onMounted(e):n?e():t.nextTick(e)},e.tryOnUnmounted=v,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},p((()=>u.value+=1),e,n))},e.useIntervalFn=p,e.useThrottle=function(e,n=200){if(n<=0)return e;const u=t.ref(e.value),r=m((()=>{u.value=e.value}),n);return t.watch(e,(()=>r())),u},e.useThrottleFn=m,e.useTimeout=function(e=1e3,n=!0){const u=t.ref(!1),r=h((()=>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=h,e.useToggle=function(e=!1){const n=t.ref(e);return[n,()=>n.value=!n.value]},e.watchWithFilter=f,e.when=function(e){let n=!1;function u(u,{flush:r="sync",deep:o=!1,timeout:i,throwOnTimeout:c}={}){let s=null;const l=[new Promise((i=>{s=t.watch(e,(e=>{u(e)===!n&&(null==s||s(),i())}),{flush:r,deep:o,immediate:!0})}))];return i&&l.push(a(i,c).finally((()=>{null==s||s()}))),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})})); |
{ | ||
"name": "@vueuse/shared", | ||
"version": "4.0.0-rc.10", | ||
"version": "4.0.0-rc.11", | ||
"main": "dist/index.cjs.js", | ||
@@ -5,0 +5,0 @@ "types": "dist/index.d.ts", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
87920
2295