UNPKG

angular.js-server-ng-cache

Version:

A REST API and template caching for server side rendering with angular.js-server

7 lines (6 loc) 3.37 kB
/* angular.js-server-ng-cache v0.2.3 https://github.com/a-lucas/angular.js-server-ng-cache#readme */ !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports["angular.js-server-ng-cache"]=t():e["angular.js-server-ng-cache"]=t()}(this,function(){return function(e){function t(r){if(n[r])return n[r].exports;var o=n[r]={exports:{},id:r,loaded:!1};return e[r].call(o.exports,o,o.exports,t),o.loaded=!0,o.exports}var n={};return t.m=e,t.c=n,t.p="",t(0)}([function(e,t,n){"use strict";var r=n(1);angular.module("server-cache",[]).provider("$cacheFactory",r.$CacheFactoryProvider).provider("$templateCache",r.$TemplateCacheProvider).constant("serverCacheConfig",{defaultCache:!0}).config(function(e,t,n,r){t.defaults.cache=!0;var o=e.$get();o.onServer&&o.onServer===!0&&(o.$cacheFactoryProvider=n),"undefined"==typeof o.onServer&&"undefined"!=typeof o.$angularServerCache&&(n.importAll(o.$angularServerCache),o.addEventListener("StackQueueEmpty",function(){n.remove("$http"),t.defaults.cache=r.defaultCache}))})},function(e,t){"use strict";function n(){var e={};this.getCaches=function(){return e},this["export"]=function(t){if("undefined"==typeof cache[t])throw new Error("$cacheFactory - iid - CacheId "+t+" is not defined!");return e[t]["export"]()},this.exportAll=function(){var t={};for(var n in e)t[n]=e[n]["export"]();return t},this.remove=function(t){"undefined"!=typeof e[t]&&delete e[t]},this.removeAll=function(){e={}},this.importAll=function(t){var n=this.$get();for(var r in t)"undefined"==typeof e[r]&&(e[r]=n(r)),e[r]["import"](t[r])},this["import"]=function(t,n){var r=this.$get();"undefined"==typeof e[t]&&(e[t]=r(i)),e[t]["import"](n)},this.info=function(t){if("undefined"==typeof e[t])throw new Error("$cacheFactory - iid - CacheId "+t+" is not defined!");return e[t].info()},this.infoAll=function(){var t={};for(var n in e)t[n]=e[n].info();return t},this.$get=function(){function t(t,n){function r(e){e!==l&&(d?d===e&&(d=e.n):d=e,o(e.n,e.p),o(e,l),l=e,l.n=null)}function o(e,t){e!==t&&(e&&(e.p=t),t&&(t.n=e))}if(t in e)return e[t];var i=0,c=Object.assign({},n,{id:t}),u=Object.create(null),f=n&&n.capacity||Number.MAX_VALUE,a=Object.create(null),l=null,d=null;return e[t]={put:function(e,t){if("undefined"!=typeof t){if(f<Number.MAX_VALUE){var n=a[e]||(a[e]={key:e});r(n)}return e in u||i++,u[e]=t,i>f&&this.remove(d.key),t}},"export":function(){return u},"import":function(e){i=0,a=Object.create(null),l=null,d=null;for(var t in e)this.put(t,e[t])},get:function(e){if(f<Number.MAX_VALUE){var t=a[e];if(!t)return;r(t)}return u[e]},remove:function(e){if(f<Number.MAX_VALUE){var t=a[e];if(!t)return;t===l&&(l=t.p),t===d&&(d=t.n),o(t.n,t.p),delete a[e]}e in u&&(delete u[e],i--)},removeAll:function(){u=Object.create(null),i=0,a=Object.create(null),l=d=null},destroy:function(){u=null,c=null,a=null,delete e[t]},info:function(){return Object.assign({},c,{size:i})},keys:function(){return Object.getOwnPropertyNames(u)}}}return t.info=function(){var t={};for(var n in e)t[n]=e[n].info();return t},t}}function r(){this.$get=["$cacheFactory",function(e){return e("templates")}]}Object.defineProperty(t,"__esModule",{value:!0}),t.$CacheFactoryProvider=n,t.$TemplateCacheProvider=r}])}); //# sourceMappingURL=angular.js-server-ng-cache.min.js.map