3 * @version 4.6.0 - Homepage <https://github.com/jmdobry/angular-cache>
4 * @copyright (c) 2013-2016 angular-cache project authors
5 * @license MIT <https://github.com/jmdobry/angular-cache/blob/master/LICENSE>
6 * @overview angular-cache is a very useful replacement for Angular's $cacheFactory.
8 (function (global, factory) {
9 typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(typeof angular === 'undefined' ? require('angular') : angular) :
10 typeof define === 'function' && define.amd ? define('angular-cache', ['angular'], factory) :
11 (global.angularCacheModuleName = factory(global.angular));
12 }(this, function (angular) { 'use strict';
14 angular = 'default' in angular ? angular['default'] : angular;
16 var babelHelpers = {};
17 babelHelpers.typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) {
20 return obj && typeof Symbol === "function" && obj.constructor === Symbol ? "symbol" : typeof obj;
25 * @param {array} heap The heap.
26 * @param {function} weightFunc The weight function.
27 * @param {number} n The index of the element to bubble up.
29 var bubbleUp = function bubbleUp(heap, weightFunc, n) {
30 var element = heap[n];
31 var weight = weightFunc(element);
32 // When at 0, an element can not go up any further.
34 // Compute the parent element's index, and fetch it.
35 var parentN = Math.floor((n + 1) / 2) - 1;
36 var parent = heap[parentN];
37 // If the parent has a lesser weight, things are in order and we
39 if (weight >= weightFunc(parent)) {
42 heap[parentN] = element;
51 * @param {array} heap The heap.
52 * @param {function} weightFunc The weight function.
53 * @param {number} n The index of the element to sink down.
55 var bubbleDown = function bubbleDown(heap, weightFunc, n) {
56 var length = heap.length;
58 var nodeWeight = weightFunc(node);
61 var child2N = (n + 1) * 2;
62 var child1N = child2N - 1;
64 if (child1N < length) {
65 var child1 = heap[child1N];
66 var child1Weight = weightFunc(child1);
67 // If the score is less than our node's, we need to swap.
68 if (child1Weight < nodeWeight) {
72 // Do the same checks for the other child.
73 if (child2N < length) {
74 var child2 = heap[child2N];
75 var child2Weight = weightFunc(child2);
76 if (child2Weight < (swap === null ? nodeWeight : weightFunc(heap[child1N]))) {
91 function BinaryHeap(weightFunc, compareFunc) {
93 weightFunc = function weightFunc(x) {
98 compareFunc = function compareFunc(x, y) {
102 if (typeof weightFunc !== 'function') {
103 throw new Error('BinaryHeap([weightFunc][, compareFunc]): "weightFunc" must be a function!');
105 if (typeof compareFunc !== 'function') {
106 throw new Error('BinaryHeap([weightFunc][, compareFunc]): "compareFunc" must be a function!');
108 this.weightFunc = weightFunc;
109 this.compareFunc = compareFunc;
113 var BHProto = BinaryHeap.prototype;
115 BHProto.push = function (node) {
116 this.heap.push(node);
117 bubbleUp(this.heap, this.weightFunc, this.heap.length - 1);
120 BHProto.peek = function () {
124 BHProto.pop = function () {
125 var front = this.heap[0];
126 var end = this.heap.pop();
127 if (this.heap.length > 0) {
129 bubbleDown(this.heap, this.weightFunc, 0);
134 BHProto.remove = function (node) {
135 var length = this.heap.length;
136 for (var i = 0; i < length; i++) {
137 if (this.compareFunc(this.heap[i], node)) {
138 var removed = this.heap[i];
139 var end = this.heap.pop();
140 if (i !== length - 1) {
142 bubbleUp(this.heap, this.weightFunc, i);
143 bubbleDown(this.heap, this.weightFunc, i);
151 BHProto.removeAll = function () {
155 BHProto.size = function () {
156 return this.heap.length;
161 _Promise = window.Promise;
165 isNumber: function isNumber(value) {
166 return typeof value === 'number';
168 isString: function isString(value) {
169 return typeof value === 'string';
171 isObject: function isObject(value) {
172 return value !== null && (typeof value === 'undefined' ? 'undefined' : babelHelpers.typeof(value)) === 'object';
174 isFunction: function isFunction(value) {
175 return typeof value === 'function';
177 fromJson: function fromJson(value) {
178 return JSON.parse(value);
180 equals: function equals(a, b) {
187 function _keys(collection) {
190 if (!utils.isObject(collection)) {
193 for (key in collection) {
194 if (collection.hasOwnProperty(key)) {
201 function _isPromiseLike(value) {
202 return value && typeof value.then === 'function';
205 function _stringifyNumber(number) {
206 if (utils.isNumber(number)) {
207 return number.toString();
212 function _keySet(collection) {
215 if (!utils.isObject(collection)) {
218 for (key in collection) {
219 if (collection.hasOwnProperty(key)) {
227 capacity: Number.MAX_VALUE,
228 maxAge: Number.MAX_VALUE,
229 deleteOnExpire: 'none',
231 cacheFlushInterval: null,
233 storageMode: 'memory',
236 storagePrefix: 'cachefactory.caches.',
237 storeOnResolve: false,
243 function createCache(cacheId, options) {
244 if (cacheId in caches) {
245 throw new Error(cacheId + ' already exists!');
246 } else if (!utils.isString(cacheId)) {
247 throw new Error('cacheId must be a string!');
252 var $$storage = null;
253 var $$expiresHeap = new BinaryHeap(function (x) {
256 var $$lruHeap = new BinaryHeap(function (x) {
260 var cache = caches[cacheId] = {
264 destroy: function destroy() {
265 clearInterval(this.$$cacheFlushIntervalId);
266 clearInterval(this.$$recycleFreqId);
269 $$storage().removeItem(this.$$prefix + '.keys');
270 $$storage().removeItem(this.$$prefix);
275 $$expiresHeap = null;
276 this.$$prefix = null;
277 delete caches[this.$$id];
279 disable: function disable() {
280 this.$$disabled = true;
282 enable: function enable() {
283 delete this.$$disabled;
285 get: function get(key, options) {
288 if (Array.isArray(key)) {
289 var _ret = function () {
293 keys.forEach(function (key) {
294 var value = _this2.get(key, options);
295 if (value !== null && value !== undefined) {
305 if ((typeof _ret === 'undefined' ? 'undefined' : babelHelpers.typeof(_ret)) === "object") return _ret.v;
307 key = _stringifyNumber(key);
309 if (this.$$disabled) {
314 options = options || {};
315 if (!utils.isString(key)) {
316 throw new Error('key must be a string!');
317 } else if (options && !utils.isObject(options)) {
318 throw new Error('options must be an object!');
319 } else if (options.onExpire && !utils.isFunction(options.onExpire)) {
320 throw new Error('options.onExpire must be a function!');
326 if ($$promises[key]) {
327 return $$promises[key];
330 var itemJson = $$storage().getItem(this.$$prefix + '.data.' + key);
333 item = utils.fromJson(itemJson);
337 } else if (utils.isObject($$data)) {
338 if (!(key in $$data)) {
345 var value = item.value;
346 var now = new Date().getTime();
351 accessed: item.accessed
359 $$lruHeap.remove(item);
361 $$lruHeap.push(item);
364 if (this.$$deleteOnExpire === 'passive' && 'expires' in item && item.expires < now) {
367 if (this.$$onExpire) {
368 this.$$onExpire(key, item.value, options.onExpire);
369 } else if (options.onExpire) {
370 options.onExpire.call(this, key, item.value);
373 } else if ($$storage) {
374 $$storage().setItem(this.$$prefix + '.data.' + key, JSON.stringify(item));
379 info: function info(key) {
383 var itemJson = $$storage().getItem(this.$$prefix + '.data.' + key);
386 item = utils.fromJson(itemJson);
388 created: item.created,
389 accessed: item.accessed,
390 expires: item.expires,
391 isExpired: new Date().getTime() - item.created > (item.maxAge || this.$$maxAge)
396 } else if (utils.isObject($$data) && key in $$data) {
400 created: item.created,
401 accessed: item.accessed,
402 expires: item.expires,
403 isExpired: new Date().getTime() - item.created > (item.maxAge || this.$$maxAge)
411 capacity: this.$$capacity,
412 maxAge: this.$$maxAge,
413 deleteOnExpire: this.$$deleteOnExpire,
414 onExpire: this.$$onExpire,
415 cacheFlushInterval: this.$$cacheFlushInterval,
416 recycleFreq: this.$$recycleFreq,
417 storageMode: this.$$storageMode,
418 storageImpl: $$storage ? $$storage() : undefined,
419 disabled: !!this.$$disabled,
420 size: $$lruHeap && $$lruHeap.size() || 0
424 keys: function keys() {
426 var keysJson = $$storage().getItem(this.$$prefix + '.keys');
429 return utils.fromJson(keysJson);
434 return _keys($$data);
437 keySet: function keySet() {
439 var keysJson = $$storage().getItem(this.$$prefix + '.keys');
443 var keys = utils.fromJson(keysJson);
445 for (var i = 0; i < keys.length; i++) {
446 kSet[keys[i]] = keys[i];
451 return _keySet($$data);
454 put: function put(key, value, options) {
457 options || (options = {});
459 var storeOnResolve = 'storeOnResolve' in options ? !!options.storeOnResolve : this.$$storeOnResolve;
460 var storeOnReject = 'storeOnReject' in options ? !!options.storeOnReject : this.$$storeOnReject;
462 var getHandler = function getHandler(store, isError) {
463 return function (v) {
465 delete $$promises[key];
466 if (utils.isObject(v) && 'status' in v && 'data' in v) {
467 v = [v.status, v.data, v.headers(), v.statusText];
475 return utils.Promise.reject(v);
485 if (this.$$disabled || !utils.isObject($$data) || value === null || value === undefined) {
488 key = _stringifyNumber(key);
490 if (!utils.isString(key)) {
491 throw new Error('key must be a string!');
494 var now = new Date().getTime();
497 value: _isPromiseLike(value) ? value.then(getHandler(storeOnResolve, false), getHandler(storeOnReject, true)) : value,
498 created: options.created === undefined ? now : options.created,
499 accessed: options.accessed === undefined ? now : options.accessed
501 if (options.maxAge) {
502 item.maxAge = options.maxAge;
505 if (options.expires === undefined) {
506 item.expires = item.created + (item.maxAge || this.$$maxAge);
508 item.expires = options.expires;
512 if (_isPromiseLike(item.value)) {
513 $$promises[key] = item.value;
514 return $$promises[key];
516 var keysJson = $$storage().getItem(this.$$prefix + '.keys');
517 var keys = keysJson ? utils.fromJson(keysJson) : [];
518 var itemJson = $$storage().getItem(this.$$prefix + '.data.' + key);
524 // Add to expires heap
527 expires: item.expires
532 accessed: item.accessed
535 $$storage().setItem(this.$$prefix + '.data.' + key, JSON.stringify(item));
537 for (var i = 0; i < keys.length; i++) {
538 if (keys[i] === key) {
546 $$storage().setItem(this.$$prefix + '.keys', JSON.stringify(keys));
552 // Add to expires heap
553 $$expiresHeap.push(item);
555 $$lruHeap.push(item);
558 delete $$promises[key];
561 // Handle exceeded capacity
562 if ($$lruHeap.size() > this.$$capacity) {
563 this.remove($$lruHeap.peek().key);
568 remove: function remove(key) {
570 delete $$promises[key];
572 var itemJson = $$storage().getItem(this.$$prefix + '.data.' + key);
575 var item = utils.fromJson(itemJson);
578 accessed: item.accessed
580 $$expiresHeap.remove({
582 expires: item.expires
584 $$storage().removeItem(this.$$prefix + '.data.' + key);
585 var keysJson = $$storage().getItem(this.$$prefix + '.keys');
586 var keys = keysJson ? utils.fromJson(keysJson) : [];
587 var index = keys.indexOf(key);
590 keys.splice(index, 1);
592 $$storage().setItem(this.$$prefix + '.keys', JSON.stringify(keys));
595 } else if (utils.isObject($$data)) {
596 var value = $$data[key] ? $$data[key].value : undefined;
597 $$lruHeap.remove($$data[key]);
598 $$expiresHeap.remove($$data[key]);
604 removeAll: function removeAll() {
606 $$lruHeap.removeAll();
607 $$expiresHeap.removeAll();
608 var keysJson = $$storage().getItem(this.$$prefix + '.keys');
611 var keys = utils.fromJson(keysJson);
613 for (var i = 0; i < keys.length; i++) {
614 this.remove(keys[i]);
617 $$storage().setItem(this.$$prefix + '.keys', JSON.stringify([]));
618 } else if (utils.isObject($$data)) {
619 $$lruHeap.removeAll();
620 $$expiresHeap.removeAll();
621 for (var key in $$data) {
626 $$lruHeap.removeAll();
627 $$expiresHeap.removeAll();
632 removeExpired: function removeExpired() {
633 var now = new Date().getTime();
636 var expiredItem = void 0;
638 while ((expiredItem = $$expiresHeap.peek()) && expiredItem.expires <= now) {
639 expired[expiredItem.key] = expiredItem.value ? expiredItem.value : null;
644 for (key in expired) {
645 var itemJson = $$storage().getItem(this.$$prefix + '.data.' + key);
647 expired[key] = utils.fromJson(itemJson).value;
652 for (key in expired) {
657 if (this.$$onExpire) {
658 for (key in expired) {
659 this.$$onExpire(key, expired[key]);
665 setCacheFlushInterval: function setCacheFlushInterval(cacheFlushInterval) {
667 if (cacheFlushInterval === null) {
668 delete _this.$$cacheFlushInterval;
669 } else if (!utils.isNumber(cacheFlushInterval)) {
670 throw new Error('cacheFlushInterval must be a number!');
671 } else if (cacheFlushInterval < 0) {
672 throw new Error('cacheFlushInterval must be greater than zero!');
673 } else if (cacheFlushInterval !== _this.$$cacheFlushInterval) {
674 _this.$$cacheFlushInterval = cacheFlushInterval;
676 clearInterval(_this.$$cacheFlushIntervalId); // eslint-disable-line
678 _this.$$cacheFlushIntervalId = setInterval(function () {
680 }, _this.$$cacheFlushInterval);
683 setCapacity: function setCapacity(capacity) {
684 if (capacity === null) {
685 delete this.$$capacity;
686 } else if (!utils.isNumber(capacity)) {
687 throw new Error('capacity must be a number!');
688 } else if (capacity < 0) {
689 throw new Error('capacity must be greater than zero!');
691 this.$$capacity = capacity;
694 while ($$lruHeap.size() > this.$$capacity) {
695 removed[$$lruHeap.peek().key] = this.remove($$lruHeap.peek().key);
699 setDeleteOnExpire: function setDeleteOnExpire(deleteOnExpire, setRecycleFreq) {
700 if (deleteOnExpire === null) {
701 delete this.$$deleteOnExpire;
702 } else if (!utils.isString(deleteOnExpire)) {
703 throw new Error('deleteOnExpire must be a string!');
704 } else if (deleteOnExpire !== 'none' && deleteOnExpire !== 'passive' && deleteOnExpire !== 'aggressive') {
705 throw new Error('deleteOnExpire must be "none", "passive" or "aggressive"!');
707 this.$$deleteOnExpire = deleteOnExpire;
709 if (setRecycleFreq !== false) {
710 this.setRecycleFreq(this.$$recycleFreq);
713 setMaxAge: function setMaxAge(maxAge) {
714 if (maxAge === null) {
715 this.$$maxAge = Number.MAX_VALUE;
716 } else if (!utils.isNumber(maxAge)) {
717 throw new Error('maxAge must be a number!');
718 } else if (maxAge < 0) {
719 throw new Error('maxAge must be greater than zero!');
721 this.$$maxAge = maxAge;
727 $$expiresHeap.removeAll();
730 var keysJson = $$storage().getItem(this.$$prefix + '.keys');
732 keys = keysJson ? utils.fromJson(keysJson) : [];
734 for (i = 0; i < keys.length; i++) {
736 var itemJson = $$storage().getItem(this.$$prefix + '.data.' + key);
739 var item = utils.fromJson(itemJson);
740 if (this.$$maxAge === Number.MAX_VALUE) {
741 item.expires = Number.MAX_VALUE;
743 item.expires = item.created + (item.maxAge || this.$$maxAge);
747 expires: item.expires
752 keys = _keys($$data);
754 for (i = 0; i < keys.length; i++) {
756 if (this.$$maxAge === Number.MAX_VALUE) {
757 $$data[key].expires = Number.MAX_VALUE;
759 $$data[key].expires = $$data[key].created + ($$data[key].maxAge || this.$$maxAge);
761 $$expiresHeap.push($$data[key]);
764 if (this.$$deleteOnExpire === 'aggressive') {
765 return this.removeExpired();
770 setOnExpire: function setOnExpire(onExpire) {
771 if (onExpire === null) {
772 delete this.$$onExpire;
773 } else if (!utils.isFunction(onExpire)) {
774 throw new Error('onExpire must be a function!');
776 this.$$onExpire = onExpire;
779 setOptions: function setOptions(cacheOptions, strict) {
780 cacheOptions = cacheOptions || {};
782 if (!utils.isObject(cacheOptions)) {
783 throw new Error('cacheOptions must be an object!');
786 if ('storagePrefix' in cacheOptions) {
787 this.$$storagePrefix = cacheOptions.storagePrefix;
789 this.$$storagePrefix = defaults.storagePrefix;
792 this.$$prefix = this.$$storagePrefix + this.$$id;
794 if ('disabled' in cacheOptions) {
795 this.$$disabled = !!cacheOptions.disabled;
797 this.$$disabled = defaults.disabled;
800 if ('deleteOnExpire' in cacheOptions) {
801 this.setDeleteOnExpire(cacheOptions.deleteOnExpire, false);
803 this.setDeleteOnExpire(defaults.deleteOnExpire, false);
806 if ('recycleFreq' in cacheOptions) {
807 this.setRecycleFreq(cacheOptions.recycleFreq);
809 this.setRecycleFreq(defaults.recycleFreq);
812 if ('maxAge' in cacheOptions) {
813 this.setMaxAge(cacheOptions.maxAge);
815 this.setMaxAge(defaults.maxAge);
818 if ('storeOnResolve' in cacheOptions) {
819 this.$$storeOnResolve = !!cacheOptions.storeOnResolve;
821 this.$$storeOnResolve = defaults.storeOnResolve;
824 if ('storeOnReject' in cacheOptions) {
825 this.$$storeOnReject = !!cacheOptions.storeOnReject;
827 this.$$storeOnReject = defaults.storeOnReject;
830 if ('capacity' in cacheOptions) {
831 this.setCapacity(cacheOptions.capacity);
833 this.setCapacity(defaults.capacity);
836 if ('cacheFlushInterval' in cacheOptions) {
837 this.setCacheFlushInterval(cacheOptions.cacheFlushInterval);
839 this.setCacheFlushInterval(defaults.cacheFlushInterval);
842 if ('onExpire' in cacheOptions) {
843 this.setOnExpire(cacheOptions.onExpire);
845 this.setOnExpire(defaults.onExpire);
848 if ('storageMode' in cacheOptions || 'storageImpl' in cacheOptions) {
849 this.setStorageMode(cacheOptions.storageMode || defaults.storageMode, cacheOptions.storageImpl || defaults.storageImpl);
851 this.setStorageMode(defaults.storageMode, defaults.storageImpl);
854 setRecycleFreq: function setRecycleFreq(recycleFreq) {
855 if (recycleFreq === null) {
856 delete this.$$recycleFreq;
857 } else if (!utils.isNumber(recycleFreq)) {
858 throw new Error('recycleFreq must be a number!');
859 } else if (recycleFreq < 0) {
860 throw new Error('recycleFreq must be greater than zero!');
862 this.$$recycleFreq = recycleFreq;
864 clearInterval(this.$$recycleFreqId);
865 if (this.$$deleteOnExpire === 'aggressive') {
867 self.$$recycleFreqId = setInterval(function () {
868 self.removeExpired();
869 }, self.$$recycleFreq);
872 delete this.$$recycleFreqId;
875 setStorageMode: function setStorageMode(storageMode, storageImpl) {
876 if (!utils.isString(storageMode)) {
877 throw new Error('storageMode must be a string!');
878 } else if (storageMode !== 'memory' && storageMode !== 'localStorage' && storageMode !== 'sessionStorage') {
879 throw new Error('storageMode must be "memory", "localStorage" or "sessionStorage"!');
882 var prevStorage = $$storage;
883 var prevData = $$data;
884 var shouldReInsert = false;
887 function load(prevStorage, prevData) {
888 var keys = this.keys();
889 var length = keys.length;
892 var prevDataIsObject = utils.isObject(prevData);
893 for (var i = 0; i < length; i++) {
896 var itemJson = prevStorage().getItem(this.$$prefix + '.data.' + _key);
898 items[_key] = utils.fromJson(itemJson);
900 } else if (prevDataIsObject) {
901 items[_key] = prevData[_key];
905 shouldReInsert = true;
909 if (!this.$$initializing) {
910 load.call(this, prevStorage, prevData);
913 this.$$storageMode = storageMode;
916 if (!utils.isObject(storageImpl)) {
917 throw new Error('storageImpl must be an object!');
918 } else if (!('setItem' in storageImpl) || typeof storageImpl.setItem !== 'function') {
919 throw new Error('storageImpl must implement "setItem(key, value)"!');
920 } else if (!('getItem' in storageImpl) || typeof storageImpl.getItem !== 'function') {
921 throw new Error('storageImpl must implement "getItem(key)"!');
922 } else if (!('removeItem' in storageImpl) || typeof storageImpl.removeItem !== 'function') {
923 throw new Error('storageImpl must implement "removeItem(key)"!');
925 $$storage = function $$storage() {
928 } else if (this.$$storageMode === 'localStorage') {
930 localStorage.setItem('cachefactory', 'cachefactory');
931 localStorage.removeItem('cachefactory');
932 $$storage = function $$storage() {
937 this.$$storageMode = 'memory';
939 } else if (this.$$storageMode === 'sessionStorage') {
941 sessionStorage.setItem('cachefactory', 'cachefactory');
942 sessionStorage.removeItem('cachefactory');
943 $$storage = function $$storage() {
944 return sessionStorage;
948 this.$$storageMode = 'memory';
952 this.$$storageMode = 'memory';
955 if (this.$$initializing) {
956 load.call(this, $$storage, $$data);
959 if (shouldReInsert) {
961 for (var key in items) {
963 this.put(key, item.value, {
964 created: item.created,
965 accessed: item.accessed,
966 expires: item.expires
971 touch: function touch(key, options) {
975 var val = this.get(key, {
976 onExpire: function onExpire(k, v) {
977 return _this4.put(k, v);
981 this.put(key, val, options);
984 var keys = this.keys();
985 for (var i = 0; i < keys.length; i++) {
986 this.touch(keys[i], options);
990 values: function values() {
991 var keys = this.keys();
993 for (var i = 0; i < keys.length; i++) {
994 items.push(this.get(keys[i]));
1000 cache.$$initializing = true;
1001 cache.setOptions(options, true);
1002 cache.$$initializing = false;
1007 function CacheFactory(cacheId, options) {
1008 return createCache(cacheId, options);
1011 CacheFactory.createCache = createCache;
1012 CacheFactory.defaults = defaults;
1014 CacheFactory.info = function () {
1015 var keys = _keys(caches);
1020 for (var opt in defaults) {
1021 if (defaults.hasOwnProperty(opt)) {
1022 info[opt] = defaults[opt];
1025 for (var i = 0; i < keys.length; i++) {
1027 info.caches[key] = caches[key].info();
1032 CacheFactory.get = function (cacheId) {
1033 return caches[cacheId];
1035 CacheFactory.keySet = function () {
1036 return _keySet(caches);
1038 CacheFactory.keys = function () {
1039 return _keys(caches);
1041 CacheFactory.destroy = function (cacheId) {
1042 if (caches[cacheId]) {
1043 caches[cacheId].destroy();
1044 delete caches[cacheId];
1047 CacheFactory.destroyAll = function () {
1048 for (var cacheId in caches) {
1049 caches[cacheId].destroy();
1053 CacheFactory.clearAll = function () {
1054 for (var cacheId in caches) {
1055 caches[cacheId].removeAll();
1058 CacheFactory.removeExpiredFromAll = function () {
1060 for (var cacheId in caches) {
1061 expired[cacheId] = caches[cacheId].removeExpired();
1065 CacheFactory.enableAll = function () {
1066 for (var cacheId in caches) {
1067 caches[cacheId].$$disabled = false;
1070 CacheFactory.disableAll = function () {
1071 for (var cacheId in caches) {
1072 caches[cacheId].$$disabled = true;
1075 CacheFactory.touchAll = function () {
1076 for (var cacheId in caches) {
1077 caches[cacheId].touch();
1081 CacheFactory.utils = utils;
1082 CacheFactory.BinaryHeap = BinaryHeap;
1084 CacheFactory.utils.equals = angular.equals;
1085 CacheFactory.utils.isObject = angular.isObject;
1086 CacheFactory.utils.fromJson = angular.fromJson;
1088 function BinaryHeapProvider() {
1089 this.$get = function () {
1090 return CacheFactory.BinaryHeap;
1094 function CacheFactoryProvider() {
1095 this.defaults = CacheFactory.defaults;
1096 this.defaults.storagePrefix = 'angular-cache.caches.';
1098 this.$get = ['$q', function ($q) {
1099 CacheFactory.utils.Promise = $q;
1100 return CacheFactory;
1104 angular.module('angular-cache', []).provider('BinaryHeap', BinaryHeapProvider).provider('CacheFactory', CacheFactoryProvider);
1106 var index = 'angular-cache';
1111 //# sourceMappingURL=angular-cache.js.map