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

ladda-cache

Package Overview
Dependencies
Maintainers
1
Versions
30
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ladda-cache - npm Package Compare versions

Comparing version 0.1.0 to 0.1.1

.nyc_output/aeaf86c8ef036dfe65af57a48590c93b.json

2

dist/bundle.js

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

module.exports=function(r){function t(e){if(n[e])return n[e].exports;var o=n[e]={exports:{},id:e,loaded:!1};return r[e].call(o.exports,o,o.exports,t),o.loaded=!0,o.exports}var n={};return t.m=r,t.c=n,t.p="",t(0)}([function(r,t,n){"use strict";var e=n(4);r.exports={build:e.build}},function(r,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=function(){function r(r,t){var n=[],e=!0,o=!1,u=void 0;try{for(var i,a=r[Symbol.iterator]();!(e=(i=a.next()).done)&&(n.push(i.value),!t||n.length!==t);e=!0);}catch(c){o=!0,u=c}finally{try{!e&&a["return"]&&a["return"]()}finally{if(o)throw u}}return n}return function(t,n){if(Array.isArray(t))return t;if(Symbol.iterator in Object(t))return r(t,n);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}(),e=(t.debug=function(r){return console.log(r),r},t.identity=function(r){return r}),o=t.curry=function O(r){return function(){for(var t=arguments.length,n=Array(t),e=0;t>e;e++)n[e]=arguments[e];var o=r.length;return n.length<o?O(r.bind.apply(r,[null].concat(n))):r.apply(void 0,n)}},u=t.passThrough=o(function(r,t){return r(t),t}),i=(t.startsWith=o(function(r,t){return 0===t.indexOf(r)}),t.join=o(function(r,t,n){return t+r+n}),t.on=o(function(r,t,n,e){return r(t(e),n(e))}),t.isEqual=o(function(r,t){return r===t}),t.on2=o(function(r,t,n,e,o){return r(t(e),n(o))})),a=(t.init=function(r){return r.slice(0,r.length-1)},t.tail=function(r){return r.slice(1,r.length)}),c=t.last=function(r){return r[r.length-1]},f=(t.head=function(r){return r[0]},t.map=o(function(r,t){return t.map(r)})),l=t.map_=o(function(r,t){f(r,t)}),s=t.reverse=function(r){return r.slice().reverse()},p=t.reduce=o(function(r,t,n){return l(function(n){t=r(t,n)},n),t}),v=(t.compose=function(){for(var r=arguments.length,t=Array(r),n=0;r>n;n++)t[n]=arguments[n];return function(){return p(function(r,t){return t(r)},c(t).apply(void 0,arguments),a(s(t)))}},t.prop=o(function(r,t){return t[r]})),y=t.zip=function(r,t){for(var n=Math.min(r.length,t.length),e=[],o=0;n>o;o++)e.push([r[o],t[o]]);return e},d=t.flip=function(r){return o(function(t,n){return r(n,t)})},h=t.toPairs=function(r){var t=Object.keys(r),n=d(v)(r);return y(t,f(n,t))},m=(t.fromPairs=function(r){var t=function(r,t){var e=n(t,2),o=e[0],i=e[1];return u(function(){return r[o]=i},r)};return p(t,{},r)},t.mapObject=i(f,e,h),o(function(r,t,n){return r[t]=n,r})),b=(t.mapValues=o(function(r,t){var n=Object.keys(t);return p(function(n,e){return n[e]=r(t[e]),n},{},n)}),t.toObject=o(function(r,t){return p(function(t,n){return m(t,r(n),n)},{},t)}),o(function(r,t,n){return r(n)&&t.push(n),t}));t.filter=o(function(r,t){return p(b(r),[],t)})},function(r,t,n){"use strict";function e(r){if(Array.isArray(r)){for(var t=0,n=Array(r.length);t<r.length;t++)n[t]=r[t];return n}return Array.from(r)}Object.defineProperty(t,"__esModule",{value:!0}),t.createEntityStore=t.contains=t.get=t.put=t.remove=void 0;var o=function(){function r(r,t){var n=[],e=!0,o=!1,u=void 0;try{for(var i,a=r[Symbol.iterator]();!(e=(i=a.next()).done)&&(n.push(i.value),!t||n.length!==t);e=!0);}catch(c){o=!0,u=c}finally{try{!e&&a["return"]&&a["return"]()}finally{if(o)throw u}}return n}return function(t,n){if(Array.isArray(t))return t;if(Symbol.iterator in Object(t))return r(t,n);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}(),u=n(11),i=n(1),a=function(r){return{value:r,timestamp:Date.now()}},c=function(r,t){var n=o(r,2),e=(n[0],n[1]);return e[t]},f=function(r,t,n){var e=o(r,2),u=(e[0],e[1]);return u[t]=a(n)},l=(0,i.curry)(function(r,t){var n=o(r,2),e=(n[0],n[1]);return delete e[t]}),s=function(r){return r.viewOf||r.name},p=function(r,t){var n=o(r,2),u=n[0],a=n[1],c=s(t),f=[].concat(e(u[c]));(0,i.map_)(l([u,a]),f)},v=function(r,t){return s(r)+t.id},y=function(r,t){return r.name+t.id},d=function(r){return!!r.viewOf},h=(t.remove=function(r,t,n){l(r,v(t,{id:n})),p(r,t)},(0,i.curry)(function(r,t,n,e,o){return d(e)?r(n,e,o):t(n,e,o)})),m=function(r,t,n){return!!c(r,v(t,n))},b=function(r,t,n){if(!n.id)throw new Error("Value is missing id, tried to add to entity "+t.name);var e=v(t,n);return f(r,e,n),n},O=function(r,t,n){if(!n.id)throw new Error("Value is missing id, tried to add to view "+t.name);if(m(r,t,n)){var e=c(r,v(t,n)).value;b(r,t,(0,u.merge)(n,e)),p(r,t)}else{var o=y(t,n);f(r,o,n)}return n},g=(t.put=h(O,b),function(r,t,n){var e=v(t,{id:n});return c(r,e)}),j=function(r,t,n){var e=c(r,v(t,{id:n})),o=c(r,y(t,{id:n})),u=o&&!e;return u?o:e},A=(t.get=h(j,g),t.contains=function(r,t,n){return!!h(j,g)(r,t,n)},function(r,t){var n=o(r,2),e=n[0],u=n[1];return e[t.viewOf]||(e[t.viewOf]=[]),e[t.viewOf].push(t.name),[e,u]}),w=function(r,t){var n=o(r,2),e=n[0],u=n[1];return e[t.name]||(e[t.name]=[]),[e,u]},_=function(r,t){return d(t)?A(r,t):w(r,t)};t.createEntityStore=function(r){return(0,i.reduce)(_,[{},{}],r)}},function(r,t,n){"use strict";function e(r){if(Array.isArray(r)){for(var t=0,n=Array(r.length);t<r.length;t++)n[t]=r[t];return n}return Array.from(r)}Object.defineProperty(t,"__esModule",{value:!0}),t.createQueryCache=t.invalidate=t.get=t.contains=t.getValue=t.put=void 0;var o=Object.assign||function(r){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var e in n)Object.prototype.hasOwnProperty.call(n,e)&&(r[e]=n[e])}return r},u="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(r){return typeof r}:function(r){return r&&"function"==typeof Symbol&&r.constructor===Symbol?"symbol":typeof r},i=n(2),a=n(1),c=function j(r){return Object.keys(r).map(function(t){return r[t]&&"object"===u(r[t])?j(r[t]):r[t]}).join("-")},f=function(r){var t=function(r){return r&&"object"===("undefined"==typeof r?"undefined":u(r))?c(r):r};return(0,a.map)(t,r)},l=(0,a.on2)((0,a.reduce)((0,a.join)("-")),(0,a.prop)("name"),f),s=function(r){return{value:r,timestamp:Date.now()}},p=(0,a.prop)("value"),v=function(r,t){return!!r.cache[t]},y=function(r,t,n){var e=p(r.cache[n]),u=Array.isArray(e)?(0,a.map)((0,i.get)(r.entityStore,t),e):(0,i.get)(r.entityStore,t,e);return o({},r.cache[n],{value:u})},d=(t.put=(0,a.curry)(function(r,t,n,o,u){var c=l(t,[n.name].concat(e((0,a.filter)(a.identity,o))));return Array.isArray(u)?r.cache[c]=s((0,a.map)((0,a.prop)("id"),u)):r.cache[c]=s((0,a.prop)("id",u)),(0,a.map_)((0,i.put)(r.entityStore,t),Array.isArray(u)?u:[u]),u}),t.getValue=function(r){return Array.isArray(r)?(0,a.map)(p,r):p(r)},t.contains=function(r,t,n,o){var u=l(t,[n.name].concat(e((0,a.filter)(a.identity,o))));return v(r,u)},t.get=function(r,t,n,o){var u=l(t,[n.name].concat(e((0,a.filter)(a.identity,o))));if(!v(r,u))throw new Error("Tried to access "+t.name+" with key "+u+" which doesn't exist.\n Do a contains check first!");return y(r,t,u)},function(r){return r.invalidatesOn||["CREATE","UPDATE","DELETE"]}),h=function(r,t){var n=d(r);return n&&n.indexOf(t)>-1},m=(0,a.curry)(function(r,t){var n=Object.keys(r.cache),e=function(n){(0,a.startsWith)(t+"-",n)&&delete r.cache[n]};(0,a.map_)(e,n)}),b=function(r){return r.invalidates||[]},O=function(r,t,n){h(t,n.operation)&&(0,a.map_)(m(r),b(t))},g=function(r,t,n){var e=function(r){return t.name+"-"+r},o=(0,a.compose)(m(r),e);(0,a.map_)(o,b(n))};t.invalidate=function(r,t,n){O(r,t,n),g(r,t,n)},t.createQueryCache=function(r){return{entityStore:r,cache:{}}}},function(r,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.build=void 0;var e=Object.assign||function(r){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var e in n)Object.prototype.hasOwnProperty.call(n,e)&&(r[e]=n[e])}return r},o=function(){function r(r,t){var n=[],e=!0,o=!1,u=void 0;try{for(var i,a=r[Symbol.iterator]();!(e=(i=a.next()).done)&&(n.push(i.value),!t||n.length!==t);e=!0);}catch(c){o=!0,u=c}finally{try{!e&&a["return"]&&a["return"]()}finally{if(o)throw u}}return n}return function(t,n){if(Array.isArray(t))return t;if(Symbol.iterator in Object(t))return r(t,n);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}(),u=n(1),i=n(2),a=n(3),c=n(7),f=function(r){var t=o(r,2),n=t[0],u=t[1];return e({name:n},u)},l=(0,u.compose)((0,u.mapValues)((0,u.prop)("api")),(0,u.toObject)((0,u.prop)("name")));t.build=function(r){var t=(0,u.mapObject)(f,r),n=(0,i.createEntityStore)(t),e=(0,a.createQueryCache)(n),o=(0,u.compose)(l,(0,u.map)((0,c.decorate)(n,e)));return o(t)}},function(r,t,n){"use strict";function e(r,t,n,e){return function(){return e.apply(void 0,arguments).then((0,i.passThrough)((0,o.put)(r,n))).then((0,i.passThrough)(function(){return(0,u.invalidate)(t,n,e)}))}}Object.defineProperty(t,"__esModule",{value:!0}),t.decorateCreate=e;var o=n(2),u=n(3),i=n(1)},function(r,t,n){"use strict";function e(r,t,n,e){return function(){for(var a=arguments.length,c=Array(a),f=0;a>f;f++)c[f]=arguments[f];return(0,o.remove)(r,n,c.join("")),e.apply(void 0,c).then((0,i.passThrough)(function(){return(0,u.invalidate)(t,n,e)}))}}Object.defineProperty(t,"__esModule",{value:!0}),t.decorateDelete=e;var o=n(2),u=n(3),i=n(1)},function(r,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.decorate=void 0;var e=Object.assign||function(r){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var e in n)Object.prototype.hasOwnProperty.call(n,e)&&(r[e]=n[e])}return r},o=n(1),u=n(5),i=n(9),a=n(10),c=n(6),f=n(8),l=(0,o.curry)(function(r,t,n,e){var o={CREATE:u.decorateCreate,READ:i.decorateRead,UPDATE:a.decorateUpdate,DELETE:c.decorateDelete,NO_OPERATION:f.decorateNoOperation}[e.operation||"NO_OPERATION"];return o(r,t,n,e)});t.decorate=(0,o.curry)(function(r,t,n){var u=(0,o.mapValues)(l(r,t,n),n.api);return e({},n,{api:u})})},function(r,t,n){"use strict";function e(r,t,n,e){var i=e.bind(null);return i.operation="NO_OPERATION",function(){return e.apply(void 0,arguments).then((0,u.passThrough)(function(){return(0,o.invalidate)(t,n,i)}))}}Object.defineProperty(t,"__esModule",{value:!0}),t.decorateNoOperation=e;var o=n(3),u=n(1)},function(r,t,n){"use strict";function e(r,t,n,e){return e.byId?f(r,n,e):l(r,t,n,e)}Object.defineProperty(t,"__esModule",{value:!0}),t.decorateRead=e;var o=n(2),u=n(3),i=n(1),a=function(r){return 1e3*(r.ttl||0)},c=function(r,t){return Date.now()-t>a(r)},f=function(r,t,n){return function(e){if((0,o.contains)(r,t,e)&&!n.alwaysGetFreshData){var u=(0,o.get)(r,t,e);if(!c(t,u.timestamp))return Promise.resolve(u.value)}return n(e).then((0,i.passThrough)((0,o.put)(r,t)))}},l=function(r,t,n,e){return function(){for(var r=arguments.length,o=Array(r),a=0;r>a;a++)o[a]=arguments[a];if((0,u.contains)(t,n,e,o)&&!e.alwaysGetFreshData){var f=(0,u.get)(t,n,e,o);if(!c(n,f.timestamp))return Promise.resolve((0,u.getValue)(f.value))}return e.apply(void 0,o).then((0,i.passThrough)((0,u.put)(t,n,e,o)))}}},function(r,t,n){"use strict";function e(r,t,n,e){return function(a){for(var c=arguments.length,f=Array(c>1?c-1:0),l=1;c>l;l++)f[l-1]=arguments[l];return(0,o.put)(r,n,a),e.apply(void 0,[a].concat(f)).then((0,i.passThrough)(function(){return(0,u.invalidate)(t,n,e)}))}}Object.defineProperty(t,"__esModule",{value:!0}),t.decorateUpdate=e;var o=n(2),u=n(3),i=n(1)},function(r,t){"use strict";function n(r,t){var u=i({},t),a=e(r);a.forEach(function(n){void 0!==t[n]&&(u[n]=r[n])});var c=o(r);return c.forEach(function(e){void 0!==t[e]&&(u[e]=n(r[e],t[e]))}),u}function e(r){return Object.keys(r).filter(function(t){return null===r[t]||"object"!==u(r[t])||Array.isArray(r[t])})}function o(r){return Object.keys(r).filter(function(t){return null!==r[t]&&!Array.isArray(r[t])&&"object"===u(r[t])})}Object.defineProperty(t,"__esModule",{value:!0});var u="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(r){return typeof r}:function(r){return r&&"function"==typeof Symbol&&r.constructor===Symbol?"symbol":typeof r},i=Object.assign||function(r){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var e in n)Object.prototype.hasOwnProperty.call(n,e)&&(r[e]=n[e])}return r};t.merge=n}]);
module.exports=function(r){function t(e){if(n[e])return n[e].exports;var o=n[e]={exports:{},id:e,loaded:!1};return r[e].call(o.exports,o,o.exports,t),o.loaded=!0,o.exports}var n={};return t.m=r,t.c=n,t.p="",t(0)}([function(r,t,n){"use strict";var e=n(5);r.exports={build:e.build}},function(r,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=function(){function r(r,t){var n=[],e=!0,o=!1,u=void 0;try{for(var i,a=r[Symbol.iterator]();!(e=(i=a.next()).done)&&(n.push(i.value),!t||n.length!==t);e=!0);}catch(c){o=!0,u=c}finally{try{!e&&a["return"]&&a["return"]()}finally{if(o)throw u}}return n}return function(t,n){if(Array.isArray(t))return t;if(Symbol.iterator in Object(t))return r(t,n);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}(),e=(t.debug=function(r){return console.log(r),r},t.identity=function(r){return r}),o=t.curry=function O(r){return function(){for(var t=arguments.length,n=Array(t),e=0;t>e;e++)n[e]=arguments[e];var o=r.length;return n.length<o?O(r.bind.apply(r,[null].concat(n))):r.apply(void 0,n)}},u=t.passThrough=o(function(r,t){return r(t),t}),i=(t.startsWith=o(function(r,t){return 0===t.indexOf(r)}),t.join=o(function(r,t,n){return t+r+n}),t.on=o(function(r,t,n,e){return r(t(e),n(e))}),t.isEqual=o(function(r,t){return r===t}),t.on2=o(function(r,t,n,e,o){return r(t(e),n(o))})),a=(t.init=function(r){return r.slice(0,r.length-1)},t.tail=function(r){return r.slice(1,r.length)}),c=t.last=function(r){return r[r.length-1]},f=(t.head=function(r){return r[0]},t.map=o(function(r,t){return t.map(r)})),l=t.map_=o(function(r,t){f(r,t)}),s=t.reverse=function(r){return r.slice().reverse()},p=t.reduce=o(function(r,t,n){return l(function(n){t=r(t,n)},n),t}),y=(t.compose=function(){for(var r=arguments.length,t=Array(r),n=0;r>n;n++)t[n]=arguments[n];return function(){return p(function(r,t){return t(r)},c(t).apply(void 0,arguments),a(s(t)))}},t.prop=o(function(r,t){return t[r]})),v=t.zip=function(r,t){for(var n=Math.min(r.length,t.length),e=[],o=0;n>o;o++)e.push([r[o],t[o]]);return e},d=t.flip=function(r){return o(function(t,n){return r(n,t)})},h=t.toPairs=function(r){var t=Object.keys(r),n=d(y)(r);return v(t,f(n,t))},m=(t.fromPairs=function(r){var t=function(r,t){var e=n(t,2),o=e[0],i=e[1];return u(function(){return r[o]=i},r)};return p(t,{},r)},t.mapObject=i(f,e,h),o(function(r,t,n){return r[t]=n,r})),b=(t.mapValues=o(function(r,t){var n=Object.keys(t);return p(function(n,e){return n[e]=r(t[e]),n},{},n)}),t.toObject=o(function(r,t){return p(function(t,n){return m(t,r(n),n)},{},t)}),o(function(r,t,n){return r(n)&&t.push(n),t}));t.filter=o(function(r,t){return p(b(r),[],t)})},function(r,t,n){"use strict";function e(r){if(Array.isArray(r)){for(var t=0,n=Array(r.length);t<r.length;t++)n[t]=r[t];return n}return Array.from(r)}Object.defineProperty(t,"__esModule",{value:!0}),t.createEntityStore=t.contains=t.get=t.put=t.remove=void 0;var o=function(){function r(r,t){var n=[],e=!0,o=!1,u=void 0;try{for(var i,a=r[Symbol.iterator]();!(e=(i=a.next()).done)&&(n.push(i.value),!t||n.length!==t);e=!0);}catch(c){o=!0,u=c}finally{try{!e&&a["return"]&&a["return"]()}finally{if(o)throw u}}return n}return function(t,n){if(Array.isArray(t))return t;if(Symbol.iterator in Object(t))return r(t,n);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}(),u=n(12),i=n(1),a=function(r){return{value:r,timestamp:Date.now()}},c=function(r,t){var n=o(r,2),e=(n[0],n[1]);return e[t]},f=function(r,t,n){var e=o(r,2),u=(e[0],e[1]);return u[t]=a(n)},l=(0,i.curry)(function(r,t){var n=o(r,2),e=(n[0],n[1]);return delete e[t]}),s=function(r){return r.viewOf||r.name},p=function(r,t){var n=o(r,2),u=n[0],a=n[1],c=s(t),f=[].concat(e(u[c]));(0,i.map_)(l([u,a]),f)},y=function(r,t){return s(r)+t.id},v=function(r,t){return r.name+t.id},d=function(r){return!!r.viewOf},h=(t.remove=function(r,t,n){l(r,y(t,{id:n})),p(r,t)},(0,i.curry)(function(r,t,n,e,o){return d(e)?r(n,e,o):t(n,e,o)})),m=function(r,t,n){return!!c(r,y(t,n))},b=function(r,t,n){if(!n.id)throw new Error("Value is missing id, tried to add to entity "+t.name);var e=y(t,n);return f(r,e,n),n},O=function(r,t,n){if(!n.id)throw new Error("Value is missing id, tried to add to view "+t.name);if(m(r,t,n)){var e=c(r,y(t,n)).value;b(r,t,(0,u.merge)(n,e)),p(r,t)}else{var o=v(t,n);f(r,o,n)}return n},g=(t.put=h(O,b),function(r,t,n){var e=y(t,{id:n});return c(r,e)}),j=function(r,t,n){var e=c(r,y(t,{id:n})),o=c(r,v(t,{id:n})),u=o&&!e;return u?o:e},A=(t.get=h(j,g),t.contains=function(r,t,n){return!!h(j,g)(r,t,n)},function(r,t){var n=o(r,2),e=n[0],u=n[1];return e[t.viewOf]||(e[t.viewOf]=[]),e[t.viewOf].push(t.name),[e,u]}),w=function(r,t){var n=o(r,2),e=n[0],u=n[1];return e[t.name]||(e[t.name]=[]),[e,u]},_=function(r,t){return d(t)?A(r,t):w(r,t)};t.createEntityStore=function(r){return(0,i.reduce)(_,[{},{}],r)}},function(r,t,n){"use strict";function e(r){if(Array.isArray(r)){for(var t=0,n=Array(r.length);t<r.length;t++)n[t]=r[t];return n}return Array.from(r)}Object.defineProperty(t,"__esModule",{value:!0}),t.createQueryCache=t.invalidate=t.get=t.contains=t.getValue=t.put=void 0;var o=Object.assign||function(r){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var e in n)Object.prototype.hasOwnProperty.call(n,e)&&(r[e]=n[e])}return r},u=n(2),i=n(1),a=n(4),c=(0,i.on2)((0,i.reduce)((0,i.join)("-")),(0,i.prop)("name"),(0,i.map)(a.serialize)),f=function(r){return{value:r,timestamp:Date.now()}},l=(0,i.prop)("value"),s=function(r,t){return!!r.cache[t]},p=function(r,t,n){var e=l(r.cache[n]),a=Array.isArray(e)?(0,i.map)((0,u.get)(r.entityStore,t),e):(0,u.get)(r.entityStore,t,e);return o({},r.cache[n],{value:a})},y=(t.put=(0,i.curry)(function(r,t,n,o,a){var l=c(t,[n.name].concat(e((0,i.filter)(i.identity,o))));return Array.isArray(a)?r.cache[l]=f((0,i.map)((0,i.prop)("id"),a)):r.cache[l]=f((0,i.prop)("id",a)),(0,i.map_)((0,u.put)(r.entityStore,t),Array.isArray(a)?a:[a]),a}),t.getValue=function(r){return Array.isArray(r)?(0,i.map)(l,r):l(r)},t.contains=function(r,t,n,o){var u=c(t,[n.name].concat(e((0,i.filter)(i.identity,o))));return s(r,u)},t.get=function(r,t,n,o){var u=c(t,[n.name].concat(e((0,i.filter)(i.identity,o))));if(!s(r,u))throw new Error("Tried to access "+t.name+" with key "+u+" which doesn't exist.\n Do a contains check first!");return p(r,t,u)},function(r){return r.invalidatesOn||["CREATE","UPDATE","DELETE"]}),v=function(r,t){var n=y(r);return n&&n.indexOf(t)>-1},d=(0,i.curry)(function(r,t){var n=Object.keys(r.cache),e=function(n){(0,i.startsWith)(t+"-",n)&&delete r.cache[n]};(0,i.map_)(e,n)}),h=function(r){return r.invalidates||[]},m=function(r,t,n){v(t,n.operation)&&(0,i.map_)(d(r),h(t))},b=function(r,t,n){var e=function(r){return t.name+"-"+r},o=(0,i.compose)(d(r),e);(0,i.map_)(o,h(n))};t.invalidate=function(r,t,n){m(r,t,n),b(r,t,n)},t.createQueryCache=function(r){return{entityStore:r,cache:{}}}},function(r,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.serialize=void 0;var e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(r){return typeof r}:function(r){return r&&"function"==typeof Symbol&&r.constructor===Symbol?"symbol":typeof r},o=(n(1),function u(r){return Object.keys(r).map(function(t){return r[t]&&"object"===e(r[t])?u(r[t]):r[t]}).join("-")});t.serialize=function(r){return r&&"object"===("undefined"==typeof r?"undefined":e(r))?o(r):r}},function(r,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.build=void 0;var e=Object.assign||function(r){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var e in n)Object.prototype.hasOwnProperty.call(n,e)&&(r[e]=n[e])}return r},o=function(){function r(r,t){var n=[],e=!0,o=!1,u=void 0;try{for(var i,a=r[Symbol.iterator]();!(e=(i=a.next()).done)&&(n.push(i.value),!t||n.length!==t);e=!0);}catch(c){o=!0,u=c}finally{try{!e&&a["return"]&&a["return"]()}finally{if(o)throw u}}return n}return function(t,n){if(Array.isArray(t))return t;if(Symbol.iterator in Object(t))return r(t,n);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}(),u=n(1),i=n(2),a=n(3),c=n(8),f=function(r){var t=o(r,2),n=t[0],u=t[1];return e({name:n},u)},l=(0,u.compose)((0,u.mapValues)((0,u.prop)("api")),(0,u.toObject)((0,u.prop)("name")));t.build=function(r){var t=(0,u.mapObject)(f,r),n=(0,i.createEntityStore)(t),e=(0,a.createQueryCache)(n),o=(0,u.compose)(l,(0,u.map)((0,c.decorate)(n,e)));return o(t)}},function(r,t,n){"use strict";function e(r,t,n,e){return function(){return e.apply(void 0,arguments).then((0,i.passThrough)((0,o.put)(r,n))).then((0,i.passThrough)(function(){return(0,u.invalidate)(t,n,e)}))}}Object.defineProperty(t,"__esModule",{value:!0}),t.decorateCreate=e;var o=n(2),u=n(3),i=n(1)},function(r,t,n){"use strict";function e(r,t,n,e){return function(){for(var a=arguments.length,c=Array(a),f=0;a>f;f++)c[f]=arguments[f];return(0,o.remove)(r,n,c.join("")),e.apply(void 0,c).then((0,i.passThrough)(function(){return(0,u.invalidate)(t,n,e)}))}}Object.defineProperty(t,"__esModule",{value:!0}),t.decorateDelete=e;var o=n(2),u=n(3),i=n(1)},function(r,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.decorate=void 0;var e=Object.assign||function(r){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var e in n)Object.prototype.hasOwnProperty.call(n,e)&&(r[e]=n[e])}return r},o=n(1),u=n(6),i=n(10),a=n(11),c=n(7),f=n(9),l=(0,o.curry)(function(r,t,n,e){var o={CREATE:u.decorateCreate,READ:i.decorateRead,UPDATE:a.decorateUpdate,DELETE:c.decorateDelete,NO_OPERATION:f.decorateNoOperation}[e.operation||"NO_OPERATION"];return o(r,t,n,e)});t.decorate=(0,o.curry)(function(r,t,n){var u=(0,o.mapValues)(l(r,t,n),n.api);return e({},n,{api:u})})},function(r,t,n){"use strict";function e(r,t,n,e){var i=e.bind(null);return i.operation="NO_OPERATION",function(){return e.apply(void 0,arguments).then((0,u.passThrough)(function(){return(0,o.invalidate)(t,n,i)}))}}Object.defineProperty(t,"__esModule",{value:!0}),t.decorateNoOperation=e;var o=n(3),u=n(1)},function(r,t,n){"use strict";function e(r,t,n,e){return e.byId?l(r,n,e):p(r,t,n,e)}Object.defineProperty(t,"__esModule",{value:!0}),t.decorateRead=e;var o=n(2),u=n(3),i=n(1),a=n(4),c=function(r){return 1e3*(r.ttl||0)},f=function(r,t){return Date.now()-t>c(r)},l=function(r,t,n){return function(e){if((0,o.contains)(r,t,e)&&!n.alwaysGetFreshData){var u=(0,o.get)(r,t,e);if(!f(t,u.timestamp))return Promise.resolve(u.value)}return n(e).then((0,i.passThrough)((0,o.put)(r,t)))}},s=(0,i.curry)(function(r,t,n){if("ARGS"===r.idFrom){if(Array.isArray(n))throw new Error("idFrom is only supported for objects");return n.id=(0,a.serialize)(t),n}return n}),p=function(r,t,n,e){return function(){for(var r=arguments.length,o=Array(r),a=0;r>a;a++)o[a]=arguments[a];if((0,u.contains)(t,n,e,o)&&!e.alwaysGetFreshData){var c=(0,u.get)(t,n,e,o);if(!f(n,c.timestamp))return Promise.resolve((0,u.getValue)(c.value))}return e.apply(void 0,o).then(s(e,o)).then((0,i.passThrough)((0,u.put)(t,n,e,o)))}}},function(r,t,n){"use strict";function e(r,t,n,e){return function(a){for(var c=arguments.length,f=Array(c>1?c-1:0),l=1;c>l;l++)f[l-1]=arguments[l];return(0,o.put)(r,n,a),e.apply(void 0,[a].concat(f)).then((0,i.passThrough)(function(){return(0,u.invalidate)(t,n,e)}))}}Object.defineProperty(t,"__esModule",{value:!0}),t.decorateUpdate=e;var o=n(2),u=n(3),i=n(1)},function(r,t){"use strict";function n(r,t){var u=i({},t),a=e(r);a.forEach(function(n){void 0!==t[n]&&(u[n]=r[n])});var c=o(r);return c.forEach(function(e){void 0!==t[e]&&(u[e]=n(r[e],t[e]))}),u}function e(r){return Object.keys(r).filter(function(t){return null===r[t]||"object"!==u(r[t])||Array.isArray(r[t])})}function o(r){return Object.keys(r).filter(function(t){return null!==r[t]&&!Array.isArray(r[t])&&"object"===u(r[t])})}Object.defineProperty(t,"__esModule",{value:!0});var u="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(r){return typeof r}:function(r){return r&&"function"==typeof Symbol&&r.constructor===Symbol?"symbol":typeof r},i=Object.assign||function(r){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var e in n)Object.prototype.hasOwnProperty.call(n,e)&&(r[e]=n[e])}return r};t.merge=n}]);
{
"name": "ladda-cache",
"version": "0.1.0",
"version": "0.1.1",
"description": "Data fetching layer with support for caching",

@@ -5,0 +5,0 @@ "main": "dist/bundle.js",

@@ -8,3 +8,4 @@ import {get as getFromEs,

getValue} from 'query-cache';
import {passThrough} from 'fp';
import {passThrough, curry} from 'fp';
import {serialize} from 'serializer';

@@ -31,2 +32,16 @@ const getTtl = e => (e.ttl || 0) * 1000;

const addId = curry((aFn, args, o) => {
// TODO Add id as a special field, allowing us to remove it before returning to the user.
// Eg. o.__ladda__id
if (aFn.idFrom === 'ARGS') {
if (Array.isArray(o)) {
throw new Error('idFrom is only supported for objects');
}
o.id = serialize(args);
return o;
} else {
return o;
}
});
const decorateReadQuery = (es, qc, e, aFn) => {

@@ -41,3 +56,3 @@ return (...args) => {

return aFn(...args).then(passThrough(putInQc(qc, e, aFn, args)));
return aFn(...args).then(addId(aFn, args)).then(passThrough(putInQc(qc, e, aFn, args)));
};

@@ -44,0 +59,0 @@ };

@@ -42,2 +42,32 @@ import {decorateRead} from './read';

describe('decorateRead', () => {
it('throws error if idFrom ARGS and array is returned', (done) => {
const es = createEntityStore(config);
const qc = createQueryCache(es);
const e = config[0];
const xOrg = [{id: 1, name: 'Kalle'}];
const aFn = sinon.spy(() => {
return Promise.resolve(xOrg);
});
aFn.idFrom = 'ARGS';
const res = decorateRead(es, qc, e, aFn);
res(1).catch(x => {
expect(x).to.be.an('Error');
done();
});
});
it('does set id to serialized args if idFrom ARGS', (done) => {
const es = createEntityStore(config);
const qc = createQueryCache(es);
const e = config[0];
const xOrg = {name: 'Kalle'};
const aFn = sinon.spy(() => {
return Promise.resolve(xOrg);
});
aFn.idFrom = 'ARGS';
const res = decorateRead(es, qc, e, aFn);
res({hello: 'hej', other: 'svej'}).then(x => {
expect(x).to.deep.equal({id: 'hej-svej', name: 'Kalle'});
done();
});
});
it('calls api fn if not in cache with byId set', (done) => {

@@ -44,0 +74,0 @@ const es = createEntityStore(config);

@@ -9,27 +9,6 @@ /* Handles queries, in essence all GET operations.

curry, map, map_, startsWith, compose, filter} from 'fp';
import {serialize} from 'serializer';
// @TODO consider moving serialize code to separate module.
const serializeObject = (o) => {
return Object.keys(o).map(x => {
if (o[x] && typeof o[x] === 'object') {
return serializeObject(o[x]);
} else {
return o[x];
}
}).join('-');
};
const mySerializer = (x) => {
const serialize = (y) => {
if (y && typeof y === 'object') {
return serializeObject(y);
} else {
return y;
}
};
return map(serialize, x);
};
// Entity -> [String] -> String
const createKey = on2(reduce(join('-')), prop('name'), mySerializer);
const createKey = on2(reduce(join('-')), prop('name'), map(serialize));

@@ -36,0 +15,0 @@ // Value -> CacheValue

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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