vuex-cache
Advanced tools
Comparing version 3.1.0 to 3.1.1
# CHANGELOG | ||
## 3.1.1 | ||
- Fixed `mapCacheActions` apply wrong context to `dispatch` method. | ||
Thanks to [@kierans](https://github.com/kierans) for PR [#44](https://github.com/superwf/vuex-cache/pull/44) that fixed issue [#43](https://github.com/superwf/vuex-cache/issues/43) reported by himself. | ||
- Export the `StoreCache` interface in type declarations. | ||
Thanks to [@kierans](https://github.com/kierans) for PR [#42](https://github.com/superwf/vuex-cache/pull/42) that fixed issue [#41](https://github.com/superwf/vuex-cache/issues/41) reported by himself. | ||
## 3.1.0 | ||
@@ -4,0 +14,0 @@ |
/*! | ||
* vuex-cache v3.1.0 | ||
* vuex-cache v3.1.1 | ||
* (c) superwf@gmail.com | ||
@@ -327,11 +327,12 @@ * Released under the MIT License. | ||
dispatch = typeof val === 'function' ? function () { | ||
var params = [], len = arguments.length; | ||
while ( len-- ) params[ len ] = arguments[ len ]; | ||
dispatch = typeof val === 'function' ? function (type) { | ||
var ref; | ||
module.context.cache.dispatch.apply(this$1.$store, [("" + namespace + (params[0]))].concat(params.slice(1))); | ||
var payload = [], len = arguments.length - 1; | ||
while ( len-- > 0 ) payload[ len ] = arguments[ len + 1 ]; | ||
(ref = module.context.cache.dispatch).call.apply(ref, [ this$1.$store.cache, ("" + namespace + type) ].concat( payload )); | ||
} : module.context.cache.dispatch; | ||
} | ||
return typeof val === 'function' ? val.apply(this, [dispatch].concat(args)) : dispatch.apply(this.$store, [("" + namespace + val)].concat(args)); | ||
return typeof val === 'function' ? val.call.apply(val, [ this, dispatch ].concat( args )) : dispatch.call.apply(dispatch, [ this.$store.cache, ("" + namespace + val) ].concat( args )); | ||
}; | ||
@@ -338,0 +339,0 @@ }); |
/*! | ||
* vuex-cache v3.1.0 | ||
* vuex-cache v3.1.1 | ||
* (c) superwf@gmail.com | ||
@@ -331,11 +331,12 @@ * Released under the MIT License. | ||
dispatch = typeof val === 'function' ? function () { | ||
var params = [], len = arguments.length; | ||
while ( len-- ) params[ len ] = arguments[ len ]; | ||
dispatch = typeof val === 'function' ? function (type) { | ||
var ref; | ||
module.context.cache.dispatch.apply(this$1.$store, [("" + namespace + (params[0]))].concat(params.slice(1))); | ||
var payload = [], len = arguments.length - 1; | ||
while ( len-- > 0 ) payload[ len ] = arguments[ len + 1 ]; | ||
(ref = module.context.cache.dispatch).call.apply(ref, [ this$1.$store.cache, ("" + namespace + type) ].concat( payload )); | ||
} : module.context.cache.dispatch; | ||
} | ||
return typeof val === 'function' ? val.apply(this, [dispatch].concat(args)) : dispatch.apply(this.$store, [("" + namespace + val)].concat(args)); | ||
return typeof val === 'function' ? val.call.apply(val, [ this, dispatch ].concat( args )) : dispatch.call.apply(dispatch, [ this.$store.cache, ("" + namespace + val) ].concat( args )); | ||
}; | ||
@@ -342,0 +343,0 @@ }); |
/*! | ||
* vuex-cache v3.1.0 | ||
* vuex-cache v3.1.1 | ||
* (c) superwf@gmail.com | ||
@@ -333,11 +333,12 @@ * Released under the MIT License. | ||
dispatch = typeof val === 'function' ? function () { | ||
var params = [], len = arguments.length; | ||
while ( len-- ) params[ len ] = arguments[ len ]; | ||
dispatch = typeof val === 'function' ? function (type) { | ||
var ref; | ||
module.context.cache.dispatch.apply(this$1.$store, [("" + namespace + (params[0]))].concat(params.slice(1))); | ||
var payload = [], len = arguments.length - 1; | ||
while ( len-- > 0 ) payload[ len ] = arguments[ len + 1 ]; | ||
(ref = module.context.cache.dispatch).call.apply(ref, [ this$1.$store.cache, ("" + namespace + type) ].concat( payload )); | ||
} : module.context.cache.dispatch; | ||
} | ||
return typeof val === 'function' ? val.apply(this, [dispatch].concat(args)) : dispatch.apply(this.$store, [("" + namespace + val)].concat(args)); | ||
return typeof val === 'function' ? val.call.apply(val, [ this, dispatch ].concat( args )) : dispatch.call.apply(dispatch, [ this.$store.cache, ("" + namespace + val) ].concat( args )); | ||
}; | ||
@@ -344,0 +345,0 @@ }); |
/*! | ||
* vuex-cache v3.1.0 | ||
* vuex-cache v3.1.1 | ||
* (c) superwf@gmail.com | ||
* Released under the MIT License. | ||
*/ | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e=e||self).VuexCache={})}(this,function(e){"use strict";var t,n=function(e){return!!e&&"object"==typeof e},r=new Error("Can't generate key from parameters."),a=function(e){try{var t=function(e){return n(e[0])?[e[0].type,e[0],e[1]]:e}(e),a=t[0],c=t[1];return a+":"+(n(o=c)?JSON.stringify(o):String(o))}catch(e){return r}var o},c=function(e){return n(e)&&"number"==typeof e.timeout},o=function(e){return!!e&&Date.now()>e},i=new Map,u=function(e,t){var u={dispatch:function(){for(var n=[],u=arguments.length;u--;)n[u]=arguments[u];var f=a(n);if(f===r)return e.dispatch.apply(e,n);var p=i.get(f)||{},s=p.value,l=p.expiresIn;if(s&&!o(l))return s;var h=function(e,t){var n="string"==typeof e[0]?e[2]:e[0];return c(n)?n.timeout:c(t)?t.timeout:0}(n,t),v={expiresIn:h?Date.now()+h:void 0,value:e.dispatch.apply(e,n)};return i.set(f,v),v.value.catch(function(e){return i.delete(f),Promise.reject(e)})},has:function(){for(var e=[],t=arguments.length;t--;)e[t]=arguments[t];var c=a(e);if(c===r)return!1;var u=i.get(c);return n(u)&&!o(u.expiresIn)},clear:function(){return i.clear()},delete:function(){for(var e=[],t=arguments.length;t--;)e[t]=arguments[t];var n=a(e);return n!==r&&i.delete(n)}};for(var p in Object.defineProperty(e,"cache",{value:u,writable:!1,enumerable:!0,configurable:!1}),e._modulesNamespaceMap){var s=f(e,"mapCacheActions",p);Object.defineProperty(s.context,"cache",{value:u,writable:!1,enumerable:!0,configurable:!1})}},f=function(e,t,n){var r=e._modulesNamespaceMap[n];return"production"===process.env.NODE_ENV||r||console.error("[vuex-cache] module namespace not found in "+t+"(): "+n),r},p=(t=function(e,t){var n,r={};return(n=t,Array.isArray(n)?n.map(function(e){return{key:e,val:e}}):Object.keys(n).map(function(e){return{key:e,val:n[e]}})).forEach(function(t){var n=t.key,a=t.val;r[n]=function(){for(var t=this,n=[],r=arguments.length;r--;)n[r]=arguments[r];var c=this.$store.cache.dispatch;if(e){var o=f(this.$store,"mapCacheActions",e);if(!o)return;c="function"==typeof a?function(){for(var n=[],r=arguments.length;r--;)n[r]=arguments[r];o.context.cache.dispatch.apply(t.$store,[""+e+n[0]].concat(n.slice(1)))}:o.context.cache.dispatch}return"function"==typeof a?a.apply(this,[c].concat(n)):c.apply(this.$store,[""+e+a].concat(n))}}),r},function(e,n){return"string"!=typeof e?(n=e,e=""):"/"!==e.charAt(e.length-1)&&(e+="/"),t(e,n)});e.cacheAction=function(e,t){return function(n,r){return u(n,t),e.call(this,n,r)}},e.default=function(e){return function(t){return u(t,e)}},e.mapCacheActions=p,Object.defineProperty(e,"__esModule",{value:!0})}); | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e=e||self).VuexCache={})}(this,function(e){"use strict";var t,n=function(e){return!!e&&"object"==typeof e},r=new Error("Can't generate key from parameters."),a=function(e){try{var t=function(e){return n(e[0])?[e[0].type,e[0],e[1]]:e}(e),a=t[0],c=t[1];return a+":"+(n(o=c)?JSON.stringify(o):String(o))}catch(e){return r}var o},c=function(e){return n(e)&&"number"==typeof e.timeout},o=function(e){return!!e&&Date.now()>e},u=new Map,i=function(e,t){var i={dispatch:function(){for(var n=[],i=arguments.length;i--;)n[i]=arguments[i];var f=a(n);if(f===r)return e.dispatch.apply(e,n);var p=u.get(f)||{},l=p.value,s=p.expiresIn;if(l&&!o(s))return l;var h=function(e,t){var n="string"==typeof e[0]?e[2]:e[0];return c(n)?n.timeout:c(t)?t.timeout:0}(n,t),v={expiresIn:h?Date.now()+h:void 0,value:e.dispatch.apply(e,n)};return u.set(f,v),v.value.catch(function(e){return u.delete(f),Promise.reject(e)})},has:function(){for(var e=[],t=arguments.length;t--;)e[t]=arguments[t];var c=a(e);if(c===r)return!1;var i=u.get(c);return n(i)&&!o(i.expiresIn)},clear:function(){return u.clear()},delete:function(){for(var e=[],t=arguments.length;t--;)e[t]=arguments[t];var n=a(e);return n!==r&&u.delete(n)}};for(var p in Object.defineProperty(e,"cache",{value:i,writable:!1,enumerable:!0,configurable:!1}),e._modulesNamespaceMap){var l=f(e,"mapCacheActions",p);Object.defineProperty(l.context,"cache",{value:i,writable:!1,enumerable:!0,configurable:!1})}},f=function(e,t,n){var r=e._modulesNamespaceMap[n];return"production"===process.env.NODE_ENV||r||console.error("[vuex-cache] module namespace not found in "+t+"(): "+n),r},p=(t=function(e,t){var n,r={};return(n=t,Array.isArray(n)?n.map(function(e){return{key:e,val:e}}):Object.keys(n).map(function(e){return{key:e,val:n[e]}})).forEach(function(t){var n=t.key,a=t.val;r[n]=function(){for(var t=this,n=[],r=arguments.length;r--;)n[r]=arguments[r];var c=this.$store.cache.dispatch;if(e){var o=f(this.$store,"mapCacheActions",e);if(!o)return;c="function"==typeof a?function(n){for(var r,a=[],c=arguments.length-1;c-- >0;)a[c]=arguments[c+1];(r=o.context.cache.dispatch).call.apply(r,[t.$store.cache,""+e+n].concat(a))}:o.context.cache.dispatch}return"function"==typeof a?a.call.apply(a,[this,c].concat(n)):c.call.apply(c,[this.$store.cache,""+e+a].concat(n))}}),r},function(e,n){return"string"!=typeof e?(n=e,e=""):"/"!==e.charAt(e.length-1)&&(e+="/"),t(e,n)});e.cacheAction=function(e,t){return function(n,r){return i(n,t),e.call(this,n,r)}},e.default=function(e){return function(t){return i(t,e)}},e.mapCacheActions=p,Object.defineProperty(e,"__esModule",{value:!0})}); | ||
//# sourceMappingURL=vuex-cache.umd.min.js.map |
{ | ||
"name": "vuex-cache", | ||
"version": "3.1.0", | ||
"version": "3.1.1", | ||
"description": "Cache dispatched actions and prevent repeated requests and heavy actions.", | ||
@@ -5,0 +5,0 @@ "cdn": "dist/vuex-cache.umd.min.js", |
@@ -0,0 +0,0 @@ # vuex-cache |
import Vue from 'vue' | ||
import { | ||
Action, | ||
ActionContext, | ||
@@ -11,3 +10,3 @@ Dispatch, | ||
interface StoreCache { | ||
export interface StoreCache { | ||
/** | ||
@@ -14,0 +13,0 @@ * Dispatch an action and set it on cache. |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
63109
991