diff --git a/.jshintrc b/.jshintrc deleted file mode 100644 index 51593b9..0000000 --- a/.jshintrc +++ /dev/null @@ -1,33 +0,0 @@ -{ - "node": false, - "browser": true, - "esnext": true, - "bitwise": true, - "camelcase": true, - "curly": true, - "eqeqeq": true, - "immed": true, - "indent": 2, - "latedef": true, - "newcap": true, - "noarg": true, - "quotmark": "single", - "regexp": true, - "undef": true, - "unused": true, - "strict": false, - "trailing": true, - "smarttabs": true, - "globals": { - "describe": true, - "it": true, - "beforeEach": true, - "afterEach": true, - "assert": true, - "fail": true, - "console": true, - "require": true, - "module": true, - "exports": true - } -} diff --git a/.npmignore b/.npmignore deleted file mode 100644 index fac0c6d..0000000 --- a/.npmignore +++ /dev/null @@ -1,9 +0,0 @@ -.* -bower.json -*.iml -.idea/ -test/ -coverage/ -bower_components/ -karma* -Gruntfile.js diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index c30ffe9..0000000 --- a/.travis.yml +++ /dev/null @@ -1,13 +0,0 @@ -language: node_js -node_js: - - "0.10" - - "0.11" -before_install: - - npm install -g bower - - bower install - - npm install -g grunt-cli -before_script: - - export DISPLAY=:99.0 - - sh -e /etc/init.d/xvfb start -script: - - npm run ci diff --git a/CHANGELOG.md b/CHANGELOG.md index 88cf56d..b5f917d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,7 +1,12 @@ +##### 4.6.0 29 April 2016 + +###### Bug fixes +- #215 - angular-cache.min.js tries to load the .map from dist/ +- #204 - Does not work with Angular 1.3 and browserify + ##### 4.5.0 12 January 2016 ###### Backwards compatible API changes - - #205 - Feature request: Cache.getAllValues ###### Backwards compatible bug fixes diff --git a/LICENSE b/LICENSE index 54f8a93..ab9faee 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ The MIT License -Copyright (C) 2013-2016 Jason Dobry +Copyright (C) 2013-2016 angular-cache project authors Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in diff --git a/README.md b/README.md index 4afc91b..a24a57b 100644 --- a/README.md +++ b/README.md @@ -1,19 +1,15 @@ -## angular-cache [![bower version](https://img.shields.io/bower/v/angular-cache.svg?style=flat-square)](https://www.npmjs.org/package/angular-cache) [![npm version](https://img.shields.io/npm/v/angular-cache.svg?style=flat-square)](https://www.npmjs.org/package/angular-cache) [![Circle CI](https://img.shields.io/circleci/project/jmdobry/angular-cache/master.svg?style=flat-square)](https://circleci.com/gh/jmdobry/angular-cache/tree/master) [![npm downloads](https://img.shields.io/npm/dm/angular-cache.svg?style=flat-square)](https://www.npmjs.org/package/angular-cache) [![License](https://img.shields.io/badge/license-MIT-blue.svg?style=flat-square)](https://github.com/jmdobry/angular-cache/blob/master/LICENSE) +# angular-cache + +[![bower version](https://img.shields.io/bower/v/angular-cache.svg?style=flat)](https://www.npmjs.org/package/angular-cache) +[![npm version](https://img.shields.io/npm/v/angular-cache.svg?style=flat)](https://www.npmjs.org/package/angular-cache) +[![Circle CI](https://img.shields.io/circleci/project/jmdobry/angular-cache/master.svg?style=flat)](https://circleci.com/gh/jmdobry/angular-cache/tree/master) +[![npm downloads](https://img.shields.io/npm/dm/angular-cache.svg?style=flat)](https://www.npmjs.org/package/angular-cache) +[![codecov](https://img.shields.io/codecov/c/github/jmdobry/angular-cache.svg)](https://codecov.io/gh/jmdobry/angular-cache) A very useful replacement for Angular's $cacheFactory. __versions of angular-cache below 4.0.0 have been deprecated, see the [breaking changes](https://github.com/jmdobry/angular-cache/blob/master/CHANGELOG.md) in 4.0.0__ -__Latest Release:__ [![Latest Release](https://img.shields.io/github/release/jmdobry/angular-cache.svg?style=flat-square)](https://github.com/jmdobry/angular-cache/releases) - -__Status:__ - -[![Dependency Status](https://img.shields.io/gemnasium/jmdobry/angular-cache.svg?style=flat-square)](https://gemnasium.com/jmdobry/angular-cache) [![Coverage Status](https://img.shields.io/coveralls/jmdobry/angular-cache/master.svg?style=flat-square)](https://coveralls.io/r/jmdobry/angular-cache?branch=master) [![Codacity](https://img.shields.io/codacy/5e27e21d0c4c4d4cb203d589384aa93a.svg?style=flat-square)](https://www.codacy.com/public/jasondobry/angular-cache/dashboard) - -__Supported Browsers:__ - -[![browsers](https://img.shields.io/badge/Browser-Chrome%2CFirefox%2CSafari%2COpera%2CIE%209%2B%2CiOS%20Safari%207.1%2B%2CAndroid%20Browser%202.3%2B-green.svg?style=flat-square)](https://github.com/jmdobry/angular-cache) - ### Table of Contents - [Quick Start](#quick-start) - [The Basics](#the-basics) @@ -655,7 +651,7 @@ Set multiple options for the cache at a time. Setting `strict` to `true` will re ### License [MIT License](https://github.com/jmdobry/angular-cache/blob/master/LICENSE) -Copyright (C) 2013-2016 Jason Dobry +Copyright (C) 2013-2016 angular-cache project authors Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in diff --git a/circle.yml b/circle.yml index 74b0946..cfe8577 100644 --- a/circle.yml +++ b/circle.yml @@ -1,8 +1,6 @@ -dependencies: - pre: - - bower install - cache_directories: - - "bower_components" +machine: + node: + version: 4.1.0 test: - post: - - grunt coveralls || true + override: + - npm run ci diff --git a/dist/angular-cache.js b/dist/angular-cache.js index be22542..6a62e9b 100644 --- a/dist/angular-cache.js +++ b/dist/angular-cache.js @@ -1,1327 +1,1111 @@ -/*! +/** * angular-cache - * @version 4.5.0 - Homepage - * @author Jason Dobry - * @copyright (c) 2013-2016 Jason Dobry + * @version 4.6.0 - Homepage + * @copyright (c) 2013-2016 angular-cache project authors * @license MIT - * * @overview angular-cache is a very useful replacement for Angular's $cacheFactory. */ -(function webpackUniversalModuleDefinition(root, factory) { - if(typeof exports === 'object' && typeof module === 'object') - module.exports = factory(require("angular")); - else if(typeof define === 'function' && define.amd) - define("angular-cache", ["angular"], factory); - else if(typeof exports === 'object') - exports["angularCacheModuleName"] = factory(require("angular")); - else - root["angularCacheModuleName"] = factory(root["angular"]); -})(this, function(__WEBPACK_EXTERNAL_MODULE_1__) { -return /******/ (function(modules) { // webpackBootstrap -/******/ // The module cache -/******/ var installedModules = {}; -/******/ -/******/ // The require function -/******/ function __webpack_require__(moduleId) { -/******/ -/******/ // Check if module is in cache -/******/ if(installedModules[moduleId]) -/******/ return installedModules[moduleId].exports; -/******/ -/******/ // Create a new module (and put it into the cache) -/******/ var module = installedModules[moduleId] = { -/******/ exports: {}, -/******/ id: moduleId, -/******/ loaded: false -/******/ }; -/******/ -/******/ // Execute the module function -/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__); -/******/ -/******/ // Flag the module as loaded -/******/ module.loaded = true; -/******/ -/******/ // Return the exports of the module -/******/ return module.exports; -/******/ } -/******/ -/******/ -/******/ // expose the modules object (__webpack_modules__) -/******/ __webpack_require__.m = modules; -/******/ -/******/ // expose the module cache -/******/ __webpack_require__.c = installedModules; -/******/ -/******/ // __webpack_public_path__ -/******/ __webpack_require__.p = ""; -/******/ -/******/ // Load entry module and return exports -/******/ return __webpack_require__(0); -/******/ }) -/************************************************************************/ -/******/ ([ -/* 0 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - var angular = __webpack_require__(1); - var CacheFactory = __webpack_require__(2); - - CacheFactory.utils.equals = angular.equals; - CacheFactory.utils.isObject = angular.isObject; - CacheFactory.utils.fromJson = angular.fromJson; - - function BinaryHeapProvider() { - this.$get = function () { - return CacheFactory.BinaryHeap; - }; - } - - function CacheFactoryProvider() { - this.defaults = CacheFactory.defaults; - this.defaults.storagePrefix = 'angular-cache.caches.'; - - this.$get = ['$q', function ($q) { - CacheFactory.utils.Promise = $q; - return CacheFactory; - }]; - } - - angular.module('angular-cache', []).provider('BinaryHeap', BinaryHeapProvider).provider('CacheFactory', CacheFactoryProvider); - - module.exports = 'angular-cache'; - try { - module.exports.name = 'angular-cache'; - } catch (err) {} - -/***/ }, -/* 1 */ -/***/ function(module, exports) { - - module.exports = __WEBPACK_EXTERNAL_MODULE_1__; - -/***/ }, -/* 2 */ -/***/ function(module, exports, __webpack_require__) { - - /*! - * cachefactory - * @version 1.4.0 - Homepage - * @author Jason Dobry - * @copyright (c) 2013-2016 Jason Dobry - * @license MIT - * - * @overview CacheFactory is a very simple and useful cache for the browser. - */ - (function webpackUniversalModuleDefinition(root, factory) { - if(true) - module.exports = factory(); - else if(typeof define === 'function' && define.amd) - define("cachefactory", [], factory); - else if(typeof exports === 'object') - exports["CacheFactory"] = factory(); - else - root["CacheFactory"] = factory(); - })(this, function() { - return /******/ (function(modules) { // webpackBootstrap - /******/ // The module cache - /******/ var installedModules = {}; - /******/ - /******/ // The require function - /******/ function __webpack_require__(moduleId) { - /******/ - /******/ // Check if module is in cache - /******/ if(installedModules[moduleId]) - /******/ return installedModules[moduleId].exports; - /******/ - /******/ // Create a new module (and put it into the cache) - /******/ var module = installedModules[moduleId] = { - /******/ exports: {}, - /******/ id: moduleId, - /******/ loaded: false - /******/ }; - /******/ - /******/ // Execute the module function - /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__); - /******/ - /******/ // Flag the module as loaded - /******/ module.loaded = true; - /******/ - /******/ // Return the exports of the module - /******/ return module.exports; - /******/ } - /******/ - /******/ - /******/ // expose the modules object (__webpack_modules__) - /******/ __webpack_require__.m = modules; - /******/ - /******/ // expose the module cache - /******/ __webpack_require__.c = installedModules; - /******/ - /******/ // __webpack_public_path__ - /******/ __webpack_require__.p = ""; - /******/ - /******/ // Load entry module and return exports - /******/ return __webpack_require__(0); - /******/ }) - /************************************************************************/ - /******/ ([ - /* 0 */ - /***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol ? "symbol" : typeof obj; }; - - var BinaryHeap = __webpack_require__(1); - var _Promise = null; - try { - _Promise = window.Promise; - } catch (e) {} - - var utils = { - isNumber: function isNumber(value) { - return typeof value === 'number'; - }, - isString: function isString(value) { - return typeof value === 'string'; - }, - isObject: function isObject(value) { - return value !== null && (typeof value === 'undefined' ? 'undefined' : _typeof(value)) === 'object'; - }, - isFunction: function isFunction(value) { - return typeof value === 'function'; - }, - fromJson: function fromJson(value) { - return JSON.parse(value); - }, - equals: function equals(a, b) { - return a === b; - }, - - Promise: _Promise - }; - - function _keys(collection) { - var keys = []; - var key = undefined; - if (!utils.isObject(collection)) { - return keys; - } - for (key in collection) { - if (collection.hasOwnProperty(key)) { - keys.push(key); - } - } - return keys; - } - - function _isPromiseLike(value) { - return value && typeof value.then === 'function'; - } - - function _stringifyNumber(number) { - if (utils.isNumber(number)) { - return number.toString(); - } - return number; - } - - function _keySet(collection) { - var keySet = {}; - var key = undefined; - if (!utils.isObject(collection)) { - return keySet; - } - for (key in collection) { - if (collection.hasOwnProperty(key)) { - keySet[key] = key; - } - } - return keySet; - } - - var defaults = { - capacity: Number.MAX_VALUE, - maxAge: Number.MAX_VALUE, - deleteOnExpire: 'none', - onExpire: null, - cacheFlushInterval: null, - recycleFreq: 1000, - storageMode: 'memory', - storageImpl: null, - disabled: false, - storagePrefix: 'cachefactory.caches.', - storeOnResolve: false, - storeOnReject: false - }; - - var caches = {}; - - function createCache(cacheId, options) { - if (cacheId in caches) { - throw new Error(cacheId + ' already exists!'); - } else if (!utils.isString(cacheId)) { - throw new Error('cacheId must be a string!'); - } - - var $$data = {}; - var $$promises = {}; - var $$storage = null; - var $$expiresHeap = new BinaryHeap(function (x) { - return x.expires; - }, utils.equals); - var $$lruHeap = new BinaryHeap(function (x) { - return x.accessed; - }, utils.equals); - - var cache = caches[cacheId] = { - - $$id: cacheId, - - destroy: function destroy() { - clearInterval(this.$$cacheFlushIntervalId); - clearInterval(this.$$recycleFreqId); - this.removeAll(); - if ($$storage) { - $$storage().removeItem(this.$$prefix + '.keys'); - $$storage().removeItem(this.$$prefix); - } - $$storage = null; - $$data = null; - $$lruHeap = null; - $$expiresHeap = null; - this.$$prefix = null; - delete caches[this.$$id]; - }, - disable: function disable() { - this.$$disabled = true; - }, - enable: function enable() { - delete this.$$disabled; - }, - get: function get(key, options) { - var _this2 = this; - - if (Array.isArray(key)) { - var _ret = function () { - var keys = key; - var values = []; - - keys.forEach(function (key) { - var value = _this2.get(key, options); - if (value !== null && value !== undefined) { - values.push(value); - } - }); - - return { - v: values - }; - }(); - - if ((typeof _ret === 'undefined' ? 'undefined' : _typeof(_ret)) === "object") return _ret.v; - } else { - key = _stringifyNumber(key); - - if (this.$$disabled) { - return; - } - } - - options = options || {}; - if (!utils.isString(key)) { - throw new Error('key must be a string!'); - } else if (options && !utils.isObject(options)) { - throw new Error('options must be an object!'); - } else if (options.onExpire && !utils.isFunction(options.onExpire)) { - throw new Error('options.onExpire must be a function!'); - } - - var item = undefined; - - if ($$storage) { - if ($$promises[key]) { - return $$promises[key]; - } - - var itemJson = $$storage().getItem(this.$$prefix + '.data.' + key); - - if (itemJson) { - item = utils.fromJson(itemJson); - } else { - return; - } - } else if (utils.isObject($$data)) { - if (!(key in $$data)) { - return; - } - - item = $$data[key]; - } - - var value = item.value; - var now = new Date().getTime(); - - if ($$storage) { - $$lruHeap.remove({ - key: key, - accessed: item.accessed - }); - item.accessed = now; - $$lruHeap.push({ - key: key, - accessed: now - }); - } else { - $$lruHeap.remove(item); - item.accessed = now; - $$lruHeap.push(item); - } - - if (this.$$deleteOnExpire === 'passive' && 'expires' in item && item.expires < now) { - this.remove(key); - - if (this.$$onExpire) { - this.$$onExpire(key, item.value, options.onExpire); - } else if (options.onExpire) { - options.onExpire.call(this, key, item.value); - } - value = undefined; - } else if ($$storage) { - $$storage().setItem(this.$$prefix + '.data.' + key, JSON.stringify(item)); - } - - return value; - }, - info: function info(key) { - if (key) { - var item = undefined; - if ($$storage) { - var itemJson = $$storage().getItem(this.$$prefix + '.data.' + key); - - if (itemJson) { - item = utils.fromJson(itemJson); - return { - created: item.created, - accessed: item.accessed, - expires: item.expires, - isExpired: new Date().getTime() - item.created > (item.maxAge || this.$$maxAge) - }; - } else { - return undefined; - } - } else if (utils.isObject($$data) && key in $$data) { - item = $$data[key]; - - return { - created: item.created, - accessed: item.accessed, - expires: item.expires, - isExpired: new Date().getTime() - item.created > (item.maxAge || this.$$maxAge) - }; - } else { - return undefined; - } - } else { - return { - id: this.$$id, - capacity: this.$$capacity, - maxAge: this.$$maxAge, - deleteOnExpire: this.$$deleteOnExpire, - onExpire: this.$$onExpire, - cacheFlushInterval: this.$$cacheFlushInterval, - recycleFreq: this.$$recycleFreq, - storageMode: this.$$storageMode, - storageImpl: $$storage ? $$storage() : undefined, - disabled: !!this.$$disabled, - size: $$lruHeap && $$lruHeap.size() || 0 - }; - } - }, - keys: function keys() { - if ($$storage) { - var keysJson = $$storage().getItem(this.$$prefix + '.keys'); - - if (keysJson) { - return utils.fromJson(keysJson); - } else { - return []; - } - } else { - return _keys($$data); - } - }, - keySet: function keySet() { - if ($$storage) { - var keysJson = $$storage().getItem(this.$$prefix + '.keys'); - var kSet = {}; - - if (keysJson) { - var keys = utils.fromJson(keysJson); - - for (var i = 0; i < keys.length; i++) { - kSet[keys[i]] = keys[i]; - } - } - return kSet; - } else { - return _keySet($$data); - } - }, - put: function put(key, value, options) { - var _this3 = this; - - options || (options = {}); - - var storeOnResolve = 'storeOnResolve' in options ? !!options.storeOnResolve : this.$$storeOnResolve; - var storeOnReject = 'storeOnReject' in options ? !!options.storeOnReject : this.$$storeOnReject; - - var getHandler = function getHandler(store, isError) { - return function (v) { - if (store) { - delete $$promises[key]; - if (utils.isObject(v) && 'status' in v && 'data' in v) { - v = [v.status, v.data, v.headers(), v.statusText]; - _this3.put(key, v); - } else { - _this3.put(key, v); - } - } - if (isError) { - if (utils.Promise) { - return utils.Promise.reject(v); - } else { - throw v; - } - } else { - return v; - } - }; - }; - - if (this.$$disabled || !utils.isObject($$data) || value === null || value === undefined) { - return; - } - key = _stringifyNumber(key); - - if (!utils.isString(key)) { - throw new Error('key must be a string!'); - } - - var now = new Date().getTime(); - var item = { - key: key, - value: _isPromiseLike(value) ? value.then(getHandler(storeOnResolve, false), getHandler(storeOnReject, true)) : value, - created: options.created === undefined ? now : options.created, - accessed: options.accessed === undefined ? now : options.accessed - }; - if (options.maxAge) { - item.maxAge = options.maxAge; - } - - if (options.expires === undefined) { - item.expires = item.created + (item.maxAge || this.$$maxAge); - } else { - item.expires = options.expires; - } - - if ($$storage) { - if (_isPromiseLike(item.value)) { - $$promises[key] = item.value; - return $$promises[key]; - } - var keysJson = $$storage().getItem(this.$$prefix + '.keys'); - var keys = keysJson ? utils.fromJson(keysJson) : []; - var itemJson = $$storage().getItem(this.$$prefix + '.data.' + key); - - // Remove existing - if (itemJson) { - this.remove(key); - } - // Add to expires heap - $$expiresHeap.push({ - key: key, - expires: item.expires - }); - // Add to lru heap - $$lruHeap.push({ - key: key, - accessed: item.accessed - }); - // Set item - $$storage().setItem(this.$$prefix + '.data.' + key, JSON.stringify(item)); - var exists = false; - for (var i = 0; i < keys.length; i++) { - if (keys[i] === key) { - exists = true; - break; - } - } - if (!exists) { - keys.push(key); - } - $$storage().setItem(this.$$prefix + '.keys', JSON.stringify(keys)); - } else { - // Remove existing - if ($$data[key]) { - this.remove(key); - } - // Add to expires heap - $$expiresHeap.push(item); - // Add to lru heap - $$lruHeap.push(item); - // Set item - $$data[key] = item; - delete $$promises[key]; - } - - // Handle exceeded capacity - if ($$lruHeap.size() > this.$$capacity) { - this.remove($$lruHeap.peek().key); - } - - return value; - }, - remove: function remove(key) { - key += ''; - delete $$promises[key]; - if ($$storage) { - var itemJson = $$storage().getItem(this.$$prefix + '.data.' + key); - - if (itemJson) { - var item = utils.fromJson(itemJson); - $$lruHeap.remove({ - key: key, - accessed: item.accessed - }); - $$expiresHeap.remove({ - key: key, - expires: item.expires - }); - $$storage().removeItem(this.$$prefix + '.data.' + key); - var keysJson = $$storage().getItem(this.$$prefix + '.keys'); - var keys = keysJson ? utils.fromJson(keysJson) : []; - var index = keys.indexOf(key); - - if (index >= 0) { - keys.splice(index, 1); - } - $$storage().setItem(this.$$prefix + '.keys', JSON.stringify(keys)); - return item.value; - } - } else if (utils.isObject($$data)) { - var value = $$data[key] ? $$data[key].value : undefined; - $$lruHeap.remove($$data[key]); - $$expiresHeap.remove($$data[key]); - $$data[key] = null; - delete $$data[key]; - return value; - } - }, - removeAll: function removeAll() { - if ($$storage) { - $$lruHeap.removeAll(); - $$expiresHeap.removeAll(); - var keysJson = $$storage().getItem(this.$$prefix + '.keys'); - - if (keysJson) { - var keys = utils.fromJson(keysJson); - - for (var i = 0; i < keys.length; i++) { - this.remove(keys[i]); - } - } - $$storage().setItem(this.$$prefix + '.keys', JSON.stringify([])); - } else if (utils.isObject($$data)) { - $$lruHeap.removeAll(); - $$expiresHeap.removeAll(); - for (var key in $$data) { - $$data[key] = null; - } - $$data = {}; - } else { - $$lruHeap.removeAll(); - $$expiresHeap.removeAll(); - $$data = {}; - } - $$promises = {}; - }, - removeExpired: function removeExpired() { - var now = new Date().getTime(); - var expired = {}; - var key = undefined; - var expiredItem = undefined; - - while ((expiredItem = $$expiresHeap.peek()) && expiredItem.expires <= now) { - expired[expiredItem.key] = expiredItem.value ? expiredItem.value : null; - $$expiresHeap.pop(); - } - - if ($$storage) { - for (key in expired) { - var itemJson = $$storage().getItem(this.$$prefix + '.data.' + key); - if (itemJson) { - expired[key] = utils.fromJson(itemJson).value; - this.remove(key); - } - } - } else { - for (key in expired) { - this.remove(key); - } - } - - if (this.$$onExpire) { - for (key in expired) { - this.$$onExpire(key, expired[key]); - } - } - - return expired; - }, - setCacheFlushInterval: function setCacheFlushInterval(cacheFlushInterval) { - var _this = this; - if (cacheFlushInterval === null) { - delete _this.$$cacheFlushInterval; - } else if (!utils.isNumber(cacheFlushInterval)) { - throw new Error('cacheFlushInterval must be a number!'); - } else if (cacheFlushInterval < 0) { - throw new Error('cacheFlushInterval must be greater than zero!'); - } else if (cacheFlushInterval !== _this.$$cacheFlushInterval) { - _this.$$cacheFlushInterval = cacheFlushInterval; - - clearInterval(_this.$$cacheFlushIntervalId); // eslint-disable-line - - _this.$$cacheFlushIntervalId = setInterval(function () { - _this.removeAll(); - }, _this.$$cacheFlushInterval); - } - }, - setCapacity: function setCapacity(capacity) { - if (capacity === null) { - delete this.$$capacity; - } else if (!utils.isNumber(capacity)) { - throw new Error('capacity must be a number!'); - } else if (capacity < 0) { - throw new Error('capacity must be greater than zero!'); - } else { - this.$$capacity = capacity; - } - var removed = {}; - while ($$lruHeap.size() > this.$$capacity) { - removed[$$lruHeap.peek().key] = this.remove($$lruHeap.peek().key); - } - return removed; - }, - setDeleteOnExpire: function setDeleteOnExpire(deleteOnExpire, setRecycleFreq) { - if (deleteOnExpire === null) { - delete this.$$deleteOnExpire; - } else if (!utils.isString(deleteOnExpire)) { - throw new Error('deleteOnExpire must be a string!'); - } else if (deleteOnExpire !== 'none' && deleteOnExpire !== 'passive' && deleteOnExpire !== 'aggressive') { - throw new Error('deleteOnExpire must be "none", "passive" or "aggressive"!'); - } else { - this.$$deleteOnExpire = deleteOnExpire; - } - if (setRecycleFreq !== false) { - this.setRecycleFreq(this.$$recycleFreq); - } - }, - setMaxAge: function setMaxAge(maxAge) { - if (maxAge === null) { - this.$$maxAge = Number.MAX_VALUE; - } else if (!utils.isNumber(maxAge)) { - throw new Error('maxAge must be a number!'); - } else if (maxAge < 0) { - throw new Error('maxAge must be greater than zero!'); - } else { - this.$$maxAge = maxAge; - } - var i = undefined, - keys = undefined, - key = undefined; - - $$expiresHeap.removeAll(); - - if ($$storage) { - var keysJson = $$storage().getItem(this.$$prefix + '.keys'); - - keys = keysJson ? utils.fromJson(keysJson) : []; - - for (i = 0; i < keys.length; i++) { - key = keys[i]; - var itemJson = $$storage().getItem(this.$$prefix + '.data.' + key); - - if (itemJson) { - var item = utils.fromJson(itemJson); - if (this.$$maxAge === Number.MAX_VALUE) { - item.expires = Number.MAX_VALUE; - } else { - item.expires = item.created + (item.maxAge || this.$$maxAge); - } - $$expiresHeap.push({ - key: key, - expires: item.expires - }); - } - } - } else { - keys = _keys($$data); - - for (i = 0; i < keys.length; i++) { - key = keys[i]; - if (this.$$maxAge === Number.MAX_VALUE) { - $$data[key].expires = Number.MAX_VALUE; - } else { - $$data[key].expires = $$data[key].created + ($$data[key].maxAge || this.$$maxAge); - } - $$expiresHeap.push($$data[key]); - } - } - if (this.$$deleteOnExpire === 'aggressive') { - return this.removeExpired(); - } else { - return {}; - } - }, - setOnExpire: function setOnExpire(onExpire) { - if (onExpire === null) { - delete this.$$onExpire; - } else if (!utils.isFunction(onExpire)) { - throw new Error('onExpire must be a function!'); - } else { - this.$$onExpire = onExpire; - } - }, - setOptions: function setOptions(cacheOptions, strict) { - cacheOptions = cacheOptions || {}; - strict = !!strict; - if (!utils.isObject(cacheOptions)) { - throw new Error('cacheOptions must be an object!'); - } - - if ('storagePrefix' in cacheOptions) { - this.$$storagePrefix = cacheOptions.storagePrefix; - } else if (strict) { - this.$$storagePrefix = defaults.storagePrefix; - } - - this.$$prefix = this.$$storagePrefix + this.$$id; - - if ('disabled' in cacheOptions) { - this.$$disabled = !!cacheOptions.disabled; - } else if (strict) { - this.$$disabled = defaults.disabled; - } - - if ('deleteOnExpire' in cacheOptions) { - this.setDeleteOnExpire(cacheOptions.deleteOnExpire, false); - } else if (strict) { - this.setDeleteOnExpire(defaults.deleteOnExpire, false); - } - - if ('recycleFreq' in cacheOptions) { - this.setRecycleFreq(cacheOptions.recycleFreq); - } else if (strict) { - this.setRecycleFreq(defaults.recycleFreq); - } - - if ('maxAge' in cacheOptions) { - this.setMaxAge(cacheOptions.maxAge); - } else if (strict) { - this.setMaxAge(defaults.maxAge); - } - - if ('storeOnResolve' in cacheOptions) { - this.$$storeOnResolve = !!cacheOptions.storeOnResolve; - } else if (strict) { - this.$$storeOnResolve = defaults.storeOnResolve; - } - - if ('storeOnReject' in cacheOptions) { - this.$$storeOnReject = !!cacheOptions.storeOnReject; - } else if (strict) { - this.$$storeOnReject = defaults.storeOnReject; - } - - if ('capacity' in cacheOptions) { - this.setCapacity(cacheOptions.capacity); - } else if (strict) { - this.setCapacity(defaults.capacity); - } - - if ('cacheFlushInterval' in cacheOptions) { - this.setCacheFlushInterval(cacheOptions.cacheFlushInterval); - } else if (strict) { - this.setCacheFlushInterval(defaults.cacheFlushInterval); - } - - if ('onExpire' in cacheOptions) { - this.setOnExpire(cacheOptions.onExpire); - } else if (strict) { - this.setOnExpire(defaults.onExpire); - } - - if ('storageMode' in cacheOptions || 'storageImpl' in cacheOptions) { - this.setStorageMode(cacheOptions.storageMode || defaults.storageMode, cacheOptions.storageImpl || defaults.storageImpl); - } else if (strict) { - this.setStorageMode(defaults.storageMode, defaults.storageImpl); - } - }, - setRecycleFreq: function setRecycleFreq(recycleFreq) { - if (recycleFreq === null) { - delete this.$$recycleFreq; - } else if (!utils.isNumber(recycleFreq)) { - throw new Error('recycleFreq must be a number!'); - } else if (recycleFreq < 0) { - throw new Error('recycleFreq must be greater than zero!'); - } else { - this.$$recycleFreq = recycleFreq; - } - clearInterval(this.$$recycleFreqId); - if (this.$$deleteOnExpire === 'aggressive') { - (function (self) { - self.$$recycleFreqId = setInterval(function () { - self.removeExpired(); - }, self.$$recycleFreq); - })(this); - } else { - delete this.$$recycleFreqId; - } - }, - setStorageMode: function setStorageMode(storageMode, storageImpl) { - if (!utils.isString(storageMode)) { - throw new Error('storageMode must be a string!'); - } else if (storageMode !== 'memory' && storageMode !== 'localStorage' && storageMode !== 'sessionStorage') { - throw new Error('storageMode must be "memory", "localStorage" or "sessionStorage"!'); - } - - var prevStorage = $$storage; - var prevData = $$data; - var shouldReInsert = false; - var items = {}; - - function load(prevStorage, prevData) { - var keys = this.keys(); - var length = keys.length; - if (length) { - var _key = undefined; - var prevDataIsObject = utils.isObject(prevData); - for (var i = 0; i < length; i++) { - _key = keys[i]; - if (prevStorage) { - var itemJson = prevStorage().getItem(this.$$prefix + '.data.' + _key); - if (itemJson) { - items[_key] = utils.fromJson(itemJson); - } - } else if (prevDataIsObject) { - items[_key] = prevData[_key]; - } - this.remove(_key); - } - shouldReInsert = true; - } - } - - if (!this.$$initializing) { - load.call(this, prevStorage, prevData); - } - - this.$$storageMode = storageMode; - - if (storageImpl) { - if (!utils.isObject(storageImpl)) { - throw new Error('storageImpl must be an object!'); - } else if (!('setItem' in storageImpl) || typeof storageImpl.setItem !== 'function') { - throw new Error('storageImpl must implement "setItem(key, value)"!'); - } else if (!('getItem' in storageImpl) || typeof storageImpl.getItem !== 'function') { - throw new Error('storageImpl must implement "getItem(key)"!'); - } else if (!('removeItem' in storageImpl) || typeof storageImpl.removeItem !== 'function') { - throw new Error('storageImpl must implement "removeItem(key)"!'); - } - $$storage = function $$storage() { - return storageImpl; - }; - } else if (this.$$storageMode === 'localStorage') { - try { - localStorage.setItem('cachefactory', 'cachefactory'); - localStorage.removeItem('cachefactory'); - $$storage = function $$storage() { - return localStorage; - }; - } catch (e) { - $$storage = null; - this.$$storageMode = 'memory'; - } - } else if (this.$$storageMode === 'sessionStorage') { - try { - sessionStorage.setItem('cachefactory', 'cachefactory'); - sessionStorage.removeItem('cachefactory'); - $$storage = function $$storage() { - return sessionStorage; - }; - } catch (e) { - $$storage = null; - this.$$storageMode = 'memory'; - } - } else { - $$storage = null; - this.$$storageModel = 'memory'; - } - - if (this.$$initializing) { - load.call(this, $$storage, $$data); - } - - if (shouldReInsert) { - var item = undefined; - for (var key in items) { - item = items[key]; - this.put(key, item.value, { - created: item.created, - accessed: item.accessed, - expires: item.expires - }); - } - } - }, - touch: function touch(key) { - var _this4 = this; - - if (key) { - var val = this.get(key, { - onExpire: function onExpire(k, v) { - return _this4.put(k, v); - } - }); - if (val) { - this.put(key, val); - } - } else { - var keys = this.keys(); - for (var i = 0; i < keys.length; i++) { - this.touch(keys[i]); - } - } - }, - values: function values() { - var keys = this.keys(); - var items = []; - for (var i = 0; i < keys.length; i++) { - items.push(this.get(keys[i])); - } - return items; - } - }; - - cache.$$initializing = true; - cache.setOptions(options, true); - cache.$$initializing = false; - - return cache; - } - - function CacheFactory(cacheId, options) { - return createCache(cacheId, options); - } - - CacheFactory.createCache = createCache; - CacheFactory.defaults = defaults; - - CacheFactory.info = function () { - var keys = _keys(caches); - var info = { - size: keys.length, - caches: {} - }; - for (var opt in defaults) { - if (defaults.hasOwnProperty(opt)) { - info[opt] = defaults[opt]; - } - } - for (var i = 0; i < keys.length; i++) { - var key = keys[i]; - info.caches[key] = caches[key].info(); - } - return info; - }; - - CacheFactory.get = function (cacheId) { - return caches[cacheId]; - }; - CacheFactory.keySet = function () { - return _keySet(caches); - }; - CacheFactory.keys = function () { - return _keys(caches); - }; - CacheFactory.destroy = function (cacheId) { - if (caches[cacheId]) { - caches[cacheId].destroy(); - delete caches[cacheId]; - } - }; - CacheFactory.destroyAll = function () { - for (var cacheId in caches) { - caches[cacheId].destroy(); - } - caches = {}; - }; - CacheFactory.clearAll = function () { - for (var cacheId in caches) { - caches[cacheId].removeAll(); - } - }; - CacheFactory.removeExpiredFromAll = function () { - var expired = {}; - for (var cacheId in caches) { - expired[cacheId] = caches[cacheId].removeExpired(); - } - return expired; - }; - CacheFactory.enableAll = function () { - for (var cacheId in caches) { - caches[cacheId].$$disabled = false; - } - }; - CacheFactory.disableAll = function () { - for (var cacheId in caches) { - caches[cacheId].$$disabled = true; - } - }; - CacheFactory.touchAll = function () { - for (var cacheId in caches) { - caches[cacheId].touch(); - } - }; - - CacheFactory.utils = utils; - CacheFactory.BinaryHeap = BinaryHeap; - - module.exports = CacheFactory; - - /***/ }, - /* 1 */ - /***/ function(module, exports, __webpack_require__) { - - /*! - * yabh - * @version 1.1.0 - Homepage - * @author Jason Dobry - * @copyright (c) 2015 Jason Dobry - * @license MIT - * - * @overview Yet another Binary Heap. - */ - (function webpackUniversalModuleDefinition(root, factory) { - if(true) - module.exports = factory(); - else if(typeof define === 'function' && define.amd) - define("yabh", factory); - else if(typeof exports === 'object') - exports["BinaryHeap"] = factory(); - else - root["BinaryHeap"] = factory(); - })(this, function() { - return /******/ (function(modules) { // webpackBootstrap - /******/ // The module cache - /******/ var installedModules = {}; - - /******/ // The require function - /******/ function __webpack_require__(moduleId) { - - /******/ // Check if module is in cache - /******/ if(installedModules[moduleId]) - /******/ return installedModules[moduleId].exports; - - /******/ // Create a new module (and put it into the cache) - /******/ var module = installedModules[moduleId] = { - /******/ exports: {}, - /******/ id: moduleId, - /******/ loaded: false - /******/ }; - - /******/ // Execute the module function - /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__); - - /******/ // Flag the module as loaded - /******/ module.loaded = true; - - /******/ // Return the exports of the module - /******/ return module.exports; - /******/ } - - - /******/ // expose the modules object (__webpack_modules__) - /******/ __webpack_require__.m = modules; - - /******/ // expose the module cache - /******/ __webpack_require__.c = installedModules; - - /******/ // __webpack_public_path__ - /******/ __webpack_require__.p = ""; - - /******/ // Load entry module and return exports - /******/ return __webpack_require__(0); - /******/ }) - /************************************************************************/ - /******/ ([ - /* 0 */ - /***/ function(module, exports, __webpack_require__) { - - /** - * @method bubbleUp - * @param {array} heap The heap. - * @param {function} weightFunc The weight function. - * @param {number} n The index of the element to bubble up. - */ - function bubbleUp(heap, weightFunc, n) { - var element = heap[n]; - var weight = weightFunc(element); - // When at 0, an element can not go up any further. - while (n > 0) { - // Compute the parent element's index, and fetch it. - var parentN = Math.floor((n + 1) / 2) - 1; - var _parent = heap[parentN]; - // If the parent has a lesser weight, things are in order and we - // are done. - if (weight >= weightFunc(_parent)) { - break; - } else { - heap[parentN] = element; - heap[n] = _parent; - n = parentN; - } - } - } - - /** - * @method bubbleDown - * @param {array} heap The heap. - * @param {function} weightFunc The weight function. - * @param {number} n The index of the element to sink down. - */ - var bubbleDown = function bubbleDown(heap, weightFunc, n) { - var length = heap.length; - var node = heap[n]; - var nodeWeight = weightFunc(node); - - while (true) { - var child2N = (n + 1) * 2, - child1N = child2N - 1; - var swap = null; - if (child1N < length) { - var child1 = heap[child1N], - child1Weight = weightFunc(child1); - // If the score is less than our node's, we need to swap. - if (child1Weight < nodeWeight) { - swap = child1N; - } - } - // Do the same checks for the other child. - if (child2N < length) { - var child2 = heap[child2N], - child2Weight = weightFunc(child2); - if (child2Weight < (swap === null ? nodeWeight : weightFunc(heap[child1N]))) { - swap = child2N; - } - } - - if (swap === null) { - break; - } else { - heap[n] = heap[swap]; - heap[swap] = node; - n = swap; - } - } - }; - - function BinaryHeap(weightFunc, compareFunc) { - if (!weightFunc) { - weightFunc = function (x) { - return x; - }; - } - if (!compareFunc) { - compareFunc = function (x, y) { - return x === y; - }; - } - if (typeof weightFunc !== 'function') { - throw new Error('BinaryHeap([weightFunc][, compareFunc]): "weightFunc" must be a function!'); - } - if (typeof compareFunc !== 'function') { - throw new Error('BinaryHeap([weightFunc][, compareFunc]): "compareFunc" must be a function!'); - } - this.weightFunc = weightFunc; - this.compareFunc = compareFunc; - this.heap = []; - } - - var BHProto = BinaryHeap.prototype; - - BHProto.push = function (node) { - this.heap.push(node); - bubbleUp(this.heap, this.weightFunc, this.heap.length - 1); - }; - - BHProto.peek = function () { - return this.heap[0]; - }; - - BHProto.pop = function () { - var front = this.heap[0]; - var end = this.heap.pop(); - if (this.heap.length > 0) { - this.heap[0] = end; - bubbleDown(this.heap, this.weightFunc, 0); - } - return front; - }; - - BHProto.remove = function (node) { - var length = this.heap.length; - for (var i = 0; i < length; i++) { - if (this.compareFunc(this.heap[i], node)) { - var removed = this.heap[i]; - var end = this.heap.pop(); - if (i !== length - 1) { - this.heap[i] = end; - bubbleUp(this.heap, this.weightFunc, i); - bubbleDown(this.heap, this.weightFunc, i); - } - return removed; - } - } - return null; - }; - - BHProto.removeAll = function () { - this.heap = []; - }; - - BHProto.size = function () { - return this.heap.length; - }; - - module.exports = BinaryHeap; - - /***/ } - /******/ ]) - }); - ; - - /***/ } - /******/ ]) - }); - ; - //# sourceMappingURL=cachefactory.js.map - -/***/ } -/******/ ]) -}); -; +(function (global, factory) { + typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(typeof angular === 'undefined' ? require('angular') : angular) : + typeof define === 'function' && define.amd ? define('angular-cache', ['angular'], factory) : + (global.angularCacheModuleName = factory(global.angular)); +}(this, function (angular) { 'use strict'; + + angular = 'default' in angular ? angular['default'] : angular; + + var babelHelpers = {}; + babelHelpers.typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { + return typeof obj; + } : function (obj) { + return obj && typeof Symbol === "function" && obj.constructor === Symbol ? "symbol" : typeof obj; + }; + + /** + * @method bubbleUp + * @param {array} heap The heap. + * @param {function} weightFunc The weight function. + * @param {number} n The index of the element to bubble up. + */ + var bubbleUp = function bubbleUp(heap, weightFunc, n) { + var element = heap[n]; + var weight = weightFunc(element); + // When at 0, an element can not go up any further. + while (n > 0) { + // Compute the parent element's index, and fetch it. + var parentN = Math.floor((n + 1) / 2) - 1; + var parent = heap[parentN]; + // If the parent has a lesser weight, things are in order and we + // are done. + if (weight >= weightFunc(parent)) { + break; + } else { + heap[parentN] = element; + heap[n] = parent; + n = parentN; + } + } + }; + + /** + * @method bubbleDown + * @param {array} heap The heap. + * @param {function} weightFunc The weight function. + * @param {number} n The index of the element to sink down. + */ + var bubbleDown = function bubbleDown(heap, weightFunc, n) { + var length = heap.length; + var node = heap[n]; + var nodeWeight = weightFunc(node); + + while (true) { + var child2N = (n + 1) * 2; + var child1N = child2N - 1; + var swap = null; + if (child1N < length) { + var child1 = heap[child1N]; + var child1Weight = weightFunc(child1); + // If the score is less than our node's, we need to swap. + if (child1Weight < nodeWeight) { + swap = child1N; + } + } + // Do the same checks for the other child. + if (child2N < length) { + var child2 = heap[child2N]; + var child2Weight = weightFunc(child2); + if (child2Weight < (swap === null ? nodeWeight : weightFunc(heap[child1N]))) { + swap = child2N; + } + } + + if (swap === null) { + break; + } else { + heap[n] = heap[swap]; + heap[swap] = node; + n = swap; + } + } + }; + + function BinaryHeap(weightFunc, compareFunc) { + if (!weightFunc) { + weightFunc = function weightFunc(x) { + return x; + }; + } + if (!compareFunc) { + compareFunc = function compareFunc(x, y) { + return x === y; + }; + } + if (typeof weightFunc !== 'function') { + throw new Error('BinaryHeap([weightFunc][, compareFunc]): "weightFunc" must be a function!'); + } + if (typeof compareFunc !== 'function') { + throw new Error('BinaryHeap([weightFunc][, compareFunc]): "compareFunc" must be a function!'); + } + this.weightFunc = weightFunc; + this.compareFunc = compareFunc; + this.heap = []; + } + + var BHProto = BinaryHeap.prototype; + + BHProto.push = function (node) { + this.heap.push(node); + bubbleUp(this.heap, this.weightFunc, this.heap.length - 1); + }; + + BHProto.peek = function () { + return this.heap[0]; + }; + + BHProto.pop = function () { + var front = this.heap[0]; + var end = this.heap.pop(); + if (this.heap.length > 0) { + this.heap[0] = end; + bubbleDown(this.heap, this.weightFunc, 0); + } + return front; + }; + + BHProto.remove = function (node) { + var length = this.heap.length; + for (var i = 0; i < length; i++) { + if (this.compareFunc(this.heap[i], node)) { + var removed = this.heap[i]; + var end = this.heap.pop(); + if (i !== length - 1) { + this.heap[i] = end; + bubbleUp(this.heap, this.weightFunc, i); + bubbleDown(this.heap, this.weightFunc, i); + } + return removed; + } + } + return null; + }; + + BHProto.removeAll = function () { + this.heap = []; + }; + + BHProto.size = function () { + return this.heap.length; + }; + + var _Promise = null; + try { + _Promise = window.Promise; + } catch (e) {} + + var utils = { + isNumber: function isNumber(value) { + return typeof value === 'number'; + }, + isString: function isString(value) { + return typeof value === 'string'; + }, + isObject: function isObject(value) { + return value !== null && (typeof value === 'undefined' ? 'undefined' : babelHelpers.typeof(value)) === 'object'; + }, + isFunction: function isFunction(value) { + return typeof value === 'function'; + }, + fromJson: function fromJson(value) { + return JSON.parse(value); + }, + equals: function equals(a, b) { + return a === b; + }, + + Promise: _Promise + }; + + function _keys(collection) { + var keys = []; + var key = void 0; + if (!utils.isObject(collection)) { + return keys; + } + for (key in collection) { + if (collection.hasOwnProperty(key)) { + keys.push(key); + } + } + return keys; + } + + function _isPromiseLike(value) { + return value && typeof value.then === 'function'; + } + + function _stringifyNumber(number) { + if (utils.isNumber(number)) { + return number.toString(); + } + return number; + } + + function _keySet(collection) { + var keySet = {}; + var key = void 0; + if (!utils.isObject(collection)) { + return keySet; + } + for (key in collection) { + if (collection.hasOwnProperty(key)) { + keySet[key] = key; + } + } + return keySet; + } + + var defaults = { + capacity: Number.MAX_VALUE, + maxAge: Number.MAX_VALUE, + deleteOnExpire: 'none', + onExpire: null, + cacheFlushInterval: null, + recycleFreq: 1000, + storageMode: 'memory', + storageImpl: null, + disabled: false, + storagePrefix: 'cachefactory.caches.', + storeOnResolve: false, + storeOnReject: false + }; + + var caches = {}; + + function createCache(cacheId, options) { + if (cacheId in caches) { + throw new Error(cacheId + ' already exists!'); + } else if (!utils.isString(cacheId)) { + throw new Error('cacheId must be a string!'); + } + + var $$data = {}; + var $$promises = {}; + var $$storage = null; + var $$expiresHeap = new BinaryHeap(function (x) { + return x.expires; + }, utils.equals); + var $$lruHeap = new BinaryHeap(function (x) { + return x.accessed; + }, utils.equals); + + var cache = caches[cacheId] = { + + $$id: cacheId, + + destroy: function destroy() { + clearInterval(this.$$cacheFlushIntervalId); + clearInterval(this.$$recycleFreqId); + this.removeAll(); + if ($$storage) { + $$storage().removeItem(this.$$prefix + '.keys'); + $$storage().removeItem(this.$$prefix); + } + $$storage = null; + $$data = null; + $$lruHeap = null; + $$expiresHeap = null; + this.$$prefix = null; + delete caches[this.$$id]; + }, + disable: function disable() { + this.$$disabled = true; + }, + enable: function enable() { + delete this.$$disabled; + }, + get: function get(key, options) { + var _this2 = this; + + if (Array.isArray(key)) { + var _ret = function () { + var keys = key; + var values = []; + + keys.forEach(function (key) { + var value = _this2.get(key, options); + if (value !== null && value !== undefined) { + values.push(value); + } + }); + + return { + v: values + }; + }(); + + if ((typeof _ret === 'undefined' ? 'undefined' : babelHelpers.typeof(_ret)) === "object") return _ret.v; + } else { + key = _stringifyNumber(key); + + if (this.$$disabled) { + return; + } + } + + options = options || {}; + if (!utils.isString(key)) { + throw new Error('key must be a string!'); + } else if (options && !utils.isObject(options)) { + throw new Error('options must be an object!'); + } else if (options.onExpire && !utils.isFunction(options.onExpire)) { + throw new Error('options.onExpire must be a function!'); + } + + var item = void 0; + + if ($$storage) { + if ($$promises[key]) { + return $$promises[key]; + } + + var itemJson = $$storage().getItem(this.$$prefix + '.data.' + key); + + if (itemJson) { + item = utils.fromJson(itemJson); + } else { + return; + } + } else if (utils.isObject($$data)) { + if (!(key in $$data)) { + return; + } + + item = $$data[key]; + } + + var value = item.value; + var now = new Date().getTime(); + + if ($$storage) { + $$lruHeap.remove({ + key: key, + accessed: item.accessed + }); + item.accessed = now; + $$lruHeap.push({ + key: key, + accessed: now + }); + } else { + $$lruHeap.remove(item); + item.accessed = now; + $$lruHeap.push(item); + } + + if (this.$$deleteOnExpire === 'passive' && 'expires' in item && item.expires < now) { + this.remove(key); + + if (this.$$onExpire) { + this.$$onExpire(key, item.value, options.onExpire); + } else if (options.onExpire) { + options.onExpire.call(this, key, item.value); + } + value = undefined; + } else if ($$storage) { + $$storage().setItem(this.$$prefix + '.data.' + key, JSON.stringify(item)); + } + + return value; + }, + info: function info(key) { + if (key) { + var item = void 0; + if ($$storage) { + var itemJson = $$storage().getItem(this.$$prefix + '.data.' + key); + + if (itemJson) { + item = utils.fromJson(itemJson); + return { + created: item.created, + accessed: item.accessed, + expires: item.expires, + isExpired: new Date().getTime() - item.created > (item.maxAge || this.$$maxAge) + }; + } else { + return undefined; + } + } else if (utils.isObject($$data) && key in $$data) { + item = $$data[key]; + + return { + created: item.created, + accessed: item.accessed, + expires: item.expires, + isExpired: new Date().getTime() - item.created > (item.maxAge || this.$$maxAge) + }; + } else { + return undefined; + } + } else { + return { + id: this.$$id, + capacity: this.$$capacity, + maxAge: this.$$maxAge, + deleteOnExpire: this.$$deleteOnExpire, + onExpire: this.$$onExpire, + cacheFlushInterval: this.$$cacheFlushInterval, + recycleFreq: this.$$recycleFreq, + storageMode: this.$$storageMode, + storageImpl: $$storage ? $$storage() : undefined, + disabled: !!this.$$disabled, + size: $$lruHeap && $$lruHeap.size() || 0 + }; + } + }, + keys: function keys() { + if ($$storage) { + var keysJson = $$storage().getItem(this.$$prefix + '.keys'); + + if (keysJson) { + return utils.fromJson(keysJson); + } else { + return []; + } + } else { + return _keys($$data); + } + }, + keySet: function keySet() { + if ($$storage) { + var keysJson = $$storage().getItem(this.$$prefix + '.keys'); + var kSet = {}; + + if (keysJson) { + var keys = utils.fromJson(keysJson); + + for (var i = 0; i < keys.length; i++) { + kSet[keys[i]] = keys[i]; + } + } + return kSet; + } else { + return _keySet($$data); + } + }, + put: function put(key, value, options) { + var _this3 = this; + + options || (options = {}); + + var storeOnResolve = 'storeOnResolve' in options ? !!options.storeOnResolve : this.$$storeOnResolve; + var storeOnReject = 'storeOnReject' in options ? !!options.storeOnReject : this.$$storeOnReject; + + var getHandler = function getHandler(store, isError) { + return function (v) { + if (store) { + delete $$promises[key]; + if (utils.isObject(v) && 'status' in v && 'data' in v) { + v = [v.status, v.data, v.headers(), v.statusText]; + _this3.put(key, v); + } else { + _this3.put(key, v); + } + } + if (isError) { + if (utils.Promise) { + return utils.Promise.reject(v); + } else { + throw v; + } + } else { + return v; + } + }; + }; + + if (this.$$disabled || !utils.isObject($$data) || value === null || value === undefined) { + return; + } + key = _stringifyNumber(key); + + if (!utils.isString(key)) { + throw new Error('key must be a string!'); + } + + var now = new Date().getTime(); + var item = { + key: key, + value: _isPromiseLike(value) ? value.then(getHandler(storeOnResolve, false), getHandler(storeOnReject, true)) : value, + created: options.created === undefined ? now : options.created, + accessed: options.accessed === undefined ? now : options.accessed + }; + if (options.maxAge) { + item.maxAge = options.maxAge; + } + + if (options.expires === undefined) { + item.expires = item.created + (item.maxAge || this.$$maxAge); + } else { + item.expires = options.expires; + } + + if ($$storage) { + if (_isPromiseLike(item.value)) { + $$promises[key] = item.value; + return $$promises[key]; + } + var keysJson = $$storage().getItem(this.$$prefix + '.keys'); + var keys = keysJson ? utils.fromJson(keysJson) : []; + var itemJson = $$storage().getItem(this.$$prefix + '.data.' + key); + + // Remove existing + if (itemJson) { + this.remove(key); + } + // Add to expires heap + $$expiresHeap.push({ + key: key, + expires: item.expires + }); + // Add to lru heap + $$lruHeap.push({ + key: key, + accessed: item.accessed + }); + // Set item + $$storage().setItem(this.$$prefix + '.data.' + key, JSON.stringify(item)); + var exists = false; + for (var i = 0; i < keys.length; i++) { + if (keys[i] === key) { + exists = true; + break; + } + } + if (!exists) { + keys.push(key); + } + $$storage().setItem(this.$$prefix + '.keys', JSON.stringify(keys)); + } else { + // Remove existing + if ($$data[key]) { + this.remove(key); + } + // Add to expires heap + $$expiresHeap.push(item); + // Add to lru heap + $$lruHeap.push(item); + // Set item + $$data[key] = item; + delete $$promises[key]; + } + + // Handle exceeded capacity + if ($$lruHeap.size() > this.$$capacity) { + this.remove($$lruHeap.peek().key); + } + + return value; + }, + remove: function remove(key) { + key += ''; + delete $$promises[key]; + if ($$storage) { + var itemJson = $$storage().getItem(this.$$prefix + '.data.' + key); + + if (itemJson) { + var item = utils.fromJson(itemJson); + $$lruHeap.remove({ + key: key, + accessed: item.accessed + }); + $$expiresHeap.remove({ + key: key, + expires: item.expires + }); + $$storage().removeItem(this.$$prefix + '.data.' + key); + var keysJson = $$storage().getItem(this.$$prefix + '.keys'); + var keys = keysJson ? utils.fromJson(keysJson) : []; + var index = keys.indexOf(key); + + if (index >= 0) { + keys.splice(index, 1); + } + $$storage().setItem(this.$$prefix + '.keys', JSON.stringify(keys)); + return item.value; + } + } else if (utils.isObject($$data)) { + var value = $$data[key] ? $$data[key].value : undefined; + $$lruHeap.remove($$data[key]); + $$expiresHeap.remove($$data[key]); + $$data[key] = null; + delete $$data[key]; + return value; + } + }, + removeAll: function removeAll() { + if ($$storage) { + $$lruHeap.removeAll(); + $$expiresHeap.removeAll(); + var keysJson = $$storage().getItem(this.$$prefix + '.keys'); + + if (keysJson) { + var keys = utils.fromJson(keysJson); + + for (var i = 0; i < keys.length; i++) { + this.remove(keys[i]); + } + } + $$storage().setItem(this.$$prefix + '.keys', JSON.stringify([])); + } else if (utils.isObject($$data)) { + $$lruHeap.removeAll(); + $$expiresHeap.removeAll(); + for (var key in $$data) { + $$data[key] = null; + } + $$data = {}; + } else { + $$lruHeap.removeAll(); + $$expiresHeap.removeAll(); + $$data = {}; + } + $$promises = {}; + }, + removeExpired: function removeExpired() { + var now = new Date().getTime(); + var expired = {}; + var key = void 0; + var expiredItem = void 0; + + while ((expiredItem = $$expiresHeap.peek()) && expiredItem.expires <= now) { + expired[expiredItem.key] = expiredItem.value ? expiredItem.value : null; + $$expiresHeap.pop(); + } + + if ($$storage) { + for (key in expired) { + var itemJson = $$storage().getItem(this.$$prefix + '.data.' + key); + if (itemJson) { + expired[key] = utils.fromJson(itemJson).value; + this.remove(key); + } + } + } else { + for (key in expired) { + this.remove(key); + } + } + + if (this.$$onExpire) { + for (key in expired) { + this.$$onExpire(key, expired[key]); + } + } + + return expired; + }, + setCacheFlushInterval: function setCacheFlushInterval(cacheFlushInterval) { + var _this = this; + if (cacheFlushInterval === null) { + delete _this.$$cacheFlushInterval; + } else if (!utils.isNumber(cacheFlushInterval)) { + throw new Error('cacheFlushInterval must be a number!'); + } else if (cacheFlushInterval < 0) { + throw new Error('cacheFlushInterval must be greater than zero!'); + } else if (cacheFlushInterval !== _this.$$cacheFlushInterval) { + _this.$$cacheFlushInterval = cacheFlushInterval; + + clearInterval(_this.$$cacheFlushIntervalId); // eslint-disable-line + + _this.$$cacheFlushIntervalId = setInterval(function () { + _this.removeAll(); + }, _this.$$cacheFlushInterval); + } + }, + setCapacity: function setCapacity(capacity) { + if (capacity === null) { + delete this.$$capacity; + } else if (!utils.isNumber(capacity)) { + throw new Error('capacity must be a number!'); + } else if (capacity < 0) { + throw new Error('capacity must be greater than zero!'); + } else { + this.$$capacity = capacity; + } + var removed = {}; + while ($$lruHeap.size() > this.$$capacity) { + removed[$$lruHeap.peek().key] = this.remove($$lruHeap.peek().key); + } + return removed; + }, + setDeleteOnExpire: function setDeleteOnExpire(deleteOnExpire, setRecycleFreq) { + if (deleteOnExpire === null) { + delete this.$$deleteOnExpire; + } else if (!utils.isString(deleteOnExpire)) { + throw new Error('deleteOnExpire must be a string!'); + } else if (deleteOnExpire !== 'none' && deleteOnExpire !== 'passive' && deleteOnExpire !== 'aggressive') { + throw new Error('deleteOnExpire must be "none", "passive" or "aggressive"!'); + } else { + this.$$deleteOnExpire = deleteOnExpire; + } + if (setRecycleFreq !== false) { + this.setRecycleFreq(this.$$recycleFreq); + } + }, + setMaxAge: function setMaxAge(maxAge) { + if (maxAge === null) { + this.$$maxAge = Number.MAX_VALUE; + } else if (!utils.isNumber(maxAge)) { + throw new Error('maxAge must be a number!'); + } else if (maxAge < 0) { + throw new Error('maxAge must be greater than zero!'); + } else { + this.$$maxAge = maxAge; + } + var i = void 0, + keys = void 0, + key = void 0; + + $$expiresHeap.removeAll(); + + if ($$storage) { + var keysJson = $$storage().getItem(this.$$prefix + '.keys'); + + keys = keysJson ? utils.fromJson(keysJson) : []; + + for (i = 0; i < keys.length; i++) { + key = keys[i]; + var itemJson = $$storage().getItem(this.$$prefix + '.data.' + key); + + if (itemJson) { + var item = utils.fromJson(itemJson); + if (this.$$maxAge === Number.MAX_VALUE) { + item.expires = Number.MAX_VALUE; + } else { + item.expires = item.created + (item.maxAge || this.$$maxAge); + } + $$expiresHeap.push({ + key: key, + expires: item.expires + }); + } + } + } else { + keys = _keys($$data); + + for (i = 0; i < keys.length; i++) { + key = keys[i]; + if (this.$$maxAge === Number.MAX_VALUE) { + $$data[key].expires = Number.MAX_VALUE; + } else { + $$data[key].expires = $$data[key].created + ($$data[key].maxAge || this.$$maxAge); + } + $$expiresHeap.push($$data[key]); + } + } + if (this.$$deleteOnExpire === 'aggressive') { + return this.removeExpired(); + } else { + return {}; + } + }, + setOnExpire: function setOnExpire(onExpire) { + if (onExpire === null) { + delete this.$$onExpire; + } else if (!utils.isFunction(onExpire)) { + throw new Error('onExpire must be a function!'); + } else { + this.$$onExpire = onExpire; + } + }, + setOptions: function setOptions(cacheOptions, strict) { + cacheOptions = cacheOptions || {}; + strict = !!strict; + if (!utils.isObject(cacheOptions)) { + throw new Error('cacheOptions must be an object!'); + } + + if ('storagePrefix' in cacheOptions) { + this.$$storagePrefix = cacheOptions.storagePrefix; + } else if (strict) { + this.$$storagePrefix = defaults.storagePrefix; + } + + this.$$prefix = this.$$storagePrefix + this.$$id; + + if ('disabled' in cacheOptions) { + this.$$disabled = !!cacheOptions.disabled; + } else if (strict) { + this.$$disabled = defaults.disabled; + } + + if ('deleteOnExpire' in cacheOptions) { + this.setDeleteOnExpire(cacheOptions.deleteOnExpire, false); + } else if (strict) { + this.setDeleteOnExpire(defaults.deleteOnExpire, false); + } + + if ('recycleFreq' in cacheOptions) { + this.setRecycleFreq(cacheOptions.recycleFreq); + } else if (strict) { + this.setRecycleFreq(defaults.recycleFreq); + } + + if ('maxAge' in cacheOptions) { + this.setMaxAge(cacheOptions.maxAge); + } else if (strict) { + this.setMaxAge(defaults.maxAge); + } + + if ('storeOnResolve' in cacheOptions) { + this.$$storeOnResolve = !!cacheOptions.storeOnResolve; + } else if (strict) { + this.$$storeOnResolve = defaults.storeOnResolve; + } + + if ('storeOnReject' in cacheOptions) { + this.$$storeOnReject = !!cacheOptions.storeOnReject; + } else if (strict) { + this.$$storeOnReject = defaults.storeOnReject; + } + + if ('capacity' in cacheOptions) { + this.setCapacity(cacheOptions.capacity); + } else if (strict) { + this.setCapacity(defaults.capacity); + } + + if ('cacheFlushInterval' in cacheOptions) { + this.setCacheFlushInterval(cacheOptions.cacheFlushInterval); + } else if (strict) { + this.setCacheFlushInterval(defaults.cacheFlushInterval); + } + + if ('onExpire' in cacheOptions) { + this.setOnExpire(cacheOptions.onExpire); + } else if (strict) { + this.setOnExpire(defaults.onExpire); + } + + if ('storageMode' in cacheOptions || 'storageImpl' in cacheOptions) { + this.setStorageMode(cacheOptions.storageMode || defaults.storageMode, cacheOptions.storageImpl || defaults.storageImpl); + } else if (strict) { + this.setStorageMode(defaults.storageMode, defaults.storageImpl); + } + }, + setRecycleFreq: function setRecycleFreq(recycleFreq) { + if (recycleFreq === null) { + delete this.$$recycleFreq; + } else if (!utils.isNumber(recycleFreq)) { + throw new Error('recycleFreq must be a number!'); + } else if (recycleFreq < 0) { + throw new Error('recycleFreq must be greater than zero!'); + } else { + this.$$recycleFreq = recycleFreq; + } + clearInterval(this.$$recycleFreqId); + if (this.$$deleteOnExpire === 'aggressive') { + (function (self) { + self.$$recycleFreqId = setInterval(function () { + self.removeExpired(); + }, self.$$recycleFreq); + })(this); + } else { + delete this.$$recycleFreqId; + } + }, + setStorageMode: function setStorageMode(storageMode, storageImpl) { + if (!utils.isString(storageMode)) { + throw new Error('storageMode must be a string!'); + } else if (storageMode !== 'memory' && storageMode !== 'localStorage' && storageMode !== 'sessionStorage') { + throw new Error('storageMode must be "memory", "localStorage" or "sessionStorage"!'); + } + + var prevStorage = $$storage; + var prevData = $$data; + var shouldReInsert = false; + var items = {}; + + function load(prevStorage, prevData) { + var keys = this.keys(); + var length = keys.length; + if (length) { + var _key = void 0; + var prevDataIsObject = utils.isObject(prevData); + for (var i = 0; i < length; i++) { + _key = keys[i]; + if (prevStorage) { + var itemJson = prevStorage().getItem(this.$$prefix + '.data.' + _key); + if (itemJson) { + items[_key] = utils.fromJson(itemJson); + } + } else if (prevDataIsObject) { + items[_key] = prevData[_key]; + } + this.remove(_key); + } + shouldReInsert = true; + } + } + + if (!this.$$initializing) { + load.call(this, prevStorage, prevData); + } + + this.$$storageMode = storageMode; + + if (storageImpl) { + if (!utils.isObject(storageImpl)) { + throw new Error('storageImpl must be an object!'); + } else if (!('setItem' in storageImpl) || typeof storageImpl.setItem !== 'function') { + throw new Error('storageImpl must implement "setItem(key, value)"!'); + } else if (!('getItem' in storageImpl) || typeof storageImpl.getItem !== 'function') { + throw new Error('storageImpl must implement "getItem(key)"!'); + } else if (!('removeItem' in storageImpl) || typeof storageImpl.removeItem !== 'function') { + throw new Error('storageImpl must implement "removeItem(key)"!'); + } + $$storage = function $$storage() { + return storageImpl; + }; + } else if (this.$$storageMode === 'localStorage') { + try { + localStorage.setItem('cachefactory', 'cachefactory'); + localStorage.removeItem('cachefactory'); + $$storage = function $$storage() { + return localStorage; + }; + } catch (e) { + $$storage = null; + this.$$storageMode = 'memory'; + } + } else if (this.$$storageMode === 'sessionStorage') { + try { + sessionStorage.setItem('cachefactory', 'cachefactory'); + sessionStorage.removeItem('cachefactory'); + $$storage = function $$storage() { + return sessionStorage; + }; + } catch (e) { + $$storage = null; + this.$$storageMode = 'memory'; + } + } else { + $$storage = null; + this.$$storageMode = 'memory'; + } + + if (this.$$initializing) { + load.call(this, $$storage, $$data); + } + + if (shouldReInsert) { + var item = void 0; + for (var key in items) { + item = items[key]; + this.put(key, item.value, { + created: item.created, + accessed: item.accessed, + expires: item.expires + }); + } + } + }, + touch: function touch(key, options) { + var _this4 = this; + + if (key) { + var val = this.get(key, { + onExpire: function onExpire(k, v) { + return _this4.put(k, v); + } + }); + if (val) { + this.put(key, val, options); + } + } else { + var keys = this.keys(); + for (var i = 0; i < keys.length; i++) { + this.touch(keys[i], options); + } + } + }, + values: function values() { + var keys = this.keys(); + var items = []; + for (var i = 0; i < keys.length; i++) { + items.push(this.get(keys[i])); + } + return items; + } + }; + + cache.$$initializing = true; + cache.setOptions(options, true); + cache.$$initializing = false; + + return cache; + } + + function CacheFactory(cacheId, options) { + return createCache(cacheId, options); + } + + CacheFactory.createCache = createCache; + CacheFactory.defaults = defaults; + + CacheFactory.info = function () { + var keys = _keys(caches); + var info = { + size: keys.length, + caches: {} + }; + for (var opt in defaults) { + if (defaults.hasOwnProperty(opt)) { + info[opt] = defaults[opt]; + } + } + for (var i = 0; i < keys.length; i++) { + var key = keys[i]; + info.caches[key] = caches[key].info(); + } + return info; + }; + + CacheFactory.get = function (cacheId) { + return caches[cacheId]; + }; + CacheFactory.keySet = function () { + return _keySet(caches); + }; + CacheFactory.keys = function () { + return _keys(caches); + }; + CacheFactory.destroy = function (cacheId) { + if (caches[cacheId]) { + caches[cacheId].destroy(); + delete caches[cacheId]; + } + }; + CacheFactory.destroyAll = function () { + for (var cacheId in caches) { + caches[cacheId].destroy(); + } + caches = {}; + }; + CacheFactory.clearAll = function () { + for (var cacheId in caches) { + caches[cacheId].removeAll(); + } + }; + CacheFactory.removeExpiredFromAll = function () { + var expired = {}; + for (var cacheId in caches) { + expired[cacheId] = caches[cacheId].removeExpired(); + } + return expired; + }; + CacheFactory.enableAll = function () { + for (var cacheId in caches) { + caches[cacheId].$$disabled = false; + } + }; + CacheFactory.disableAll = function () { + for (var cacheId in caches) { + caches[cacheId].$$disabled = true; + } + }; + CacheFactory.touchAll = function () { + for (var cacheId in caches) { + caches[cacheId].touch(); + } + }; + + CacheFactory.utils = utils; + CacheFactory.BinaryHeap = BinaryHeap; + + CacheFactory.utils.equals = angular.equals; + CacheFactory.utils.isObject = angular.isObject; + CacheFactory.utils.fromJson = angular.fromJson; + + function BinaryHeapProvider() { + this.$get = function () { + return CacheFactory.BinaryHeap; + }; + } + + function CacheFactoryProvider() { + this.defaults = CacheFactory.defaults; + this.defaults.storagePrefix = 'angular-cache.caches.'; + + this.$get = ['$q', function ($q) { + CacheFactory.utils.Promise = $q; + return CacheFactory; + }]; + } + + angular.module('angular-cache', []).provider('BinaryHeap', BinaryHeapProvider).provider('CacheFactory', CacheFactoryProvider); + + var index = 'angular-cache'; + + return index; + +})); //# sourceMappingURL=angular-cache.js.map \ No newline at end of file diff --git a/dist/angular-cache.js.map b/dist/angular-cache.js.map index 0f1ed06..ca27a6f 100644 --- a/dist/angular-cache.js.map +++ b/dist/angular-cache.js.map @@ -1 +1 @@ -{"version":3,"sources":["webpack:///webpack/universalModuleDefinition","webpack:///webpack/bootstrap 8a05c295a6019ef8c7eb","webpack:///./src/index.js","webpack:///external \"angular\"","webpack:///../CacheFactory/dist/cachefactory.js"],"names":[],"mappings":";;;;;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,CAAC;AACD,O;ACVA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA,uBAAe;AACf;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;;AAGA;AACA;;AAEA;A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;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,WAAU;AACV;AACA;AACA;AACA;;AAEA;;AAEA,sGAAqG,mBAAmB,EAAE,mBAAmB,kGAAkG;;AAE/O;AACA;AACA;AACA;AACA,GAAE;;AAEF;AACA;AACA;AACA,KAAI;AACJ;AACA;AACA,KAAI;AACJ;AACA;AACA,KAAI;AACJ;AACA;AACA,KAAI;AACJ;AACA;AACA,KAAI;AACJ;AACA;AACA,KAAI;;AAEJ;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA,KAAI;AACJ;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,KAAI;AACJ;AACA;AACA,KAAI;;AAEJ;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAM;AACN;AACA;AACA,OAAM;AACN;AACA;AACA,OAAM;AACN;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,aAAY;;AAEZ;AACA;AACA;AACA,WAAU;;AAEV;AACA,SAAQ;AACR;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,SAAQ;AACR;AACA,SAAQ;AACR;AACA;;AAEA;;AAEA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA,WAAU;AACV;AACA;AACA,SAAQ;AACR;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA,WAAU;AACV;AACA;AACA;AACA;AACA,WAAU;AACV,SAAQ;AACR;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA,WAAU;AACV;AACA;AACA;AACA,SAAQ;AACR;AACA;;AAEA;AACA,OAAM;AACN;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,aAAY;AACZ;AACA;AACA,WAAU;AACV;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,WAAU;AACV;AACA;AACA,SAAQ;AACR;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAM;AACN;AACA;AACA;;AAEA;AACA;AACA,WAAU;AACV;AACA;AACA,SAAQ;AACR;AACA;AACA,OAAM;AACN;AACA;AACA;AACA;;AAEA;AACA;;AAEA,2BAA0B,iBAAiB;AAC3C;AACA;AACA;AACA;AACA,SAAQ;AACR;AACA;AACA,OAAM;AACN;AACA;;AAEA,gCAA+B;;AAE/B;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAc;AACd;AACA;AACA;AACA;AACA;AACA;AACA,eAAc;AACd;AACA;AACA,aAAY;AACZ;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,SAAQ;AACR;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,WAAU;AACV;AACA;AACA;AACA;AACA,WAAU;AACV;AACA;AACA;AACA,yBAAwB,iBAAiB;AACzC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAQ;AACR;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA,OAAM;AACN;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,aAAY;AACZ;AACA;AACA;AACA,aAAY;AACZ;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,SAAQ;AACR;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAM;AACN;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA,2BAA0B,iBAAiB;AAC3C;AACA;AACA;AACA;AACA,SAAQ;AACR;AACA;AACA;AACA;AACA;AACA;AACA,SAAQ;AACR;AACA;AACA;AACA;AACA;AACA,OAAM;AACN;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAQ;AACR;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA,OAAM;AACN;AACA;AACA;AACA;AACA,SAAQ;AACR;AACA,SAAQ;AACR;AACA,SAAQ;AACR;;AAEA,sDAAqD;;AAErD;AACA;AACA,WAAU;AACV;AACA,OAAM;AACN;AACA;AACA;AACA,SAAQ;AACR;AACA,SAAQ;AACR;AACA,SAAQ;AACR;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAM;AACN;AACA;AACA;AACA,SAAQ;AACR;AACA,SAAQ;AACR;AACA,SAAQ;AACR;AACA;AACA;AACA;AACA;AACA,OAAM;AACN;AACA;AACA;AACA,SAAQ;AACR;AACA,SAAQ;AACR;AACA,SAAQ;AACR;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;;AAEA;;AAEA,qBAAoB,iBAAiB;AACrC;AACA;;AAEA;AACA;AACA;AACA;AACA,eAAc;AACd;AACA;AACA;AACA;AACA;AACA,eAAc;AACd;AACA;AACA,SAAQ;AACR;;AAEA,qBAAoB,iBAAiB;AACrC;AACA;AACA;AACA,aAAY;AACZ;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAQ;AACR;AACA;AACA,OAAM;AACN;AACA;AACA;AACA,SAAQ;AACR;AACA,SAAQ;AACR;AACA;AACA,OAAM;AACN;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,SAAQ;AACR;AACA;;AAEA;;AAEA;AACA;AACA,SAAQ;AACR;AACA;;AAEA;AACA;AACA,SAAQ;AACR;AACA;;AAEA;AACA;AACA,SAAQ;AACR;AACA;;AAEA;AACA;AACA,SAAQ;AACR;AACA;;AAEA;AACA;AACA,SAAQ;AACR;AACA;;AAEA;AACA;AACA,SAAQ;AACR;AACA;;AAEA;AACA;AACA,SAAQ;AACR;AACA;;AAEA;AACA;AACA,SAAQ;AACR;AACA;;AAEA;AACA;AACA,SAAQ;AACR;AACA;;AAEA;AACA;AACA,SAAQ;AACR;AACA;AACA,OAAM;AACN;AACA;AACA;AACA,SAAQ;AACR;AACA,SAAQ;AACR;AACA,SAAQ;AACR;AACA;AACA;AACA;AACA;AACA;AACA;AACA,aAAY;AACZ,WAAU;AACV,SAAQ;AACR;AACA;AACA,OAAM;AACN;AACA;AACA;AACA,SAAQ;AACR;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,2BAA0B,YAAY;AACtC;AACA;AACA;AACA;AACA;AACA;AACA,eAAc;AACd;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA,WAAU;AACV;AACA,WAAU;AACV;AACA,WAAU;AACV;AACA;AACA;AACA;AACA;AACA,SAAQ;AACR;AACA;AACA;AACA;AACA;AACA;AACA,WAAU;AACV;AACA;AACA;AACA,SAAQ;AACR;AACA;AACA;AACA;AACA;AACA;AACA,WAAU;AACV;AACA;AACA;AACA,SAAQ;AACR;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,aAAY;AACZ;AACA;AACA,OAAM;AACN;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,WAAU;AACV;AACA;AACA;AACA,SAAQ;AACR;AACA,yBAAwB,iBAAiB;AACzC;AACA;AACA;AACA,OAAM;AACN;AACA;AACA;AACA,uBAAsB,iBAAiB;AACvC;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,mBAAkB,iBAAiB;AACnC;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;;AAEA,QAAO;AACP;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GAAE;AACF,sCAAqC;AACrC;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA,yBAAwB;AACxB;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;;AAGA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA,YAAW;AACX;AACA;AACA;AACA;;AAEA;AACA;AACA,cAAa,MAAM;AACnB,cAAa,SAAS;AACtB,cAAa,OAAO;AACpB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,QAAO;AACP;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,cAAa,MAAM;AACnB,cAAa,SAAS;AACtB,cAAa,OAAO;AACpB;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,QAAO;AACP;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,oBAAmB,YAAY;AAC/B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;;AAEA;AACA;AACA,GAAE;AACF;;AAEA;AACA;AACA,EAAC;AACD;AACA,yC","file":"./dist/angular-cache.js","sourcesContent":["(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory(require(\"angular\"));\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine(\"angular-cache\", [\"angular\"], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"angularCacheModuleName\"] = factory(require(\"angular\"));\n\telse\n\t\troot[\"angularCacheModuleName\"] = factory(root[\"angular\"]);\n})(this, function(__WEBPACK_EXTERNAL_MODULE_1__) {\nreturn \n\n\n/** WEBPACK FOOTER **\n ** webpack/universalModuleDefinition\n **/"," \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId])\n \t\t\treturn installedModules[moduleId].exports;\n\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\texports: {},\n \t\t\tid: moduleId,\n \t\t\tloaded: false\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.loaded = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(0);\n\n\n\n/** WEBPACK FOOTER **\n ** webpack/bootstrap 8a05c295a6019ef8c7eb\n **/","const angular = require('angular')\nconst CacheFactory = require('cachefactory')\n\nCacheFactory.utils.equals = angular.equals\nCacheFactory.utils.isObject = angular.isObject\nCacheFactory.utils.fromJson = angular.fromJson\n\nfunction BinaryHeapProvider () {\n this.$get = function () { return CacheFactory.BinaryHeap }\n}\n\nfunction CacheFactoryProvider () {\n this.defaults = CacheFactory.defaults\n this.defaults.storagePrefix = 'angular-cache.caches.'\n\n this.$get = ['$q', function ($q) {\n CacheFactory.utils.Promise = $q\n return CacheFactory\n }]\n}\n\nangular.module('angular-cache', [])\n .provider('BinaryHeap', BinaryHeapProvider)\n .provider('CacheFactory', CacheFactoryProvider)\n\nmodule.exports = 'angular-cache'\ntry {\n module.exports.name = 'angular-cache'\n} catch (err) {\n\n}\n\n\n\n\n/** WEBPACK FOOTER **\n ** ./src/index.js\n **/","module.exports = __WEBPACK_EXTERNAL_MODULE_1__;\n\n\n/*****************\n ** WEBPACK FOOTER\n ** external \"angular\"\n ** module id = 1\n ** module chunks = 0\n **/","/*!\n * cachefactory\n * @version 1.4.0 - Homepage \n * @author Jason Dobry \n * @copyright (c) 2013-2016 Jason Dobry \n * @license MIT \n * \n * @overview CacheFactory is a very simple and useful cache for the browser.\n */\n(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory();\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine(\"cachefactory\", [], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"CacheFactory\"] = factory();\n\telse\n\t\troot[\"CacheFactory\"] = factory();\n})(this, function() {\nreturn /******/ (function(modules) { // webpackBootstrap\n/******/ \t// The module cache\n/******/ \tvar installedModules = {};\n/******/\n/******/ \t// The require function\n/******/ \tfunction __webpack_require__(moduleId) {\n/******/\n/******/ \t\t// Check if module is in cache\n/******/ \t\tif(installedModules[moduleId])\n/******/ \t\t\treturn installedModules[moduleId].exports;\n/******/\n/******/ \t\t// Create a new module (and put it into the cache)\n/******/ \t\tvar module = installedModules[moduleId] = {\n/******/ \t\t\texports: {},\n/******/ \t\t\tid: moduleId,\n/******/ \t\t\tloaded: false\n/******/ \t\t};\n/******/\n/******/ \t\t// Execute the module function\n/******/ \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n/******/\n/******/ \t\t// Flag the module as loaded\n/******/ \t\tmodule.loaded = true;\n/******/\n/******/ \t\t// Return the exports of the module\n/******/ \t\treturn module.exports;\n/******/ \t}\n/******/\n/******/\n/******/ \t// expose the modules object (__webpack_modules__)\n/******/ \t__webpack_require__.m = modules;\n/******/\n/******/ \t// expose the module cache\n/******/ \t__webpack_require__.c = installedModules;\n/******/\n/******/ \t// __webpack_public_path__\n/******/ \t__webpack_require__.p = \"\";\n/******/\n/******/ \t// Load entry module and return exports\n/******/ \treturn __webpack_require__(0);\n/******/ })\n/************************************************************************/\n/******/ ([\n/* 0 */\n/***/ function(module, exports, __webpack_require__) {\n\n\t'use strict';\n\t\n\tvar _typeof = typeof Symbol === \"function\" && typeof Symbol.iterator === \"symbol\" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === \"function\" && obj.constructor === Symbol ? \"symbol\" : typeof obj; };\n\t\n\tvar BinaryHeap = __webpack_require__(1);\n\tvar _Promise = null;\n\ttry {\n\t _Promise = window.Promise;\n\t} catch (e) {}\n\t\n\tvar utils = {\n\t isNumber: function isNumber(value) {\n\t return typeof value === 'number';\n\t },\n\t isString: function isString(value) {\n\t return typeof value === 'string';\n\t },\n\t isObject: function isObject(value) {\n\t return value !== null && (typeof value === 'undefined' ? 'undefined' : _typeof(value)) === 'object';\n\t },\n\t isFunction: function isFunction(value) {\n\t return typeof value === 'function';\n\t },\n\t fromJson: function fromJson(value) {\n\t return JSON.parse(value);\n\t },\n\t equals: function equals(a, b) {\n\t return a === b;\n\t },\n\t\n\t Promise: _Promise\n\t};\n\t\n\tfunction _keys(collection) {\n\t var keys = [];\n\t var key = undefined;\n\t if (!utils.isObject(collection)) {\n\t return keys;\n\t }\n\t for (key in collection) {\n\t if (collection.hasOwnProperty(key)) {\n\t keys.push(key);\n\t }\n\t }\n\t return keys;\n\t}\n\t\n\tfunction _isPromiseLike(value) {\n\t return value && typeof value.then === 'function';\n\t}\n\t\n\tfunction _stringifyNumber(number) {\n\t if (utils.isNumber(number)) {\n\t return number.toString();\n\t }\n\t return number;\n\t}\n\t\n\tfunction _keySet(collection) {\n\t var keySet = {};\n\t var key = undefined;\n\t if (!utils.isObject(collection)) {\n\t return keySet;\n\t }\n\t for (key in collection) {\n\t if (collection.hasOwnProperty(key)) {\n\t keySet[key] = key;\n\t }\n\t }\n\t return keySet;\n\t}\n\t\n\tvar defaults = {\n\t capacity: Number.MAX_VALUE,\n\t maxAge: Number.MAX_VALUE,\n\t deleteOnExpire: 'none',\n\t onExpire: null,\n\t cacheFlushInterval: null,\n\t recycleFreq: 1000,\n\t storageMode: 'memory',\n\t storageImpl: null,\n\t disabled: false,\n\t storagePrefix: 'cachefactory.caches.',\n\t storeOnResolve: false,\n\t storeOnReject: false\n\t};\n\t\n\tvar caches = {};\n\t\n\tfunction createCache(cacheId, options) {\n\t if (cacheId in caches) {\n\t throw new Error(cacheId + ' already exists!');\n\t } else if (!utils.isString(cacheId)) {\n\t throw new Error('cacheId must be a string!');\n\t }\n\t\n\t var $$data = {};\n\t var $$promises = {};\n\t var $$storage = null;\n\t var $$expiresHeap = new BinaryHeap(function (x) {\n\t return x.expires;\n\t }, utils.equals);\n\t var $$lruHeap = new BinaryHeap(function (x) {\n\t return x.accessed;\n\t }, utils.equals);\n\t\n\t var cache = caches[cacheId] = {\n\t\n\t $$id: cacheId,\n\t\n\t destroy: function destroy() {\n\t clearInterval(this.$$cacheFlushIntervalId);\n\t clearInterval(this.$$recycleFreqId);\n\t this.removeAll();\n\t if ($$storage) {\n\t $$storage().removeItem(this.$$prefix + '.keys');\n\t $$storage().removeItem(this.$$prefix);\n\t }\n\t $$storage = null;\n\t $$data = null;\n\t $$lruHeap = null;\n\t $$expiresHeap = null;\n\t this.$$prefix = null;\n\t delete caches[this.$$id];\n\t },\n\t disable: function disable() {\n\t this.$$disabled = true;\n\t },\n\t enable: function enable() {\n\t delete this.$$disabled;\n\t },\n\t get: function get(key, options) {\n\t var _this2 = this;\n\t\n\t if (Array.isArray(key)) {\n\t var _ret = function () {\n\t var keys = key;\n\t var values = [];\n\t\n\t keys.forEach(function (key) {\n\t var value = _this2.get(key, options);\n\t if (value !== null && value !== undefined) {\n\t values.push(value);\n\t }\n\t });\n\t\n\t return {\n\t v: values\n\t };\n\t }();\n\t\n\t if ((typeof _ret === 'undefined' ? 'undefined' : _typeof(_ret)) === \"object\") return _ret.v;\n\t } else {\n\t key = _stringifyNumber(key);\n\t\n\t if (this.$$disabled) {\n\t return;\n\t }\n\t }\n\t\n\t options = options || {};\n\t if (!utils.isString(key)) {\n\t throw new Error('key must be a string!');\n\t } else if (options && !utils.isObject(options)) {\n\t throw new Error('options must be an object!');\n\t } else if (options.onExpire && !utils.isFunction(options.onExpire)) {\n\t throw new Error('options.onExpire must be a function!');\n\t }\n\t\n\t var item = undefined;\n\t\n\t if ($$storage) {\n\t if ($$promises[key]) {\n\t return $$promises[key];\n\t }\n\t\n\t var itemJson = $$storage().getItem(this.$$prefix + '.data.' + key);\n\t\n\t if (itemJson) {\n\t item = utils.fromJson(itemJson);\n\t } else {\n\t return;\n\t }\n\t } else if (utils.isObject($$data)) {\n\t if (!(key in $$data)) {\n\t return;\n\t }\n\t\n\t item = $$data[key];\n\t }\n\t\n\t var value = item.value;\n\t var now = new Date().getTime();\n\t\n\t if ($$storage) {\n\t $$lruHeap.remove({\n\t key: key,\n\t accessed: item.accessed\n\t });\n\t item.accessed = now;\n\t $$lruHeap.push({\n\t key: key,\n\t accessed: now\n\t });\n\t } else {\n\t $$lruHeap.remove(item);\n\t item.accessed = now;\n\t $$lruHeap.push(item);\n\t }\n\t\n\t if (this.$$deleteOnExpire === 'passive' && 'expires' in item && item.expires < now) {\n\t this.remove(key);\n\t\n\t if (this.$$onExpire) {\n\t this.$$onExpire(key, item.value, options.onExpire);\n\t } else if (options.onExpire) {\n\t options.onExpire.call(this, key, item.value);\n\t }\n\t value = undefined;\n\t } else if ($$storage) {\n\t $$storage().setItem(this.$$prefix + '.data.' + key, JSON.stringify(item));\n\t }\n\t\n\t return value;\n\t },\n\t info: function info(key) {\n\t if (key) {\n\t var item = undefined;\n\t if ($$storage) {\n\t var itemJson = $$storage().getItem(this.$$prefix + '.data.' + key);\n\t\n\t if (itemJson) {\n\t item = utils.fromJson(itemJson);\n\t return {\n\t created: item.created,\n\t accessed: item.accessed,\n\t expires: item.expires,\n\t isExpired: new Date().getTime() - item.created > (item.maxAge || this.$$maxAge)\n\t };\n\t } else {\n\t return undefined;\n\t }\n\t } else if (utils.isObject($$data) && key in $$data) {\n\t item = $$data[key];\n\t\n\t return {\n\t created: item.created,\n\t accessed: item.accessed,\n\t expires: item.expires,\n\t isExpired: new Date().getTime() - item.created > (item.maxAge || this.$$maxAge)\n\t };\n\t } else {\n\t return undefined;\n\t }\n\t } else {\n\t return {\n\t id: this.$$id,\n\t capacity: this.$$capacity,\n\t maxAge: this.$$maxAge,\n\t deleteOnExpire: this.$$deleteOnExpire,\n\t onExpire: this.$$onExpire,\n\t cacheFlushInterval: this.$$cacheFlushInterval,\n\t recycleFreq: this.$$recycleFreq,\n\t storageMode: this.$$storageMode,\n\t storageImpl: $$storage ? $$storage() : undefined,\n\t disabled: !!this.$$disabled,\n\t size: $$lruHeap && $$lruHeap.size() || 0\n\t };\n\t }\n\t },\n\t keys: function keys() {\n\t if ($$storage) {\n\t var keysJson = $$storage().getItem(this.$$prefix + '.keys');\n\t\n\t if (keysJson) {\n\t return utils.fromJson(keysJson);\n\t } else {\n\t return [];\n\t }\n\t } else {\n\t return _keys($$data);\n\t }\n\t },\n\t keySet: function keySet() {\n\t if ($$storage) {\n\t var keysJson = $$storage().getItem(this.$$prefix + '.keys');\n\t var kSet = {};\n\t\n\t if (keysJson) {\n\t var keys = utils.fromJson(keysJson);\n\t\n\t for (var i = 0; i < keys.length; i++) {\n\t kSet[keys[i]] = keys[i];\n\t }\n\t }\n\t return kSet;\n\t } else {\n\t return _keySet($$data);\n\t }\n\t },\n\t put: function put(key, value, options) {\n\t var _this3 = this;\n\t\n\t options || (options = {});\n\t\n\t var storeOnResolve = 'storeOnResolve' in options ? !!options.storeOnResolve : this.$$storeOnResolve;\n\t var storeOnReject = 'storeOnReject' in options ? !!options.storeOnReject : this.$$storeOnReject;\n\t\n\t var getHandler = function getHandler(store, isError) {\n\t return function (v) {\n\t if (store) {\n\t delete $$promises[key];\n\t if (utils.isObject(v) && 'status' in v && 'data' in v) {\n\t v = [v.status, v.data, v.headers(), v.statusText];\n\t _this3.put(key, v);\n\t } else {\n\t _this3.put(key, v);\n\t }\n\t }\n\t if (isError) {\n\t if (utils.Promise) {\n\t return utils.Promise.reject(v);\n\t } else {\n\t throw v;\n\t }\n\t } else {\n\t return v;\n\t }\n\t };\n\t };\n\t\n\t if (this.$$disabled || !utils.isObject($$data) || value === null || value === undefined) {\n\t return;\n\t }\n\t key = _stringifyNumber(key);\n\t\n\t if (!utils.isString(key)) {\n\t throw new Error('key must be a string!');\n\t }\n\t\n\t var now = new Date().getTime();\n\t var item = {\n\t key: key,\n\t value: _isPromiseLike(value) ? value.then(getHandler(storeOnResolve, false), getHandler(storeOnReject, true)) : value,\n\t created: options.created === undefined ? now : options.created,\n\t accessed: options.accessed === undefined ? now : options.accessed\n\t };\n\t if (options.maxAge) {\n\t item.maxAge = options.maxAge;\n\t }\n\t\n\t if (options.expires === undefined) {\n\t item.expires = item.created + (item.maxAge || this.$$maxAge);\n\t } else {\n\t item.expires = options.expires;\n\t }\n\t\n\t if ($$storage) {\n\t if (_isPromiseLike(item.value)) {\n\t $$promises[key] = item.value;\n\t return $$promises[key];\n\t }\n\t var keysJson = $$storage().getItem(this.$$prefix + '.keys');\n\t var keys = keysJson ? utils.fromJson(keysJson) : [];\n\t var itemJson = $$storage().getItem(this.$$prefix + '.data.' + key);\n\t\n\t // Remove existing\n\t if (itemJson) {\n\t this.remove(key);\n\t }\n\t // Add to expires heap\n\t $$expiresHeap.push({\n\t key: key,\n\t expires: item.expires\n\t });\n\t // Add to lru heap\n\t $$lruHeap.push({\n\t key: key,\n\t accessed: item.accessed\n\t });\n\t // Set item\n\t $$storage().setItem(this.$$prefix + '.data.' + key, JSON.stringify(item));\n\t var exists = false;\n\t for (var i = 0; i < keys.length; i++) {\n\t if (keys[i] === key) {\n\t exists = true;\n\t break;\n\t }\n\t }\n\t if (!exists) {\n\t keys.push(key);\n\t }\n\t $$storage().setItem(this.$$prefix + '.keys', JSON.stringify(keys));\n\t } else {\n\t // Remove existing\n\t if ($$data[key]) {\n\t this.remove(key);\n\t }\n\t // Add to expires heap\n\t $$expiresHeap.push(item);\n\t // Add to lru heap\n\t $$lruHeap.push(item);\n\t // Set item\n\t $$data[key] = item;\n\t delete $$promises[key];\n\t }\n\t\n\t // Handle exceeded capacity\n\t if ($$lruHeap.size() > this.$$capacity) {\n\t this.remove($$lruHeap.peek().key);\n\t }\n\t\n\t return value;\n\t },\n\t remove: function remove(key) {\n\t key += '';\n\t delete $$promises[key];\n\t if ($$storage) {\n\t var itemJson = $$storage().getItem(this.$$prefix + '.data.' + key);\n\t\n\t if (itemJson) {\n\t var item = utils.fromJson(itemJson);\n\t $$lruHeap.remove({\n\t key: key,\n\t accessed: item.accessed\n\t });\n\t $$expiresHeap.remove({\n\t key: key,\n\t expires: item.expires\n\t });\n\t $$storage().removeItem(this.$$prefix + '.data.' + key);\n\t var keysJson = $$storage().getItem(this.$$prefix + '.keys');\n\t var keys = keysJson ? utils.fromJson(keysJson) : [];\n\t var index = keys.indexOf(key);\n\t\n\t if (index >= 0) {\n\t keys.splice(index, 1);\n\t }\n\t $$storage().setItem(this.$$prefix + '.keys', JSON.stringify(keys));\n\t return item.value;\n\t }\n\t } else if (utils.isObject($$data)) {\n\t var value = $$data[key] ? $$data[key].value : undefined;\n\t $$lruHeap.remove($$data[key]);\n\t $$expiresHeap.remove($$data[key]);\n\t $$data[key] = null;\n\t delete $$data[key];\n\t return value;\n\t }\n\t },\n\t removeAll: function removeAll() {\n\t if ($$storage) {\n\t $$lruHeap.removeAll();\n\t $$expiresHeap.removeAll();\n\t var keysJson = $$storage().getItem(this.$$prefix + '.keys');\n\t\n\t if (keysJson) {\n\t var keys = utils.fromJson(keysJson);\n\t\n\t for (var i = 0; i < keys.length; i++) {\n\t this.remove(keys[i]);\n\t }\n\t }\n\t $$storage().setItem(this.$$prefix + '.keys', JSON.stringify([]));\n\t } else if (utils.isObject($$data)) {\n\t $$lruHeap.removeAll();\n\t $$expiresHeap.removeAll();\n\t for (var key in $$data) {\n\t $$data[key] = null;\n\t }\n\t $$data = {};\n\t } else {\n\t $$lruHeap.removeAll();\n\t $$expiresHeap.removeAll();\n\t $$data = {};\n\t }\n\t $$promises = {};\n\t },\n\t removeExpired: function removeExpired() {\n\t var now = new Date().getTime();\n\t var expired = {};\n\t var key = undefined;\n\t var expiredItem = undefined;\n\t\n\t while ((expiredItem = $$expiresHeap.peek()) && expiredItem.expires <= now) {\n\t expired[expiredItem.key] = expiredItem.value ? expiredItem.value : null;\n\t $$expiresHeap.pop();\n\t }\n\t\n\t if ($$storage) {\n\t for (key in expired) {\n\t var itemJson = $$storage().getItem(this.$$prefix + '.data.' + key);\n\t if (itemJson) {\n\t expired[key] = utils.fromJson(itemJson).value;\n\t this.remove(key);\n\t }\n\t }\n\t } else {\n\t for (key in expired) {\n\t this.remove(key);\n\t }\n\t }\n\t\n\t if (this.$$onExpire) {\n\t for (key in expired) {\n\t this.$$onExpire(key, expired[key]);\n\t }\n\t }\n\t\n\t return expired;\n\t },\n\t setCacheFlushInterval: function setCacheFlushInterval(cacheFlushInterval) {\n\t var _this = this;\n\t if (cacheFlushInterval === null) {\n\t delete _this.$$cacheFlushInterval;\n\t } else if (!utils.isNumber(cacheFlushInterval)) {\n\t throw new Error('cacheFlushInterval must be a number!');\n\t } else if (cacheFlushInterval < 0) {\n\t throw new Error('cacheFlushInterval must be greater than zero!');\n\t } else if (cacheFlushInterval !== _this.$$cacheFlushInterval) {\n\t _this.$$cacheFlushInterval = cacheFlushInterval;\n\t\n\t clearInterval(_this.$$cacheFlushIntervalId); // eslint-disable-line\n\t\n\t _this.$$cacheFlushIntervalId = setInterval(function () {\n\t _this.removeAll();\n\t }, _this.$$cacheFlushInterval);\n\t }\n\t },\n\t setCapacity: function setCapacity(capacity) {\n\t if (capacity === null) {\n\t delete this.$$capacity;\n\t } else if (!utils.isNumber(capacity)) {\n\t throw new Error('capacity must be a number!');\n\t } else if (capacity < 0) {\n\t throw new Error('capacity must be greater than zero!');\n\t } else {\n\t this.$$capacity = capacity;\n\t }\n\t var removed = {};\n\t while ($$lruHeap.size() > this.$$capacity) {\n\t removed[$$lruHeap.peek().key] = this.remove($$lruHeap.peek().key);\n\t }\n\t return removed;\n\t },\n\t setDeleteOnExpire: function setDeleteOnExpire(deleteOnExpire, setRecycleFreq) {\n\t if (deleteOnExpire === null) {\n\t delete this.$$deleteOnExpire;\n\t } else if (!utils.isString(deleteOnExpire)) {\n\t throw new Error('deleteOnExpire must be a string!');\n\t } else if (deleteOnExpire !== 'none' && deleteOnExpire !== 'passive' && deleteOnExpire !== 'aggressive') {\n\t throw new Error('deleteOnExpire must be \"none\", \"passive\" or \"aggressive\"!');\n\t } else {\n\t this.$$deleteOnExpire = deleteOnExpire;\n\t }\n\t if (setRecycleFreq !== false) {\n\t this.setRecycleFreq(this.$$recycleFreq);\n\t }\n\t },\n\t setMaxAge: function setMaxAge(maxAge) {\n\t if (maxAge === null) {\n\t this.$$maxAge = Number.MAX_VALUE;\n\t } else if (!utils.isNumber(maxAge)) {\n\t throw new Error('maxAge must be a number!');\n\t } else if (maxAge < 0) {\n\t throw new Error('maxAge must be greater than zero!');\n\t } else {\n\t this.$$maxAge = maxAge;\n\t }\n\t var i = undefined,\n\t keys = undefined,\n\t key = undefined;\n\t\n\t $$expiresHeap.removeAll();\n\t\n\t if ($$storage) {\n\t var keysJson = $$storage().getItem(this.$$prefix + '.keys');\n\t\n\t keys = keysJson ? utils.fromJson(keysJson) : [];\n\t\n\t for (i = 0; i < keys.length; i++) {\n\t key = keys[i];\n\t var itemJson = $$storage().getItem(this.$$prefix + '.data.' + key);\n\t\n\t if (itemJson) {\n\t var item = utils.fromJson(itemJson);\n\t if (this.$$maxAge === Number.MAX_VALUE) {\n\t item.expires = Number.MAX_VALUE;\n\t } else {\n\t item.expires = item.created + (item.maxAge || this.$$maxAge);\n\t }\n\t $$expiresHeap.push({\n\t key: key,\n\t expires: item.expires\n\t });\n\t }\n\t }\n\t } else {\n\t keys = _keys($$data);\n\t\n\t for (i = 0; i < keys.length; i++) {\n\t key = keys[i];\n\t if (this.$$maxAge === Number.MAX_VALUE) {\n\t $$data[key].expires = Number.MAX_VALUE;\n\t } else {\n\t $$data[key].expires = $$data[key].created + ($$data[key].maxAge || this.$$maxAge);\n\t }\n\t $$expiresHeap.push($$data[key]);\n\t }\n\t }\n\t if (this.$$deleteOnExpire === 'aggressive') {\n\t return this.removeExpired();\n\t } else {\n\t return {};\n\t }\n\t },\n\t setOnExpire: function setOnExpire(onExpire) {\n\t if (onExpire === null) {\n\t delete this.$$onExpire;\n\t } else if (!utils.isFunction(onExpire)) {\n\t throw new Error('onExpire must be a function!');\n\t } else {\n\t this.$$onExpire = onExpire;\n\t }\n\t },\n\t setOptions: function setOptions(cacheOptions, strict) {\n\t cacheOptions = cacheOptions || {};\n\t strict = !!strict;\n\t if (!utils.isObject(cacheOptions)) {\n\t throw new Error('cacheOptions must be an object!');\n\t }\n\t\n\t if ('storagePrefix' in cacheOptions) {\n\t this.$$storagePrefix = cacheOptions.storagePrefix;\n\t } else if (strict) {\n\t this.$$storagePrefix = defaults.storagePrefix;\n\t }\n\t\n\t this.$$prefix = this.$$storagePrefix + this.$$id;\n\t\n\t if ('disabled' in cacheOptions) {\n\t this.$$disabled = !!cacheOptions.disabled;\n\t } else if (strict) {\n\t this.$$disabled = defaults.disabled;\n\t }\n\t\n\t if ('deleteOnExpire' in cacheOptions) {\n\t this.setDeleteOnExpire(cacheOptions.deleteOnExpire, false);\n\t } else if (strict) {\n\t this.setDeleteOnExpire(defaults.deleteOnExpire, false);\n\t }\n\t\n\t if ('recycleFreq' in cacheOptions) {\n\t this.setRecycleFreq(cacheOptions.recycleFreq);\n\t } else if (strict) {\n\t this.setRecycleFreq(defaults.recycleFreq);\n\t }\n\t\n\t if ('maxAge' in cacheOptions) {\n\t this.setMaxAge(cacheOptions.maxAge);\n\t } else if (strict) {\n\t this.setMaxAge(defaults.maxAge);\n\t }\n\t\n\t if ('storeOnResolve' in cacheOptions) {\n\t this.$$storeOnResolve = !!cacheOptions.storeOnResolve;\n\t } else if (strict) {\n\t this.$$storeOnResolve = defaults.storeOnResolve;\n\t }\n\t\n\t if ('storeOnReject' in cacheOptions) {\n\t this.$$storeOnReject = !!cacheOptions.storeOnReject;\n\t } else if (strict) {\n\t this.$$storeOnReject = defaults.storeOnReject;\n\t }\n\t\n\t if ('capacity' in cacheOptions) {\n\t this.setCapacity(cacheOptions.capacity);\n\t } else if (strict) {\n\t this.setCapacity(defaults.capacity);\n\t }\n\t\n\t if ('cacheFlushInterval' in cacheOptions) {\n\t this.setCacheFlushInterval(cacheOptions.cacheFlushInterval);\n\t } else if (strict) {\n\t this.setCacheFlushInterval(defaults.cacheFlushInterval);\n\t }\n\t\n\t if ('onExpire' in cacheOptions) {\n\t this.setOnExpire(cacheOptions.onExpire);\n\t } else if (strict) {\n\t this.setOnExpire(defaults.onExpire);\n\t }\n\t\n\t if ('storageMode' in cacheOptions || 'storageImpl' in cacheOptions) {\n\t this.setStorageMode(cacheOptions.storageMode || defaults.storageMode, cacheOptions.storageImpl || defaults.storageImpl);\n\t } else if (strict) {\n\t this.setStorageMode(defaults.storageMode, defaults.storageImpl);\n\t }\n\t },\n\t setRecycleFreq: function setRecycleFreq(recycleFreq) {\n\t if (recycleFreq === null) {\n\t delete this.$$recycleFreq;\n\t } else if (!utils.isNumber(recycleFreq)) {\n\t throw new Error('recycleFreq must be a number!');\n\t } else if (recycleFreq < 0) {\n\t throw new Error('recycleFreq must be greater than zero!');\n\t } else {\n\t this.$$recycleFreq = recycleFreq;\n\t }\n\t clearInterval(this.$$recycleFreqId);\n\t if (this.$$deleteOnExpire === 'aggressive') {\n\t (function (self) {\n\t self.$$recycleFreqId = setInterval(function () {\n\t self.removeExpired();\n\t }, self.$$recycleFreq);\n\t })(this);\n\t } else {\n\t delete this.$$recycleFreqId;\n\t }\n\t },\n\t setStorageMode: function setStorageMode(storageMode, storageImpl) {\n\t if (!utils.isString(storageMode)) {\n\t throw new Error('storageMode must be a string!');\n\t } else if (storageMode !== 'memory' && storageMode !== 'localStorage' && storageMode !== 'sessionStorage') {\n\t throw new Error('storageMode must be \"memory\", \"localStorage\" or \"sessionStorage\"!');\n\t }\n\t\n\t var prevStorage = $$storage;\n\t var prevData = $$data;\n\t var shouldReInsert = false;\n\t var items = {};\n\t\n\t function load(prevStorage, prevData) {\n\t var keys = this.keys();\n\t var length = keys.length;\n\t if (length) {\n\t var _key = undefined;\n\t var prevDataIsObject = utils.isObject(prevData);\n\t for (var i = 0; i < length; i++) {\n\t _key = keys[i];\n\t if (prevStorage) {\n\t var itemJson = prevStorage().getItem(this.$$prefix + '.data.' + _key);\n\t if (itemJson) {\n\t items[_key] = utils.fromJson(itemJson);\n\t }\n\t } else if (prevDataIsObject) {\n\t items[_key] = prevData[_key];\n\t }\n\t this.remove(_key);\n\t }\n\t shouldReInsert = true;\n\t }\n\t }\n\t\n\t if (!this.$$initializing) {\n\t load.call(this, prevStorage, prevData);\n\t }\n\t\n\t this.$$storageMode = storageMode;\n\t\n\t if (storageImpl) {\n\t if (!utils.isObject(storageImpl)) {\n\t throw new Error('storageImpl must be an object!');\n\t } else if (!('setItem' in storageImpl) || typeof storageImpl.setItem !== 'function') {\n\t throw new Error('storageImpl must implement \"setItem(key, value)\"!');\n\t } else if (!('getItem' in storageImpl) || typeof storageImpl.getItem !== 'function') {\n\t throw new Error('storageImpl must implement \"getItem(key)\"!');\n\t } else if (!('removeItem' in storageImpl) || typeof storageImpl.removeItem !== 'function') {\n\t throw new Error('storageImpl must implement \"removeItem(key)\"!');\n\t }\n\t $$storage = function $$storage() {\n\t return storageImpl;\n\t };\n\t } else if (this.$$storageMode === 'localStorage') {\n\t try {\n\t localStorage.setItem('cachefactory', 'cachefactory');\n\t localStorage.removeItem('cachefactory');\n\t $$storage = function $$storage() {\n\t return localStorage;\n\t };\n\t } catch (e) {\n\t $$storage = null;\n\t this.$$storageMode = 'memory';\n\t }\n\t } else if (this.$$storageMode === 'sessionStorage') {\n\t try {\n\t sessionStorage.setItem('cachefactory', 'cachefactory');\n\t sessionStorage.removeItem('cachefactory');\n\t $$storage = function $$storage() {\n\t return sessionStorage;\n\t };\n\t } catch (e) {\n\t $$storage = null;\n\t this.$$storageMode = 'memory';\n\t }\n\t } else {\n\t $$storage = null;\n\t this.$$storageModel = 'memory';\n\t }\n\t\n\t if (this.$$initializing) {\n\t load.call(this, $$storage, $$data);\n\t }\n\t\n\t if (shouldReInsert) {\n\t var item = undefined;\n\t for (var key in items) {\n\t item = items[key];\n\t this.put(key, item.value, {\n\t created: item.created,\n\t accessed: item.accessed,\n\t expires: item.expires\n\t });\n\t }\n\t }\n\t },\n\t touch: function touch(key) {\n\t var _this4 = this;\n\t\n\t if (key) {\n\t var val = this.get(key, {\n\t onExpire: function onExpire(k, v) {\n\t return _this4.put(k, v);\n\t }\n\t });\n\t if (val) {\n\t this.put(key, val);\n\t }\n\t } else {\n\t var keys = this.keys();\n\t for (var i = 0; i < keys.length; i++) {\n\t this.touch(keys[i]);\n\t }\n\t }\n\t },\n\t values: function values() {\n\t var keys = this.keys();\n\t var items = [];\n\t for (var i = 0; i < keys.length; i++) {\n\t items.push(this.get(keys[i]));\n\t }\n\t return items;\n\t }\n\t };\n\t\n\t cache.$$initializing = true;\n\t cache.setOptions(options, true);\n\t cache.$$initializing = false;\n\t\n\t return cache;\n\t}\n\t\n\tfunction CacheFactory(cacheId, options) {\n\t return createCache(cacheId, options);\n\t}\n\t\n\tCacheFactory.createCache = createCache;\n\tCacheFactory.defaults = defaults;\n\t\n\tCacheFactory.info = function () {\n\t var keys = _keys(caches);\n\t var info = {\n\t size: keys.length,\n\t caches: {}\n\t };\n\t for (var opt in defaults) {\n\t if (defaults.hasOwnProperty(opt)) {\n\t info[opt] = defaults[opt];\n\t }\n\t }\n\t for (var i = 0; i < keys.length; i++) {\n\t var key = keys[i];\n\t info.caches[key] = caches[key].info();\n\t }\n\t return info;\n\t};\n\t\n\tCacheFactory.get = function (cacheId) {\n\t return caches[cacheId];\n\t};\n\tCacheFactory.keySet = function () {\n\t return _keySet(caches);\n\t};\n\tCacheFactory.keys = function () {\n\t return _keys(caches);\n\t};\n\tCacheFactory.destroy = function (cacheId) {\n\t if (caches[cacheId]) {\n\t caches[cacheId].destroy();\n\t delete caches[cacheId];\n\t }\n\t};\n\tCacheFactory.destroyAll = function () {\n\t for (var cacheId in caches) {\n\t caches[cacheId].destroy();\n\t }\n\t caches = {};\n\t};\n\tCacheFactory.clearAll = function () {\n\t for (var cacheId in caches) {\n\t caches[cacheId].removeAll();\n\t }\n\t};\n\tCacheFactory.removeExpiredFromAll = function () {\n\t var expired = {};\n\t for (var cacheId in caches) {\n\t expired[cacheId] = caches[cacheId].removeExpired();\n\t }\n\t return expired;\n\t};\n\tCacheFactory.enableAll = function () {\n\t for (var cacheId in caches) {\n\t caches[cacheId].$$disabled = false;\n\t }\n\t};\n\tCacheFactory.disableAll = function () {\n\t for (var cacheId in caches) {\n\t caches[cacheId].$$disabled = true;\n\t }\n\t};\n\tCacheFactory.touchAll = function () {\n\t for (var cacheId in caches) {\n\t caches[cacheId].touch();\n\t }\n\t};\n\t\n\tCacheFactory.utils = utils;\n\tCacheFactory.BinaryHeap = BinaryHeap;\n\t\n\tmodule.exports = CacheFactory;\n\n/***/ },\n/* 1 */\n/***/ function(module, exports, __webpack_require__) {\n\n\t/*!\n\t * yabh\n\t * @version 1.1.0 - Homepage \n\t * @author Jason Dobry \n\t * @copyright (c) 2015 Jason Dobry \n\t * @license MIT \n\t * \n\t * @overview Yet another Binary Heap.\n\t */\n\t(function webpackUniversalModuleDefinition(root, factory) {\n\t\tif(true)\n\t\t\tmodule.exports = factory();\n\t\telse if(typeof define === 'function' && define.amd)\n\t\t\tdefine(\"yabh\", factory);\n\t\telse if(typeof exports === 'object')\n\t\t\texports[\"BinaryHeap\"] = factory();\n\t\telse\n\t\t\troot[\"BinaryHeap\"] = factory();\n\t})(this, function() {\n\treturn /******/ (function(modules) { // webpackBootstrap\n\t/******/ \t// The module cache\n\t/******/ \tvar installedModules = {};\n\t\n\t/******/ \t// The require function\n\t/******/ \tfunction __webpack_require__(moduleId) {\n\t\n\t/******/ \t\t// Check if module is in cache\n\t/******/ \t\tif(installedModules[moduleId])\n\t/******/ \t\t\treturn installedModules[moduleId].exports;\n\t\n\t/******/ \t\t// Create a new module (and put it into the cache)\n\t/******/ \t\tvar module = installedModules[moduleId] = {\n\t/******/ \t\t\texports: {},\n\t/******/ \t\t\tid: moduleId,\n\t/******/ \t\t\tloaded: false\n\t/******/ \t\t};\n\t\n\t/******/ \t\t// Execute the module function\n\t/******/ \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\t\n\t/******/ \t\t// Flag the module as loaded\n\t/******/ \t\tmodule.loaded = true;\n\t\n\t/******/ \t\t// Return the exports of the module\n\t/******/ \t\treturn module.exports;\n\t/******/ \t}\n\t\n\t\n\t/******/ \t// expose the modules object (__webpack_modules__)\n\t/******/ \t__webpack_require__.m = modules;\n\t\n\t/******/ \t// expose the module cache\n\t/******/ \t__webpack_require__.c = installedModules;\n\t\n\t/******/ \t// __webpack_public_path__\n\t/******/ \t__webpack_require__.p = \"\";\n\t\n\t/******/ \t// Load entry module and return exports\n\t/******/ \treturn __webpack_require__(0);\n\t/******/ })\n\t/************************************************************************/\n\t/******/ ([\n\t/* 0 */\n\t/***/ function(module, exports, __webpack_require__) {\n\t\n\t\t/**\n\t\t * @method bubbleUp\n\t\t * @param {array} heap The heap.\n\t\t * @param {function} weightFunc The weight function.\n\t\t * @param {number} n The index of the element to bubble up.\n\t\t */\n\t\tfunction bubbleUp(heap, weightFunc, n) {\n\t\t var element = heap[n];\n\t\t var weight = weightFunc(element);\n\t\t // When at 0, an element can not go up any further.\n\t\t while (n > 0) {\n\t\t // Compute the parent element's index, and fetch it.\n\t\t var parentN = Math.floor((n + 1) / 2) - 1;\n\t\t var _parent = heap[parentN];\n\t\t // If the parent has a lesser weight, things are in order and we\n\t\t // are done.\n\t\t if (weight >= weightFunc(_parent)) {\n\t\t break;\n\t\t } else {\n\t\t heap[parentN] = element;\n\t\t heap[n] = _parent;\n\t\t n = parentN;\n\t\t }\n\t\t }\n\t\t}\n\t\n\t\t/**\n\t\t * @method bubbleDown\n\t\t * @param {array} heap The heap.\n\t\t * @param {function} weightFunc The weight function.\n\t\t * @param {number} n The index of the element to sink down.\n\t\t */\n\t\tvar bubbleDown = function bubbleDown(heap, weightFunc, n) {\n\t\t var length = heap.length;\n\t\t var node = heap[n];\n\t\t var nodeWeight = weightFunc(node);\n\t\n\t\t while (true) {\n\t\t var child2N = (n + 1) * 2,\n\t\t child1N = child2N - 1;\n\t\t var swap = null;\n\t\t if (child1N < length) {\n\t\t var child1 = heap[child1N],\n\t\t child1Weight = weightFunc(child1);\n\t\t // If the score is less than our node's, we need to swap.\n\t\t if (child1Weight < nodeWeight) {\n\t\t swap = child1N;\n\t\t }\n\t\t }\n\t\t // Do the same checks for the other child.\n\t\t if (child2N < length) {\n\t\t var child2 = heap[child2N],\n\t\t child2Weight = weightFunc(child2);\n\t\t if (child2Weight < (swap === null ? nodeWeight : weightFunc(heap[child1N]))) {\n\t\t swap = child2N;\n\t\t }\n\t\t }\n\t\n\t\t if (swap === null) {\n\t\t break;\n\t\t } else {\n\t\t heap[n] = heap[swap];\n\t\t heap[swap] = node;\n\t\t n = swap;\n\t\t }\n\t\t }\n\t\t};\n\t\n\t\tfunction BinaryHeap(weightFunc, compareFunc) {\n\t\t if (!weightFunc) {\n\t\t weightFunc = function (x) {\n\t\t return x;\n\t\t };\n\t\t }\n\t\t if (!compareFunc) {\n\t\t compareFunc = function (x, y) {\n\t\t return x === y;\n\t\t };\n\t\t }\n\t\t if (typeof weightFunc !== 'function') {\n\t\t throw new Error('BinaryHeap([weightFunc][, compareFunc]): \"weightFunc\" must be a function!');\n\t\t }\n\t\t if (typeof compareFunc !== 'function') {\n\t\t throw new Error('BinaryHeap([weightFunc][, compareFunc]): \"compareFunc\" must be a function!');\n\t\t }\n\t\t this.weightFunc = weightFunc;\n\t\t this.compareFunc = compareFunc;\n\t\t this.heap = [];\n\t\t}\n\t\n\t\tvar BHProto = BinaryHeap.prototype;\n\t\n\t\tBHProto.push = function (node) {\n\t\t this.heap.push(node);\n\t\t bubbleUp(this.heap, this.weightFunc, this.heap.length - 1);\n\t\t};\n\t\n\t\tBHProto.peek = function () {\n\t\t return this.heap[0];\n\t\t};\n\t\n\t\tBHProto.pop = function () {\n\t\t var front = this.heap[0];\n\t\t var end = this.heap.pop();\n\t\t if (this.heap.length > 0) {\n\t\t this.heap[0] = end;\n\t\t bubbleDown(this.heap, this.weightFunc, 0);\n\t\t }\n\t\t return front;\n\t\t};\n\t\n\t\tBHProto.remove = function (node) {\n\t\t var length = this.heap.length;\n\t\t for (var i = 0; i < length; i++) {\n\t\t if (this.compareFunc(this.heap[i], node)) {\n\t\t var removed = this.heap[i];\n\t\t var end = this.heap.pop();\n\t\t if (i !== length - 1) {\n\t\t this.heap[i] = end;\n\t\t bubbleUp(this.heap, this.weightFunc, i);\n\t\t bubbleDown(this.heap, this.weightFunc, i);\n\t\t }\n\t\t return removed;\n\t\t }\n\t\t }\n\t\t return null;\n\t\t};\n\t\n\t\tBHProto.removeAll = function () {\n\t\t this.heap = [];\n\t\t};\n\t\n\t\tBHProto.size = function () {\n\t\t return this.heap.length;\n\t\t};\n\t\n\t\tmodule.exports = BinaryHeap;\n\t\n\t/***/ }\n\t/******/ ])\n\t});\n\t;\n\n/***/ }\n/******/ ])\n});\n;\n//# sourceMappingURL=cachefactory.js.map\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ../CacheFactory/dist/cachefactory.js\n ** module id = 2\n ** module chunks = 0\n **/"],"sourceRoot":""} \ No newline at end of file +{"version":3,"file":"angular-cache.js","sources":["../node_modules/cachefactory/dist/cachefactory.es2015.js","../src/index.js"],"sourcesContent":["/**\n * CacheFactory\n * @version 1.5.1 - Homepage \n * @copyright (c) 2013-2016 CacheFactory project authors\n * @license MIT \n * @overview CacheFactory is a very simple and useful cache for the browser.\n */\nvar babelHelpers = {};\nbabelHelpers.typeof = typeof Symbol === \"function\" && typeof Symbol.iterator === \"symbol\" ? function (obj) {\n return typeof obj;\n} : function (obj) {\n return obj && typeof Symbol === \"function\" && obj.constructor === Symbol ? \"symbol\" : typeof obj;\n};\nbabelHelpers;\n\n/**\n * @method bubbleUp\n * @param {array} heap The heap.\n * @param {function} weightFunc The weight function.\n * @param {number} n The index of the element to bubble up.\n */\nvar bubbleUp = function bubbleUp(heap, weightFunc, n) {\n var element = heap[n];\n var weight = weightFunc(element);\n // When at 0, an element can not go up any further.\n while (n > 0) {\n // Compute the parent element's index, and fetch it.\n var parentN = Math.floor((n + 1) / 2) - 1;\n var parent = heap[parentN];\n // If the parent has a lesser weight, things are in order and we\n // are done.\n if (weight >= weightFunc(parent)) {\n break;\n } else {\n heap[parentN] = element;\n heap[n] = parent;\n n = parentN;\n }\n }\n};\n\n/**\n * @method bubbleDown\n * @param {array} heap The heap.\n * @param {function} weightFunc The weight function.\n * @param {number} n The index of the element to sink down.\n */\nvar bubbleDown = function bubbleDown(heap, weightFunc, n) {\n var length = heap.length;\n var node = heap[n];\n var nodeWeight = weightFunc(node);\n\n while (true) {\n var child2N = (n + 1) * 2;\n var child1N = child2N - 1;\n var swap = null;\n if (child1N < length) {\n var child1 = heap[child1N];\n var child1Weight = weightFunc(child1);\n // If the score is less than our node's, we need to swap.\n if (child1Weight < nodeWeight) {\n swap = child1N;\n }\n }\n // Do the same checks for the other child.\n if (child2N < length) {\n var child2 = heap[child2N];\n var child2Weight = weightFunc(child2);\n if (child2Weight < (swap === null ? nodeWeight : weightFunc(heap[child1N]))) {\n swap = child2N;\n }\n }\n\n if (swap === null) {\n break;\n } else {\n heap[n] = heap[swap];\n heap[swap] = node;\n n = swap;\n }\n }\n};\n\nfunction BinaryHeap(weightFunc, compareFunc) {\n if (!weightFunc) {\n weightFunc = function weightFunc(x) {\n return x;\n };\n }\n if (!compareFunc) {\n compareFunc = function compareFunc(x, y) {\n return x === y;\n };\n }\n if (typeof weightFunc !== 'function') {\n throw new Error('BinaryHeap([weightFunc][, compareFunc]): \"weightFunc\" must be a function!');\n }\n if (typeof compareFunc !== 'function') {\n throw new Error('BinaryHeap([weightFunc][, compareFunc]): \"compareFunc\" must be a function!');\n }\n this.weightFunc = weightFunc;\n this.compareFunc = compareFunc;\n this.heap = [];\n}\n\nvar BHProto = BinaryHeap.prototype;\n\nBHProto.push = function (node) {\n this.heap.push(node);\n bubbleUp(this.heap, this.weightFunc, this.heap.length - 1);\n};\n\nBHProto.peek = function () {\n return this.heap[0];\n};\n\nBHProto.pop = function () {\n var front = this.heap[0];\n var end = this.heap.pop();\n if (this.heap.length > 0) {\n this.heap[0] = end;\n bubbleDown(this.heap, this.weightFunc, 0);\n }\n return front;\n};\n\nBHProto.remove = function (node) {\n var length = this.heap.length;\n for (var i = 0; i < length; i++) {\n if (this.compareFunc(this.heap[i], node)) {\n var removed = this.heap[i];\n var end = this.heap.pop();\n if (i !== length - 1) {\n this.heap[i] = end;\n bubbleUp(this.heap, this.weightFunc, i);\n bubbleDown(this.heap, this.weightFunc, i);\n }\n return removed;\n }\n }\n return null;\n};\n\nBHProto.removeAll = function () {\n this.heap = [];\n};\n\nBHProto.size = function () {\n return this.heap.length;\n};\n\nvar _Promise = null;\ntry {\n _Promise = window.Promise;\n} catch (e) {}\n\nvar utils = {\n isNumber: function isNumber(value) {\n return typeof value === 'number';\n },\n isString: function isString(value) {\n return typeof value === 'string';\n },\n isObject: function isObject(value) {\n return value !== null && (typeof value === 'undefined' ? 'undefined' : babelHelpers.typeof(value)) === 'object';\n },\n isFunction: function isFunction(value) {\n return typeof value === 'function';\n },\n fromJson: function fromJson(value) {\n return JSON.parse(value);\n },\n equals: function equals(a, b) {\n return a === b;\n },\n\n\n Promise: _Promise\n};\n\nfunction _keys(collection) {\n var keys = [];\n var key = void 0;\n if (!utils.isObject(collection)) {\n return keys;\n }\n for (key in collection) {\n if (collection.hasOwnProperty(key)) {\n keys.push(key);\n }\n }\n return keys;\n}\n\nfunction _isPromiseLike(value) {\n return value && typeof value.then === 'function';\n}\n\nfunction _stringifyNumber(number) {\n if (utils.isNumber(number)) {\n return number.toString();\n }\n return number;\n}\n\nfunction _keySet(collection) {\n var keySet = {};\n var key = void 0;\n if (!utils.isObject(collection)) {\n return keySet;\n }\n for (key in collection) {\n if (collection.hasOwnProperty(key)) {\n keySet[key] = key;\n }\n }\n return keySet;\n}\n\nvar defaults = {\n capacity: Number.MAX_VALUE,\n maxAge: Number.MAX_VALUE,\n deleteOnExpire: 'none',\n onExpire: null,\n cacheFlushInterval: null,\n recycleFreq: 1000,\n storageMode: 'memory',\n storageImpl: null,\n disabled: false,\n storagePrefix: 'cachefactory.caches.',\n storeOnResolve: false,\n storeOnReject: false\n};\n\nvar caches = {};\n\nfunction createCache(cacheId, options) {\n if (cacheId in caches) {\n throw new Error(cacheId + ' already exists!');\n } else if (!utils.isString(cacheId)) {\n throw new Error('cacheId must be a string!');\n }\n\n var $$data = {};\n var $$promises = {};\n var $$storage = null;\n var $$expiresHeap = new BinaryHeap(function (x) {\n return x.expires;\n }, utils.equals);\n var $$lruHeap = new BinaryHeap(function (x) {\n return x.accessed;\n }, utils.equals);\n\n var cache = caches[cacheId] = {\n\n $$id: cacheId,\n\n destroy: function destroy() {\n clearInterval(this.$$cacheFlushIntervalId);\n clearInterval(this.$$recycleFreqId);\n this.removeAll();\n if ($$storage) {\n $$storage().removeItem(this.$$prefix + '.keys');\n $$storage().removeItem(this.$$prefix);\n }\n $$storage = null;\n $$data = null;\n $$lruHeap = null;\n $$expiresHeap = null;\n this.$$prefix = null;\n delete caches[this.$$id];\n },\n disable: function disable() {\n this.$$disabled = true;\n },\n enable: function enable() {\n delete this.$$disabled;\n },\n get: function get(key, options) {\n var _this2 = this;\n\n if (Array.isArray(key)) {\n var _ret = function () {\n var keys = key;\n var values = [];\n\n keys.forEach(function (key) {\n var value = _this2.get(key, options);\n if (value !== null && value !== undefined) {\n values.push(value);\n }\n });\n\n return {\n v: values\n };\n }();\n\n if ((typeof _ret === 'undefined' ? 'undefined' : babelHelpers.typeof(_ret)) === \"object\") return _ret.v;\n } else {\n key = _stringifyNumber(key);\n\n if (this.$$disabled) {\n return;\n }\n }\n\n options = options || {};\n if (!utils.isString(key)) {\n throw new Error('key must be a string!');\n } else if (options && !utils.isObject(options)) {\n throw new Error('options must be an object!');\n } else if (options.onExpire && !utils.isFunction(options.onExpire)) {\n throw new Error('options.onExpire must be a function!');\n }\n\n var item = void 0;\n\n if ($$storage) {\n if ($$promises[key]) {\n return $$promises[key];\n }\n\n var itemJson = $$storage().getItem(this.$$prefix + '.data.' + key);\n\n if (itemJson) {\n item = utils.fromJson(itemJson);\n } else {\n return;\n }\n } else if (utils.isObject($$data)) {\n if (!(key in $$data)) {\n return;\n }\n\n item = $$data[key];\n }\n\n var value = item.value;\n var now = new Date().getTime();\n\n if ($$storage) {\n $$lruHeap.remove({\n key: key,\n accessed: item.accessed\n });\n item.accessed = now;\n $$lruHeap.push({\n key: key,\n accessed: now\n });\n } else {\n $$lruHeap.remove(item);\n item.accessed = now;\n $$lruHeap.push(item);\n }\n\n if (this.$$deleteOnExpire === 'passive' && 'expires' in item && item.expires < now) {\n this.remove(key);\n\n if (this.$$onExpire) {\n this.$$onExpire(key, item.value, options.onExpire);\n } else if (options.onExpire) {\n options.onExpire.call(this, key, item.value);\n }\n value = undefined;\n } else if ($$storage) {\n $$storage().setItem(this.$$prefix + '.data.' + key, JSON.stringify(item));\n }\n\n return value;\n },\n info: function info(key) {\n if (key) {\n var item = void 0;\n if ($$storage) {\n var itemJson = $$storage().getItem(this.$$prefix + '.data.' + key);\n\n if (itemJson) {\n item = utils.fromJson(itemJson);\n return {\n created: item.created,\n accessed: item.accessed,\n expires: item.expires,\n isExpired: new Date().getTime() - item.created > (item.maxAge || this.$$maxAge)\n };\n } else {\n return undefined;\n }\n } else if (utils.isObject($$data) && key in $$data) {\n item = $$data[key];\n\n return {\n created: item.created,\n accessed: item.accessed,\n expires: item.expires,\n isExpired: new Date().getTime() - item.created > (item.maxAge || this.$$maxAge)\n };\n } else {\n return undefined;\n }\n } else {\n return {\n id: this.$$id,\n capacity: this.$$capacity,\n maxAge: this.$$maxAge,\n deleteOnExpire: this.$$deleteOnExpire,\n onExpire: this.$$onExpire,\n cacheFlushInterval: this.$$cacheFlushInterval,\n recycleFreq: this.$$recycleFreq,\n storageMode: this.$$storageMode,\n storageImpl: $$storage ? $$storage() : undefined,\n disabled: !!this.$$disabled,\n size: $$lruHeap && $$lruHeap.size() || 0\n };\n }\n },\n keys: function keys() {\n if ($$storage) {\n var keysJson = $$storage().getItem(this.$$prefix + '.keys');\n\n if (keysJson) {\n return utils.fromJson(keysJson);\n } else {\n return [];\n }\n } else {\n return _keys($$data);\n }\n },\n keySet: function keySet() {\n if ($$storage) {\n var keysJson = $$storage().getItem(this.$$prefix + '.keys');\n var kSet = {};\n\n if (keysJson) {\n var keys = utils.fromJson(keysJson);\n\n for (var i = 0; i < keys.length; i++) {\n kSet[keys[i]] = keys[i];\n }\n }\n return kSet;\n } else {\n return _keySet($$data);\n }\n },\n put: function put(key, value, options) {\n var _this3 = this;\n\n options || (options = {});\n\n var storeOnResolve = 'storeOnResolve' in options ? !!options.storeOnResolve : this.$$storeOnResolve;\n var storeOnReject = 'storeOnReject' in options ? !!options.storeOnReject : this.$$storeOnReject;\n\n var getHandler = function getHandler(store, isError) {\n return function (v) {\n if (store) {\n delete $$promises[key];\n if (utils.isObject(v) && 'status' in v && 'data' in v) {\n v = [v.status, v.data, v.headers(), v.statusText];\n _this3.put(key, v);\n } else {\n _this3.put(key, v);\n }\n }\n if (isError) {\n if (utils.Promise) {\n return utils.Promise.reject(v);\n } else {\n throw v;\n }\n } else {\n return v;\n }\n };\n };\n\n if (this.$$disabled || !utils.isObject($$data) || value === null || value === undefined) {\n return;\n }\n key = _stringifyNumber(key);\n\n if (!utils.isString(key)) {\n throw new Error('key must be a string!');\n }\n\n var now = new Date().getTime();\n var item = {\n key: key,\n value: _isPromiseLike(value) ? value.then(getHandler(storeOnResolve, false), getHandler(storeOnReject, true)) : value,\n created: options.created === undefined ? now : options.created,\n accessed: options.accessed === undefined ? now : options.accessed\n };\n if (options.maxAge) {\n item.maxAge = options.maxAge;\n }\n\n if (options.expires === undefined) {\n item.expires = item.created + (item.maxAge || this.$$maxAge);\n } else {\n item.expires = options.expires;\n }\n\n if ($$storage) {\n if (_isPromiseLike(item.value)) {\n $$promises[key] = item.value;\n return $$promises[key];\n }\n var keysJson = $$storage().getItem(this.$$prefix + '.keys');\n var keys = keysJson ? utils.fromJson(keysJson) : [];\n var itemJson = $$storage().getItem(this.$$prefix + '.data.' + key);\n\n // Remove existing\n if (itemJson) {\n this.remove(key);\n }\n // Add to expires heap\n $$expiresHeap.push({\n key: key,\n expires: item.expires\n });\n // Add to lru heap\n $$lruHeap.push({\n key: key,\n accessed: item.accessed\n });\n // Set item\n $$storage().setItem(this.$$prefix + '.data.' + key, JSON.stringify(item));\n var exists = false;\n for (var i = 0; i < keys.length; i++) {\n if (keys[i] === key) {\n exists = true;\n break;\n }\n }\n if (!exists) {\n keys.push(key);\n }\n $$storage().setItem(this.$$prefix + '.keys', JSON.stringify(keys));\n } else {\n // Remove existing\n if ($$data[key]) {\n this.remove(key);\n }\n // Add to expires heap\n $$expiresHeap.push(item);\n // Add to lru heap\n $$lruHeap.push(item);\n // Set item\n $$data[key] = item;\n delete $$promises[key];\n }\n\n // Handle exceeded capacity\n if ($$lruHeap.size() > this.$$capacity) {\n this.remove($$lruHeap.peek().key);\n }\n\n return value;\n },\n remove: function remove(key) {\n key += '';\n delete $$promises[key];\n if ($$storage) {\n var itemJson = $$storage().getItem(this.$$prefix + '.data.' + key);\n\n if (itemJson) {\n var item = utils.fromJson(itemJson);\n $$lruHeap.remove({\n key: key,\n accessed: item.accessed\n });\n $$expiresHeap.remove({\n key: key,\n expires: item.expires\n });\n $$storage().removeItem(this.$$prefix + '.data.' + key);\n var keysJson = $$storage().getItem(this.$$prefix + '.keys');\n var keys = keysJson ? utils.fromJson(keysJson) : [];\n var index = keys.indexOf(key);\n\n if (index >= 0) {\n keys.splice(index, 1);\n }\n $$storage().setItem(this.$$prefix + '.keys', JSON.stringify(keys));\n return item.value;\n }\n } else if (utils.isObject($$data)) {\n var value = $$data[key] ? $$data[key].value : undefined;\n $$lruHeap.remove($$data[key]);\n $$expiresHeap.remove($$data[key]);\n $$data[key] = null;\n delete $$data[key];\n return value;\n }\n },\n removeAll: function removeAll() {\n if ($$storage) {\n $$lruHeap.removeAll();\n $$expiresHeap.removeAll();\n var keysJson = $$storage().getItem(this.$$prefix + '.keys');\n\n if (keysJson) {\n var keys = utils.fromJson(keysJson);\n\n for (var i = 0; i < keys.length; i++) {\n this.remove(keys[i]);\n }\n }\n $$storage().setItem(this.$$prefix + '.keys', JSON.stringify([]));\n } else if (utils.isObject($$data)) {\n $$lruHeap.removeAll();\n $$expiresHeap.removeAll();\n for (var key in $$data) {\n $$data[key] = null;\n }\n $$data = {};\n } else {\n $$lruHeap.removeAll();\n $$expiresHeap.removeAll();\n $$data = {};\n }\n $$promises = {};\n },\n removeExpired: function removeExpired() {\n var now = new Date().getTime();\n var expired = {};\n var key = void 0;\n var expiredItem = void 0;\n\n while ((expiredItem = $$expiresHeap.peek()) && expiredItem.expires <= now) {\n expired[expiredItem.key] = expiredItem.value ? expiredItem.value : null;\n $$expiresHeap.pop();\n }\n\n if ($$storage) {\n for (key in expired) {\n var itemJson = $$storage().getItem(this.$$prefix + '.data.' + key);\n if (itemJson) {\n expired[key] = utils.fromJson(itemJson).value;\n this.remove(key);\n }\n }\n } else {\n for (key in expired) {\n this.remove(key);\n }\n }\n\n if (this.$$onExpire) {\n for (key in expired) {\n this.$$onExpire(key, expired[key]);\n }\n }\n\n return expired;\n },\n setCacheFlushInterval: function setCacheFlushInterval(cacheFlushInterval) {\n var _this = this;\n if (cacheFlushInterval === null) {\n delete _this.$$cacheFlushInterval;\n } else if (!utils.isNumber(cacheFlushInterval)) {\n throw new Error('cacheFlushInterval must be a number!');\n } else if (cacheFlushInterval < 0) {\n throw new Error('cacheFlushInterval must be greater than zero!');\n } else if (cacheFlushInterval !== _this.$$cacheFlushInterval) {\n _this.$$cacheFlushInterval = cacheFlushInterval;\n\n clearInterval(_this.$$cacheFlushIntervalId); // eslint-disable-line\n\n _this.$$cacheFlushIntervalId = setInterval(function () {\n _this.removeAll();\n }, _this.$$cacheFlushInterval);\n }\n },\n setCapacity: function setCapacity(capacity) {\n if (capacity === null) {\n delete this.$$capacity;\n } else if (!utils.isNumber(capacity)) {\n throw new Error('capacity must be a number!');\n } else if (capacity < 0) {\n throw new Error('capacity must be greater than zero!');\n } else {\n this.$$capacity = capacity;\n }\n var removed = {};\n while ($$lruHeap.size() > this.$$capacity) {\n removed[$$lruHeap.peek().key] = this.remove($$lruHeap.peek().key);\n }\n return removed;\n },\n setDeleteOnExpire: function setDeleteOnExpire(deleteOnExpire, setRecycleFreq) {\n if (deleteOnExpire === null) {\n delete this.$$deleteOnExpire;\n } else if (!utils.isString(deleteOnExpire)) {\n throw new Error('deleteOnExpire must be a string!');\n } else if (deleteOnExpire !== 'none' && deleteOnExpire !== 'passive' && deleteOnExpire !== 'aggressive') {\n throw new Error('deleteOnExpire must be \"none\", \"passive\" or \"aggressive\"!');\n } else {\n this.$$deleteOnExpire = deleteOnExpire;\n }\n if (setRecycleFreq !== false) {\n this.setRecycleFreq(this.$$recycleFreq);\n }\n },\n setMaxAge: function setMaxAge(maxAge) {\n if (maxAge === null) {\n this.$$maxAge = Number.MAX_VALUE;\n } else if (!utils.isNumber(maxAge)) {\n throw new Error('maxAge must be a number!');\n } else if (maxAge < 0) {\n throw new Error('maxAge must be greater than zero!');\n } else {\n this.$$maxAge = maxAge;\n }\n var i = void 0,\n keys = void 0,\n key = void 0;\n\n $$expiresHeap.removeAll();\n\n if ($$storage) {\n var keysJson = $$storage().getItem(this.$$prefix + '.keys');\n\n keys = keysJson ? utils.fromJson(keysJson) : [];\n\n for (i = 0; i < keys.length; i++) {\n key = keys[i];\n var itemJson = $$storage().getItem(this.$$prefix + '.data.' + key);\n\n if (itemJson) {\n var item = utils.fromJson(itemJson);\n if (this.$$maxAge === Number.MAX_VALUE) {\n item.expires = Number.MAX_VALUE;\n } else {\n item.expires = item.created + (item.maxAge || this.$$maxAge);\n }\n $$expiresHeap.push({\n key: key,\n expires: item.expires\n });\n }\n }\n } else {\n keys = _keys($$data);\n\n for (i = 0; i < keys.length; i++) {\n key = keys[i];\n if (this.$$maxAge === Number.MAX_VALUE) {\n $$data[key].expires = Number.MAX_VALUE;\n } else {\n $$data[key].expires = $$data[key].created + ($$data[key].maxAge || this.$$maxAge);\n }\n $$expiresHeap.push($$data[key]);\n }\n }\n if (this.$$deleteOnExpire === 'aggressive') {\n return this.removeExpired();\n } else {\n return {};\n }\n },\n setOnExpire: function setOnExpire(onExpire) {\n if (onExpire === null) {\n delete this.$$onExpire;\n } else if (!utils.isFunction(onExpire)) {\n throw new Error('onExpire must be a function!');\n } else {\n this.$$onExpire = onExpire;\n }\n },\n setOptions: function setOptions(cacheOptions, strict) {\n cacheOptions = cacheOptions || {};\n strict = !!strict;\n if (!utils.isObject(cacheOptions)) {\n throw new Error('cacheOptions must be an object!');\n }\n\n if ('storagePrefix' in cacheOptions) {\n this.$$storagePrefix = cacheOptions.storagePrefix;\n } else if (strict) {\n this.$$storagePrefix = defaults.storagePrefix;\n }\n\n this.$$prefix = this.$$storagePrefix + this.$$id;\n\n if ('disabled' in cacheOptions) {\n this.$$disabled = !!cacheOptions.disabled;\n } else if (strict) {\n this.$$disabled = defaults.disabled;\n }\n\n if ('deleteOnExpire' in cacheOptions) {\n this.setDeleteOnExpire(cacheOptions.deleteOnExpire, false);\n } else if (strict) {\n this.setDeleteOnExpire(defaults.deleteOnExpire, false);\n }\n\n if ('recycleFreq' in cacheOptions) {\n this.setRecycleFreq(cacheOptions.recycleFreq);\n } else if (strict) {\n this.setRecycleFreq(defaults.recycleFreq);\n }\n\n if ('maxAge' in cacheOptions) {\n this.setMaxAge(cacheOptions.maxAge);\n } else if (strict) {\n this.setMaxAge(defaults.maxAge);\n }\n\n if ('storeOnResolve' in cacheOptions) {\n this.$$storeOnResolve = !!cacheOptions.storeOnResolve;\n } else if (strict) {\n this.$$storeOnResolve = defaults.storeOnResolve;\n }\n\n if ('storeOnReject' in cacheOptions) {\n this.$$storeOnReject = !!cacheOptions.storeOnReject;\n } else if (strict) {\n this.$$storeOnReject = defaults.storeOnReject;\n }\n\n if ('capacity' in cacheOptions) {\n this.setCapacity(cacheOptions.capacity);\n } else if (strict) {\n this.setCapacity(defaults.capacity);\n }\n\n if ('cacheFlushInterval' in cacheOptions) {\n this.setCacheFlushInterval(cacheOptions.cacheFlushInterval);\n } else if (strict) {\n this.setCacheFlushInterval(defaults.cacheFlushInterval);\n }\n\n if ('onExpire' in cacheOptions) {\n this.setOnExpire(cacheOptions.onExpire);\n } else if (strict) {\n this.setOnExpire(defaults.onExpire);\n }\n\n if ('storageMode' in cacheOptions || 'storageImpl' in cacheOptions) {\n this.setStorageMode(cacheOptions.storageMode || defaults.storageMode, cacheOptions.storageImpl || defaults.storageImpl);\n } else if (strict) {\n this.setStorageMode(defaults.storageMode, defaults.storageImpl);\n }\n },\n setRecycleFreq: function setRecycleFreq(recycleFreq) {\n if (recycleFreq === null) {\n delete this.$$recycleFreq;\n } else if (!utils.isNumber(recycleFreq)) {\n throw new Error('recycleFreq must be a number!');\n } else if (recycleFreq < 0) {\n throw new Error('recycleFreq must be greater than zero!');\n } else {\n this.$$recycleFreq = recycleFreq;\n }\n clearInterval(this.$$recycleFreqId);\n if (this.$$deleteOnExpire === 'aggressive') {\n (function (self) {\n self.$$recycleFreqId = setInterval(function () {\n self.removeExpired();\n }, self.$$recycleFreq);\n })(this);\n } else {\n delete this.$$recycleFreqId;\n }\n },\n setStorageMode: function setStorageMode(storageMode, storageImpl) {\n if (!utils.isString(storageMode)) {\n throw new Error('storageMode must be a string!');\n } else if (storageMode !== 'memory' && storageMode !== 'localStorage' && storageMode !== 'sessionStorage') {\n throw new Error('storageMode must be \"memory\", \"localStorage\" or \"sessionStorage\"!');\n }\n\n var prevStorage = $$storage;\n var prevData = $$data;\n var shouldReInsert = false;\n var items = {};\n\n function load(prevStorage, prevData) {\n var keys = this.keys();\n var length = keys.length;\n if (length) {\n var _key = void 0;\n var prevDataIsObject = utils.isObject(prevData);\n for (var i = 0; i < length; i++) {\n _key = keys[i];\n if (prevStorage) {\n var itemJson = prevStorage().getItem(this.$$prefix + '.data.' + _key);\n if (itemJson) {\n items[_key] = utils.fromJson(itemJson);\n }\n } else if (prevDataIsObject) {\n items[_key] = prevData[_key];\n }\n this.remove(_key);\n }\n shouldReInsert = true;\n }\n }\n\n if (!this.$$initializing) {\n load.call(this, prevStorage, prevData);\n }\n\n this.$$storageMode = storageMode;\n\n if (storageImpl) {\n if (!utils.isObject(storageImpl)) {\n throw new Error('storageImpl must be an object!');\n } else if (!('setItem' in storageImpl) || typeof storageImpl.setItem !== 'function') {\n throw new Error('storageImpl must implement \"setItem(key, value)\"!');\n } else if (!('getItem' in storageImpl) || typeof storageImpl.getItem !== 'function') {\n throw new Error('storageImpl must implement \"getItem(key)\"!');\n } else if (!('removeItem' in storageImpl) || typeof storageImpl.removeItem !== 'function') {\n throw new Error('storageImpl must implement \"removeItem(key)\"!');\n }\n $$storage = function $$storage() {\n return storageImpl;\n };\n } else if (this.$$storageMode === 'localStorage') {\n try {\n localStorage.setItem('cachefactory', 'cachefactory');\n localStorage.removeItem('cachefactory');\n $$storage = function $$storage() {\n return localStorage;\n };\n } catch (e) {\n $$storage = null;\n this.$$storageMode = 'memory';\n }\n } else if (this.$$storageMode === 'sessionStorage') {\n try {\n sessionStorage.setItem('cachefactory', 'cachefactory');\n sessionStorage.removeItem('cachefactory');\n $$storage = function $$storage() {\n return sessionStorage;\n };\n } catch (e) {\n $$storage = null;\n this.$$storageMode = 'memory';\n }\n } else {\n $$storage = null;\n this.$$storageMode = 'memory';\n }\n\n if (this.$$initializing) {\n load.call(this, $$storage, $$data);\n }\n\n if (shouldReInsert) {\n var item = void 0;\n for (var key in items) {\n item = items[key];\n this.put(key, item.value, {\n created: item.created,\n accessed: item.accessed,\n expires: item.expires\n });\n }\n }\n },\n touch: function touch(key, options) {\n var _this4 = this;\n\n if (key) {\n var val = this.get(key, {\n onExpire: function onExpire(k, v) {\n return _this4.put(k, v);\n }\n });\n if (val) {\n this.put(key, val, options);\n }\n } else {\n var keys = this.keys();\n for (var i = 0; i < keys.length; i++) {\n this.touch(keys[i], options);\n }\n }\n },\n values: function values() {\n var keys = this.keys();\n var items = [];\n for (var i = 0; i < keys.length; i++) {\n items.push(this.get(keys[i]));\n }\n return items;\n }\n };\n\n cache.$$initializing = true;\n cache.setOptions(options, true);\n cache.$$initializing = false;\n\n return cache;\n}\n\nfunction CacheFactory(cacheId, options) {\n return createCache(cacheId, options);\n}\n\nCacheFactory.createCache = createCache;\nCacheFactory.defaults = defaults;\n\nCacheFactory.info = function () {\n var keys = _keys(caches);\n var info = {\n size: keys.length,\n caches: {}\n };\n for (var opt in defaults) {\n if (defaults.hasOwnProperty(opt)) {\n info[opt] = defaults[opt];\n }\n }\n for (var i = 0; i < keys.length; i++) {\n var key = keys[i];\n info.caches[key] = caches[key].info();\n }\n return info;\n};\n\nCacheFactory.get = function (cacheId) {\n return caches[cacheId];\n};\nCacheFactory.keySet = function () {\n return _keySet(caches);\n};\nCacheFactory.keys = function () {\n return _keys(caches);\n};\nCacheFactory.destroy = function (cacheId) {\n if (caches[cacheId]) {\n caches[cacheId].destroy();\n delete caches[cacheId];\n }\n};\nCacheFactory.destroyAll = function () {\n for (var cacheId in caches) {\n caches[cacheId].destroy();\n }\n caches = {};\n};\nCacheFactory.clearAll = function () {\n for (var cacheId in caches) {\n caches[cacheId].removeAll();\n }\n};\nCacheFactory.removeExpiredFromAll = function () {\n var expired = {};\n for (var cacheId in caches) {\n expired[cacheId] = caches[cacheId].removeExpired();\n }\n return expired;\n};\nCacheFactory.enableAll = function () {\n for (var cacheId in caches) {\n caches[cacheId].$$disabled = false;\n }\n};\nCacheFactory.disableAll = function () {\n for (var cacheId in caches) {\n caches[cacheId].$$disabled = true;\n }\n};\nCacheFactory.touchAll = function () {\n for (var cacheId in caches) {\n caches[cacheId].touch();\n }\n};\n\nCacheFactory.utils = utils;\nCacheFactory.BinaryHeap = BinaryHeap;\n\nexport default CacheFactory;\n//# sourceMappingURL=cachefactory.es2015.js.map","import angular from 'angular'\nimport CacheFactory from '../node_modules/cachefactory/dist/cachefactory.es2015'\n\nCacheFactory.utils.equals = angular.equals\nCacheFactory.utils.isObject = angular.isObject\nCacheFactory.utils.fromJson = angular.fromJson\n\nfunction BinaryHeapProvider () {\n this.$get = function () { return CacheFactory.BinaryHeap }\n}\n\nfunction CacheFactoryProvider () {\n this.defaults = CacheFactory.defaults\n this.defaults.storagePrefix = 'angular-cache.caches.'\n\n this.$get = ['$q', function ($q) {\n CacheFactory.utils.Promise = $q\n return CacheFactory\n }]\n}\n\nangular.module('angular-cache', [])\n .provider('BinaryHeap', BinaryHeapProvider)\n .provider('CacheFactory', CacheFactoryProvider)\n\nexport default 'angular-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S,kBAAT,GAA+B;AAC7B,EAAA,OAAK,IAAL,GAAY,YAAY;AAAE,EAAA,WAAO,aAAa,UAApB;AAAgC,EAAA,GAA1D;AACD,EAAA;;AAED,EAAA,SAAS,oBAAT,GAAiC;AAC/B,EAAA,OAAK,QAAL,GAAgB,aAAa,QAA7B;AACA,EAAA,OAAK,QAAL,CAAc,aAAd,GAA8B,uBAA9B;;AAEA,EAAA,OAAK,IAAL,GAAY,CAAC,IAAD,EAAO,UAAU,EAAV,EAAc;AAC/B,EAAA,iBAAa,KAAb,CAAmB,OAAnB,GAA6B,EAA7B;AACA,EAAA,WAAO,YAAP;AACD,EAAA,GAHW,CAAZ;AAID,EAAA;;AAED,EAAA,QAAQ,MAAR,CAAe,eAAf,EAAgC,EAAhC,EACG,QADH,CACY,YADZ,EAC0B,kBAD1B,EAEG,QAFH,CAEY,cAFZ,EAE4B,oBAF5B;;AAIA,cAAe,eAAf;;;;"} \ No newline at end of file diff --git a/dist/angular-cache.min.js b/dist/angular-cache.min.js index e92be36..ae78ddc 100644 --- a/dist/angular-cache.min.js +++ b/dist/angular-cache.min.js @@ -1,2 +1,2 @@ -!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("angular")):"function"==typeof define&&define.amd?define("angular-cache",["angular"],t):"object"==typeof exports?exports.angularCacheModuleName=t(require("angular")):e.angularCacheModuleName=t(e.angular)}(this,function(e){return function(e){function t(i){if(r[i])return r[i].exports;var n=r[i]={exports:{},id:i,loaded:!1};return e[i].call(n.exports,n,n.exports,t),n.loaded=!0,n.exports}var r={};return t.m=e,t.c=r,t.p="",t(0)}([function(e,t,r){"use strict";function i(){this.$get=function(){return o.BinaryHeap}}function n(){this.defaults=o.defaults,this.defaults.storagePrefix="angular-cache.caches.",this.$get=["$q",function(e){return o.utils.Promise=e,o}]}var s=r(1),o=r(2);o.utils.equals=s.equals,o.utils.isObject=s.isObject,o.utils.fromJson=s.fromJson,s.module("angular-cache",[]).provider("BinaryHeap",i).provider("CacheFactory",n),e.exports="angular-cache";try{e.exports.name="angular-cache"}catch(a){}},function(t,r){t.exports=e},function(e,t,r){!function(t,r){e.exports=r()}(this,function(){return function(e){function t(i){if(r[i])return r[i].exports;var n=r[i]={exports:{},id:i,loaded:!1};return e[i].call(n.exports,n,n.exports,t),n.loaded=!0,n.exports}var r={};return t.m=e,t.c=r,t.p="",t(0)}([function(e,t,r){"use strict";function i(e){var t=[],r=void 0;if(!p.isObject(e))return t;for(r in e)e.hasOwnProperty(r)&&t.push(r);return t}function n(e){return e&&"function"==typeof e.then}function s(e){return p.isNumber(e)?e.toString():e}function o(e){var t={},r=void 0;if(!p.isObject(e))return t;for(r in e)e.hasOwnProperty(r)&&(t[r]=r);return t}function a(e,t){if(e in d)throw new Error(e+" already exists!");if(!p.isString(e))throw new Error("cacheId must be a string!");var r={},a={},c=null,h=new l(function(e){return e.expires},p.equals),f=new l(function(e){return e.accessed},p.equals),$=d[e]={$$id:e,destroy:function(){clearInterval(this.$$cacheFlushIntervalId),clearInterval(this.$$recycleFreqId),this.removeAll(),c&&(c().removeItem(this.$$prefix+".keys"),c().removeItem(this.$$prefix)),c=null,r=null,f=null,h=null,this.$$prefix=null,delete d[this.$$id]},disable:function(){this.$$disabled=!0},enable:function(){delete this.$$disabled},get:function(e,t){var i=this;if(Array.isArray(e)){var n=function(){var r=e,n=[];return r.forEach(function(e){var r=i.get(e,t);null!==r&&void 0!==r&&n.push(r)}),{v:n}}();if("object"===("undefined"==typeof n?"undefined":u(n)))return n.v}else if(e=s(e),this.$$disabled)return;if(t=t||{},!p.isString(e))throw new Error("key must be a string!");if(t&&!p.isObject(t))throw new Error("options must be an object!");if(t.onExpire&&!p.isFunction(t.onExpire))throw new Error("options.onExpire must be a function!");var o=void 0;if(c){if(a[e])return a[e];var l=c().getItem(this.$$prefix+".data."+e);if(!l)return;o=p.fromJson(l)}else if(p.isObject(r)){if(!(e in r))return;o=r[e]}var h=o.value,m=(new Date).getTime();return c?(f.remove({key:e,accessed:o.accessed}),o.accessed=m,f.push({key:e,accessed:m})):(f.remove(o),o.accessed=m,f.push(o)),"passive"===this.$$deleteOnExpire&&"expires"in o&&o.expires(t.maxAge||this.$$maxAge)}):void 0}return p.isObject(r)&&e in r?(t=r[e],{created:t.created,accessed:t.accessed,expires:t.expires,isExpired:(new Date).getTime()-t.created>(t.maxAge||this.$$maxAge)}):void 0}return{id:this.$$id,capacity:this.$$capacity,maxAge:this.$$maxAge,deleteOnExpire:this.$$deleteOnExpire,onExpire:this.$$onExpire,cacheFlushInterval:this.$$cacheFlushInterval,recycleFreq:this.$$recycleFreq,storageMode:this.$$storageMode,storageImpl:c?c():void 0,disabled:!!this.$$disabled,size:f&&f.size()||0}},keys:function(){if(c){var e=c().getItem(this.$$prefix+".keys");return e?p.fromJson(e):[]}return i(r)},keySet:function(){if(c){var e=c().getItem(this.$$prefix+".keys"),t={};if(e)for(var i=p.fromJson(e),n=0;nthis.$$capacity&&this.remove(f.peek().key),t}},remove:function(e){if(e+="",delete a[e],c){var t=c().getItem(this.$$prefix+".data."+e);if(t){var i=p.fromJson(t);f.remove({key:e,accessed:i.accessed}),h.remove({key:e,expires:i.expires}),c().removeItem(this.$$prefix+".data."+e);var n=c().getItem(this.$$prefix+".keys"),s=n?p.fromJson(n):[],o=s.indexOf(e);return o>=0&&s.splice(o,1),c().setItem(this.$$prefix+".keys",JSON.stringify(s)),i.value}}else if(p.isObject(r)){var u=r[e]?r[e].value:void 0;return f.remove(r[e]),h.remove(r[e]),r[e]=null,delete r[e],u}},removeAll:function(){if(c){f.removeAll(),h.removeAll();var e=c().getItem(this.$$prefix+".keys");if(e)for(var t=p.fromJson(e),i=0;ie)throw new Error("cacheFlushInterval must be greater than zero!");e!==t.$$cacheFlushInterval&&(t.$$cacheFlushInterval=e,clearInterval(t.$$cacheFlushIntervalId),t.$$cacheFlushIntervalId=setInterval(function(){t.removeAll()},t.$$cacheFlushInterval))}},setCapacity:function(e){if(null===e)delete this.$$capacity;else{if(!p.isNumber(e))throw new Error("capacity must be a number!");if(0>e)throw new Error("capacity must be greater than zero!");this.$$capacity=e}for(var t={};f.size()>this.$$capacity;)t[f.peek().key]=this.remove(f.peek().key);return t},setDeleteOnExpire:function(e,t){if(null===e)delete this.$$deleteOnExpire;else{if(!p.isString(e))throw new Error("deleteOnExpire must be a string!");if("none"!==e&&"passive"!==e&&"aggressive"!==e)throw new Error('deleteOnExpire must be "none", "passive" or "aggressive"!');this.$$deleteOnExpire=e}t!==!1&&this.setRecycleFreq(this.$$recycleFreq)},setMaxAge:function(e){if(null===e)this.$$maxAge=Number.MAX_VALUE;else{if(!p.isNumber(e))throw new Error("maxAge must be a number!");if(0>e)throw new Error("maxAge must be greater than zero!");this.$$maxAge=e}var t=void 0,n=void 0,s=void 0;if(h.removeAll(),c){var o=c().getItem(this.$$prefix+".keys");for(n=o?p.fromJson(o):[],t=0;te)throw new Error("recycleFreq must be greater than zero!");this.$$recycleFreq=e}clearInterval(this.$$recycleFreqId),"aggressive"===this.$$deleteOnExpire?!function(e){e.$$recycleFreqId=setInterval(function(){e.removeExpired()},e.$$recycleFreq)}(this):delete this.$$recycleFreqId},setStorageMode:function(e,t){function i(e,t){var r=this.keys(),i=r.length;if(i){for(var n=void 0,s=p.isObject(t),c=0;i>c;c++){if(n=r[c],e){var u=e().getItem(this.$$prefix+".data."+n);u&&(a[n]=p.fromJson(u))}else s&&(a[n]=t[n]);this.remove(n)}o=!0}}if(!p.isString(e))throw new Error("storageMode must be a string!");if("memory"!==e&&"localStorage"!==e&&"sessionStorage"!==e)throw new Error('storageMode must be "memory", "localStorage" or "sessionStorage"!');var n=c,s=r,o=!1,a={};if(this.$$initializing||i.call(this,n,s),this.$$storageMode=e,t){if(!p.isObject(t))throw new Error("storageImpl must be an object!");if(!("setItem"in t&&"function"==typeof t.setItem))throw new Error('storageImpl must implement "setItem(key, value)"!');if(!("getItem"in t&&"function"==typeof t.getItem))throw new Error('storageImpl must implement "getItem(key)"!');if(!("removeItem"in t)||"function"!=typeof t.removeItem)throw new Error('storageImpl must implement "removeItem(key)"!');c=function(){return t}}else if("localStorage"===this.$$storageMode)try{localStorage.setItem("cachefactory","cachefactory"),localStorage.removeItem("cachefactory"),c=function(){return localStorage}}catch(u){c=null,this.$$storageMode="memory"}else if("sessionStorage"===this.$$storageMode)try{sessionStorage.setItem("cachefactory","cachefactory"),sessionStorage.removeItem("cachefactory"),c=function(){return sessionStorage}}catch(u){c=null,this.$$storageMode="memory"}else c=null,this.$$storageModel="memory";if(this.$$initializing&&i.call(this,c,r),o){var l=void 0;for(var h in a)l=a[h],this.put(h,l.value,{created:l.created,accessed:l.accessed,expires:l.expires})}},touch:function(e){var t=this;if(e){var r=this.get(e,{onExpire:function(e,r){return t.put(e,r)}});r&&this.put(e,r)}else for(var i=this.keys(),n=0;n0;){var s=Math.floor((r+1)/2)-1,o=e[s];if(n>=t(o))break;e[s]=i,e[r]=o,r=s}}function n(e,t){if(e||(e=function(e){return e}),t||(t=function(e,t){return e===t}),"function"!=typeof e)throw new Error('BinaryHeap([weightFunc][, compareFunc]): "weightFunc" must be a function!');if("function"!=typeof t)throw new Error('BinaryHeap([weightFunc][, compareFunc]): "compareFunc" must be a function!');this.weightFunc=e,this.compareFunc=t,this.heap=[]}var s=function(e,t,r){for(var i=e.length,n=e[r],s=t(n);;){var o=2*(r+1),a=o-1,c=null;if(i>a){var u=e[a],l=t(u);s>l&&(c=a)}if(i>o){var h=e[o],f=t(h);f<(null===c?s:t(e[a]))&&(c=o)}if(null===c)break;e[r]=e[c],e[c]=n,r=c}},o=n.prototype;o.push=function(e){this.heap.push(e),i(this.heap,this.weightFunc,this.heap.length-1)},o.peek=function(){return this.heap[0]},o.pop=function(){var e=this.heap[0],t=this.heap.pop();return this.heap.length>0&&(this.heap[0]=t,s(this.heap,this.weightFunc,0)),e},o.remove=function(e){for(var t=this.heap.length,r=0;t>r;r++)if(this.compareFunc(this.heap[r],e)){var n=this.heap[r],o=this.heap.pop();return r!==t-1&&(this.heap[r]=o,i(this.heap,this.weightFunc,r),s(this.heap,this.weightFunc,r)),n}return null},o.removeAll=function(){this.heap=[]},o.size=function(){return this.heap.length},e.exports=n}])})}])})}])}); -//# sourceMappingURL=dist/angular-cache.min.map \ No newline at end of file +!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t("undefined"==typeof angular?require("angular"):angular):"function"==typeof define&&define.amd?define("angular-cache",["angular"],t):e.angularCacheModuleName=t(e.angular)}(this,function(e){"use strict";function t(e,t){if(e||(e=function(e){return e}),t||(t=function(e,t){return e===t}),"function"!=typeof e)throw new Error('BinaryHeap([weightFunc][, compareFunc]): "weightFunc" must be a function!');if("function"!=typeof t)throw new Error('BinaryHeap([weightFunc][, compareFunc]): "compareFunc" must be a function!');this.weightFunc=e,this.compareFunc=t,this.heap=[]}function r(e){var t=[],r=void 0;if(!d.isObject(e))return t;for(r in e)e.hasOwnProperty(r)&&t.push(r);return t}function i(e){return e&&"function"==typeof e.then}function s(e){return d.isNumber(e)?e.toString():e}function n(e){var t={},r=void 0;if(!d.isObject(e))return t;for(r in e)e.hasOwnProperty(r)&&(t[r]=r);return t}function o(e,o){if(e in g)throw new Error(e+" already exists!");if(!d.isString(e))throw new Error("cacheId must be a string!");var a={},c={},l=null,h=new t(function(e){return e.expires},d.equals),f=new t(function(e){return e.accessed},d.equals),p=g[e]={$$id:e,destroy:function(){clearInterval(this.$$cacheFlushIntervalId),clearInterval(this.$$recycleFreqId),this.removeAll(),l&&(l().removeItem(this.$$prefix+".keys"),l().removeItem(this.$$prefix)),l=null,a=null,f=null,h=null,this.$$prefix=null,delete g[this.$$id]},disable:function(){this.$$disabled=!0},enable:function(){delete this.$$disabled},get:function(e,t){var r=this;if(Array.isArray(e)){var i=function(){var i=e,s=[];return i.forEach(function(e){var i=r.get(e,t);null!==i&&void 0!==i&&s.push(i)}),{v:s}}();if("object"===("undefined"==typeof i?"undefined":u["typeof"](i)))return i.v}else if(e=s(e),this.$$disabled)return;if(t=t||{},!d.isString(e))throw new Error("key must be a string!");if(t&&!d.isObject(t))throw new Error("options must be an object!");if(t.onExpire&&!d.isFunction(t.onExpire))throw new Error("options.onExpire must be a function!");var n=void 0;if(l){if(c[e])return c[e];var o=l().getItem(this.$$prefix+".data."+e);if(!o)return;n=d.fromJson(o)}else if(d.isObject(a)){if(!(e in a))return;n=a[e]}var h=n.value,p=(new Date).getTime();return l?(f.remove({key:e,accessed:n.accessed}),n.accessed=p,f.push({key:e,accessed:p})):(f.remove(n),n.accessed=p,f.push(n)),"passive"===this.$$deleteOnExpire&&"expires"in n&&n.expires(t.maxAge||this.$$maxAge)}):void 0}return d.isObject(a)&&e in a?(t=a[e],{created:t.created,accessed:t.accessed,expires:t.expires,isExpired:(new Date).getTime()-t.created>(t.maxAge||this.$$maxAge)}):void 0}return{id:this.$$id,capacity:this.$$capacity,maxAge:this.$$maxAge,deleteOnExpire:this.$$deleteOnExpire,onExpire:this.$$onExpire,cacheFlushInterval:this.$$cacheFlushInterval,recycleFreq:this.$$recycleFreq,storageMode:this.$$storageMode,storageImpl:l?l():void 0,disabled:!!this.$$disabled,size:f&&f.size()||0}},keys:function(){if(l){var e=l().getItem(this.$$prefix+".keys");return e?d.fromJson(e):[]}return r(a)},keySet:function(){if(l){var e=l().getItem(this.$$prefix+".keys"),t={};if(e)for(var r=d.fromJson(e),i=0;ithis.$$capacity&&this.remove(f.peek().key),t}},remove:function(e){if(e+="",delete c[e],l){var t=l().getItem(this.$$prefix+".data."+e);if(t){var r=d.fromJson(t);f.remove({key:e,accessed:r.accessed}),h.remove({key:e,expires:r.expires}),l().removeItem(this.$$prefix+".data."+e);var i=l().getItem(this.$$prefix+".keys"),s=i?d.fromJson(i):[],n=s.indexOf(e);return n>=0&&s.splice(n,1),l().setItem(this.$$prefix+".keys",JSON.stringify(s)),r.value}}else if(d.isObject(a)){var o=a[e]?a[e].value:void 0;return f.remove(a[e]),h.remove(a[e]),a[e]=null,delete a[e],o}},removeAll:function(){if(l){f.removeAll(),h.removeAll();var e=l().getItem(this.$$prefix+".keys");if(e)for(var t=d.fromJson(e),r=0;re)throw new Error("cacheFlushInterval must be greater than zero!");e!==t.$$cacheFlushInterval&&(t.$$cacheFlushInterval=e,clearInterval(t.$$cacheFlushIntervalId),t.$$cacheFlushIntervalId=setInterval(function(){t.removeAll()},t.$$cacheFlushInterval))}},setCapacity:function(e){if(null===e)delete this.$$capacity;else{if(!d.isNumber(e))throw new Error("capacity must be a number!");if(0>e)throw new Error("capacity must be greater than zero!");this.$$capacity=e}for(var t={};f.size()>this.$$capacity;)t[f.peek().key]=this.remove(f.peek().key);return t},setDeleteOnExpire:function(e,t){if(null===e)delete this.$$deleteOnExpire;else{if(!d.isString(e))throw new Error("deleteOnExpire must be a string!");if("none"!==e&&"passive"!==e&&"aggressive"!==e)throw new Error('deleteOnExpire must be "none", "passive" or "aggressive"!');this.$$deleteOnExpire=e}t!==!1&&this.setRecycleFreq(this.$$recycleFreq)},setMaxAge:function(e){if(null===e)this.$$maxAge=Number.MAX_VALUE;else{if(!d.isNumber(e))throw new Error("maxAge must be a number!");if(0>e)throw new Error("maxAge must be greater than zero!");this.$$maxAge=e}var t=void 0,i=void 0,s=void 0;if(h.removeAll(),l){var n=l().getItem(this.$$prefix+".keys");for(i=n?d.fromJson(n):[],t=0;te)throw new Error("recycleFreq must be greater than zero!");this.$$recycleFreq=e}clearInterval(this.$$recycleFreqId),"aggressive"===this.$$deleteOnExpire?!function(e){e.$$recycleFreqId=setInterval(function(){e.removeExpired()},e.$$recycleFreq)}(this):delete this.$$recycleFreqId},setStorageMode:function(e,t){function r(e,t){var r=this.keys(),i=r.length;if(i){for(var s=void 0,a=d.isObject(t),c=0;i>c;c++){if(s=r[c],e){var l=e().getItem(this.$$prefix+".data."+s);l&&(o[s]=d.fromJson(l))}else a&&(o[s]=t[s]);this.remove(s)}n=!0}}if(!d.isString(e))throw new Error("storageMode must be a string!");if("memory"!==e&&"localStorage"!==e&&"sessionStorage"!==e)throw new Error('storageMode must be "memory", "localStorage" or "sessionStorage"!');var i=l,s=a,n=!1,o={};if(this.$$initializing||r.call(this,i,s),this.$$storageMode=e,t){if(!d.isObject(t))throw new Error("storageImpl must be an object!");if(!("setItem"in t&&"function"==typeof t.setItem))throw new Error('storageImpl must implement "setItem(key, value)"!');if(!("getItem"in t&&"function"==typeof t.getItem))throw new Error('storageImpl must implement "getItem(key)"!');if(!("removeItem"in t)||"function"!=typeof t.removeItem)throw new Error('storageImpl must implement "removeItem(key)"!');l=function(){return t}}else if("localStorage"===this.$$storageMode)try{localStorage.setItem("cachefactory","cachefactory"),localStorage.removeItem("cachefactory"),l=function(){return localStorage}}catch(c){l=null,this.$$storageMode="memory"}else if("sessionStorage"===this.$$storageMode)try{sessionStorage.setItem("cachefactory","cachefactory"),sessionStorage.removeItem("cachefactory"),l=function(){return sessionStorage}}catch(c){l=null,this.$$storageMode="memory"}else l=null,this.$$storageMode="memory";if(this.$$initializing&&r.call(this,l,a),n){var u=void 0;for(var h in o)u=o[h],this.put(h,u.value,{created:u.created,accessed:u.accessed,expires:u.expires})}},touch:function(e,t){var r=this;if(e){var i=this.get(e,{onExpire:function(e,t){return r.put(e,t)}});i&&this.put(e,i,t)}else for(var s=this.keys(),n=0;n0;){var n=Math.floor((r+1)/2)-1,o=e[n];if(s>=t(o))break;e[n]=i,e[r]=o,r=n}},f=function(e,t,r){for(var i=e.length,s=e[r],n=t(s);;){var o=2*(r+1),a=o-1,c=null;if(i>a){var l=e[a],u=t(l);n>u&&(c=a)}if(i>o){var h=e[o],f=t(h);f<(null===c?n:t(e[a]))&&(c=o)}if(null===c)break;e[r]=e[c],e[c]=s,r=c}},p=t.prototype;p.push=function(e){this.heap.push(e),h(this.heap,this.weightFunc,this.heap.length-1)},p.peek=function(){return this.heap[0]},p.pop=function(){var e=this.heap[0],t=this.heap.pop();return this.heap.length>0&&(this.heap[0]=t,f(this.heap,this.weightFunc,0)),e},p.remove=function(e){for(var t=this.heap.length,r=0;t>r;r++)if(this.compareFunc(this.heap[r],e)){var i=this.heap[r],s=this.heap.pop();return r!==t-1&&(this.heap[r]=s,h(this.heap,this.weightFunc,r),f(this.heap,this.weightFunc,r)),i}return null},p.removeAll=function(){this.heap=[]},p.size=function(){return this.heap.length};var m=null;try{m=window.Promise}catch($){}var d={isNumber:function(e){return"number"==typeof e},isString:function(e){return"string"==typeof e},isObject:function(e){return null!==e&&"object"===("undefined"==typeof e?"undefined":u["typeof"](e))},isFunction:function(e){return"function"==typeof e},fromJson:function(e){return JSON.parse(e)},equals:function(e,t){return e===t},Promise:m},v={capacity:Number.MAX_VALUE,maxAge:Number.MAX_VALUE,deleteOnExpire:"none",onExpire:null,cacheFlushInterval:null,recycleFreq:1e3,storageMode:"memory",storageImpl:null,disabled:!1,storagePrefix:"cachefactory.caches.",storeOnResolve:!1,storeOnReject:!1},g={};a.createCache=o,a.defaults=v,a.info=function(){var e=r(g),t={size:e.length,caches:{}};for(var i in v)v.hasOwnProperty(i)&&(t[i]=v[i]);for(var s=0;s=1.x" + "angular": ">=1.x <2" } } diff --git a/rollup.config.js b/rollup.config.js new file mode 100644 index 0000000..21abf98 --- /dev/null +++ b/rollup.config.js @@ -0,0 +1,22 @@ +var babel = require('rollup-plugin-babel') +var pkg = require('./package.json') + +module.exports = { + moduleName: 'angularCacheModuleName', + moduleId: 'angular-cache', + banner: '/**\n' + + ' * angular-cache\n' + + ' * @version ' + pkg.version + ' - Homepage \n' + + ' * @copyright (c) 2013-2016 angular-cache project authors\n' + + ' * @license MIT \n' + + ' * @overview angular-cache is a very useful replacement for Angular\'s $cacheFactory.\n' + + ' */', + plugins: [ + babel({ + babelrc: false, + presets: [ + 'es2015-rollup' + ] + }) + ] +} diff --git a/scripts/postbuild.js b/scripts/postbuild.js new file mode 100644 index 0000000..20c3d9a --- /dev/null +++ b/scripts/postbuild.js @@ -0,0 +1,21 @@ +var fs = require('fs') +var path = __dirname + '/../dist/angular-cache.js' +var file = fs.readFileSync(path, { encoding: 'utf8' }) +file = file.replace( + 'module.exports = factory(require(\'angular\'))', + 'module.exports = factory(typeof angular === \'undefined\' ? require(\'angular\') : angular)' +) +var index = file.indexOf('babelHelpers;') +var str = 'var babelHelpers = {};\n' + +' babelHelpers.typeof = typeof Symbol === "function" && babelHelpers.typeof(Symbol.iterator) === "symbol" ? function (obj) {\n' + +' return typeof obj === "undefined" ? "undefined" : babelHelpers.typeof(obj);\n' + +' } : function (obj) {\n' + +' return obj && typeof Symbol === "function" && obj.constructor === Symbol ? "symbol" : typeof obj === "undefined" ? "undefined" : babelHelpers.typeof(obj);\n' + +' };' + +var index2 = file.indexOf(str) + +var file2 = file.substring(index2 + str.length) +file = file.substring(0, index) + file2 + +fs.writeFileSync(path, file) diff --git a/src/index.js b/src/index.js index 4fd2324..f2948cc 100644 --- a/src/index.js +++ b/src/index.js @@ -1,5 +1,5 @@ -const angular = require('angular') -const CacheFactory = require('cachefactory') +import angular from 'angular' +import CacheFactory from '../node_modules/cachefactory/dist/cachefactory.es2015' CacheFactory.utils.equals = angular.equals CacheFactory.utils.isObject = angular.isObject @@ -23,10 +23,4 @@ angular.module('angular-cache', []) .provider('BinaryHeap', BinaryHeapProvider) .provider('CacheFactory', CacheFactoryProvider) -module.exports = 'angular-cache' -try { - module.exports.name = 'angular-cache' -} catch (err) { - -} - +export default 'angular-cache' diff --git a/test/unit/Cache/index.put.test.js b/test/unit/Cache/index.put.test.js index 1f17430..e8df2a7 100644 --- a/test/unit/Cache/index.put.test.js +++ b/test/unit/Cache/index.put.test.js @@ -317,6 +317,7 @@ describe('Cache#put(key, value[, options])', function () { assert.deepEqual(cache.keys(), ['test.com']); setTimeout(function () { try { + $rootScope.$safeApply(); var promise = cache.get('test.com'); assert.equal(typeof promise.then, 'function'); $http.get('test.com', { diff --git a/webpack.config.js b/webpack.config.js deleted file mode 100644 index d63fd6f..0000000 --- a/webpack.config.js +++ /dev/null @@ -1,84 +0,0 @@ -var webpack = require('webpack'); -var pkg = JSON.parse(require('fs').readFileSync('package.json')); -var banner = 'angular-cache\n' + - '@version ' + pkg.version + ' - Homepage \n' + - '@author Jason Dobry \n' + - '@copyright (c) 2013-2016 Jason Dobry \n' + - '@license MIT \n' + - '\n' + - '@overview angular-cache is a very useful replacement for Angular\'s $cacheFactory.'; - -module.exports = { - devtool: 'source-map', - entry: './src/index.js', - output: { - filename: './dist/angular-cache.js', - libraryTarget: 'umd', - library: 'angularCacheModuleName' - }, - externals: { - 'angular': 'angular' - }, - module: { - loaders: [ - { - test: /(src)(.+)\.js$/, - exclude: /node_modules/, - loader: 'babel-loader', - query: { - presets: ['es2015'] - } - } - ] - }, - plugins: [ - { - apply: function (compiler) { - function isObject (value) { - return toString.call(value) === '[object Object]' || false - } - - function findAndReplace (target, search, str) { - if (Array.isArray(target)) { - target.forEach(function (target) { - findAndReplace(target, search, str) - }) - } else if (isObject(target)) { - for (var key in target) { - if (target.hasOwnProperty(key)) { - if (typeof target[key] === 'string') { - target[key] = target[key] - .replace(search, str) - } else if (Array.isArray(target[key])) { - target[key].forEach(function (target) { - findAndReplace(target, search, str) - }); - } else if (target[key] && isObject(target[key])) { - findAndReplace(target[key], search, str); - } - } - } - } - } - - compiler.plugin('compilation', function (compilation) { - compilation.plugin('optimize-chunk-assets', function (chunks, callback) { - chunks.forEach(function (chunk) { - if (chunk.initial) { - var start = new Date().getTime(); - chunk.files.forEach(function (file) { - findAndReplace(compilation.assets[file]._source, 'define(["angular"], factory)', 'define("angular-cache", ["angular"], factory)'); - findAndReplace(compilation.assets[file]._source, 'define([], factory)', 'define("cachefactory", [], factory)'); - }); - var end = new Date().getTime(); - console.log('time taken: ' + (end - start) + 'ms'); - } - }); - callback(); - }); - }); - } - }, - new webpack.BannerPlugin(banner) - ] -};