diff --git a/.gitignore b/.gitignore
index ab1a12a..83b561d 100644
--- a/.gitignore
+++ b/.gitignore
@@ -15,3 +15,5 @@ coverage/Firefox*/*
coverage/
bower_components/
+
+build_examples/**/bundle.js
diff --git a/build_examples/browserify/README.md b/build_examples/browserify/README.md
new file mode 100644
index 0000000..0d762e6
--- /dev/null
+++ b/build_examples/browserify/README.md
@@ -0,0 +1 @@
+Running `browserify app.js > bundle.js` in this directory will produce `bundle.js`
diff --git a/build_examples/browserify/app.js b/build_examples/browserify/app.js
new file mode 100644
index 0000000..6f841e7
--- /dev/null
+++ b/build_examples/browserify/app.js
@@ -0,0 +1,11 @@
+var angular = require('angular');
+
+angular.module('app', [
+ // this is what you would do in a real app
+ // require('angular-cache')
+
+ // for the example to work
+ require('../../dist/angular-cache.js')
+]).run(function ($rootScope, CacheFactory) {
+ $rootScope.test = 'It works! Using ' + (CacheFactory ? 'angular-cache' : 'undefined');
+});
diff --git a/build_examples/browserify/index.html b/build_examples/browserify/index.html
new file mode 100644
index 0000000..9769ccd
--- /dev/null
+++ b/build_examples/browserify/index.html
@@ -0,0 +1,11 @@
+
+
+
+ My App
+
+
+
+
+{{ test }}
+
+
diff --git a/build_examples/r.js/README.md b/build_examples/r.js/README.md
new file mode 100644
index 0000000..0632f37
--- /dev/null
+++ b/build_examples/r.js/README.md
@@ -0,0 +1,3 @@
+Running `r.js -o require.config.js` in this directory will produce `bundle.js`
+
+In `index.html` switch `script/main` between `main` (load scripts dynamically) and `bundle` (load bundled scripts)
diff --git a/build_examples/r.js/app.js b/build_examples/r.js/app.js
new file mode 100644
index 0000000..74cb904
--- /dev/null
+++ b/build_examples/r.js/app.js
@@ -0,0 +1,9 @@
+define('app', [
+ 'angular',
+ 'angular-cache'
+], function (angular, angularCacheModuleName) {
+ return angular.module('app', ['angular-cache'])
+ .run(function ($rootScope) {
+ $rootScope.test = 'It works! Using ' + angularCacheModuleName;
+ });
+});
diff --git a/build_examples/r.js/index.html b/build_examples/r.js/index.html
new file mode 100644
index 0000000..781e49d
--- /dev/null
+++ b/build_examples/r.js/index.html
@@ -0,0 +1,14 @@
+
+
+
+ My App
+
+
+
+
+
+
+
+{{ test }}
+
+
diff --git a/build_examples/r.js/main.js b/build_examples/r.js/main.js
new file mode 100644
index 0000000..0fb6e49
--- /dev/null
+++ b/build_examples/r.js/main.js
@@ -0,0 +1,22 @@
+require.config({
+ paths: {
+ angular: '../../bower_components/angular/angular',
+ 'angular-cache': '../../dist/angular-cache',
+ },
+ shim: {
+ 'angular': {
+ exports: 'angular'
+ }
+ }
+});
+
+require([
+ 'angular',
+ 'app'
+ ], function (angular, app) {
+ angular.element(document.getElementsByTagName('html')[0]).ready(function () {
+ // bootstrap the app manually
+ angular.bootstrap(document, ['app']);
+ });
+ }
+);
diff --git a/build_examples/r.js/require.config.js b/build_examples/r.js/require.config.js
new file mode 100644
index 0000000..a89ae0f
--- /dev/null
+++ b/build_examples/r.js/require.config.js
@@ -0,0 +1,6 @@
+({
+ name: 'main',
+ mainConfigFile: 'main.js',
+ out: 'bundle.js',
+ optimize: 'none'
+})
diff --git a/build_examples/webpack/README.md b/build_examples/webpack/README.md
new file mode 100644
index 0000000..77d2d8f
--- /dev/null
+++ b/build_examples/webpack/README.md
@@ -0,0 +1 @@
+Running `webpack` in this directory will produce `bundle.js`
diff --git a/build_examples/webpack/app.js b/build_examples/webpack/app.js
new file mode 100644
index 0000000..7b904ee
--- /dev/null
+++ b/build_examples/webpack/app.js
@@ -0,0 +1,8 @@
+var angular = require('angular');
+var angularCacheModuleName = require('angular-cache');
+
+var app = angular.module('app', [
+ angularCacheModuleName
+]).run(function ($rootScope) {
+ $rootScope.test = 'It works, imported ' + angularCacheModuleName;
+});
diff --git a/build_examples/webpack/index.html b/build_examples/webpack/index.html
new file mode 100644
index 0000000..9769ccd
--- /dev/null
+++ b/build_examples/webpack/index.html
@@ -0,0 +1,11 @@
+
+
+
+ My App
+
+
+
+
+{{ test }}
+
+
diff --git a/build_examples/webpack/webpack.config.js b/build_examples/webpack/webpack.config.js
new file mode 100644
index 0000000..1b3a6df
--- /dev/null
+++ b/build_examples/webpack/webpack.config.js
@@ -0,0 +1,11 @@
+module.exports = {
+ entry: './app.js',
+ output: {
+ filename: 'bundle.js'
+ },
+ resolve: {
+ alias: {
+ 'angular-cache': '../../dist/angular-cache.js'
+ }
+ }
+};
diff --git a/build_examples/webpack_es6/README.md b/build_examples/webpack_es6/README.md
new file mode 100644
index 0000000..77d2d8f
--- /dev/null
+++ b/build_examples/webpack_es6/README.md
@@ -0,0 +1 @@
+Running `webpack` in this directory will produce `bundle.js`
diff --git a/build_examples/webpack_es6/app.js b/build_examples/webpack_es6/app.js
new file mode 100644
index 0000000..78a3d25
--- /dev/null
+++ b/build_examples/webpack_es6/app.js
@@ -0,0 +1,8 @@
+import angular from 'angular';
+import angularCacheModuleName from 'angular-cache';
+
+let app = angular.module('app', [
+ angularCacheModuleName
+]).run($rootScope => {
+ $rootScope.test = 'It works, imported ' + angularCacheModuleName;
+});
diff --git a/build_examples/webpack_es6/index.html b/build_examples/webpack_es6/index.html
new file mode 100644
index 0000000..9769ccd
--- /dev/null
+++ b/build_examples/webpack_es6/index.html
@@ -0,0 +1,11 @@
+
+
+
+ My App
+
+
+
+
+{{ test }}
+
+
diff --git a/build_examples/webpack_es6/webpack.config.js b/build_examples/webpack_es6/webpack.config.js
new file mode 100644
index 0000000..3caf2be
--- /dev/null
+++ b/build_examples/webpack_es6/webpack.config.js
@@ -0,0 +1,16 @@
+module.exports = {
+ entry: './app.js',
+ output: {
+ filename: 'bundle.js'
+ },
+ resolve: {
+ alias: {
+ 'angular-cache': '../../dist/angular-cache.js'
+ }
+ },
+ module: {
+ loaders: [
+ { test: /(.+)\.js$/, loader: 'babel-loader?blacklist=useStrict' }
+ ]
+ }
+};
diff --git a/build_examples/webpack_es6_2/README.md b/build_examples/webpack_es6_2/README.md
new file mode 100644
index 0000000..77d2d8f
--- /dev/null
+++ b/build_examples/webpack_es6_2/README.md
@@ -0,0 +1 @@
+Running `webpack` in this directory will produce `bundle.js`
diff --git a/build_examples/webpack_es6_2/app.js b/build_examples/webpack_es6_2/app.js
new file mode 100644
index 0000000..c75a0b3
--- /dev/null
+++ b/build_examples/webpack_es6_2/app.js
@@ -0,0 +1,8 @@
+import 'angular';
+import 'angular-cache';
+
+let app = angular.module('app', [
+ 'angular-cache'
+]).run(($rootScope, CacheFactory) => {
+ $rootScope.test = 'It works, imported ' + (CacheFactory ? 'angular-cache' : 'undefined');
+});
diff --git a/build_examples/webpack_es6_2/index.html b/build_examples/webpack_es6_2/index.html
new file mode 100644
index 0000000..9769ccd
--- /dev/null
+++ b/build_examples/webpack_es6_2/index.html
@@ -0,0 +1,11 @@
+
+
+
+ My App
+
+
+
+
+{{ test }}
+
+
diff --git a/build_examples/webpack_es6_2/webpack.config.js b/build_examples/webpack_es6_2/webpack.config.js
new file mode 100644
index 0000000..3caf2be
--- /dev/null
+++ b/build_examples/webpack_es6_2/webpack.config.js
@@ -0,0 +1,16 @@
+module.exports = {
+ entry: './app.js',
+ output: {
+ filename: 'bundle.js'
+ },
+ resolve: {
+ alias: {
+ 'angular-cache': '../../dist/angular-cache.js'
+ }
+ },
+ module: {
+ loaders: [
+ { test: /(.+)\.js$/, loader: 'babel-loader?blacklist=useStrict' }
+ ]
+ }
+};
diff --git a/dist/angular-cache.js b/dist/angular-cache.js
index f2700bc..cd84b13 100644
--- a/dist/angular-cache.js
+++ b/dist/angular-cache.js
@@ -1,6 +1,6 @@
/*!
* angular-cache
- * @version 4.2.0 - Homepage
+ * @version 4.2.1 - Homepage
* @author Jason Dobry
* @copyright (c) 2013-2015 Jason Dobry
* @license MIT
@@ -63,13 +63,11 @@ return /******/ (function(modules) { // webpackBootstrap
/* 0 */
/***/ function(module, exports, __webpack_require__) {
- var _interopRequire = function (obj) { return obj && obj.__esModule ? obj["default"] : obj; };
+ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
- var _classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } };
+ var angular = __webpack_require__(1);
- var angular = _interopRequire(__webpack_require__(1));
-
- var _keys = function (collection) {
+ var _keys = function _keys(collection) {
var keys = [],
key = undefined;
for (key in collection) {
@@ -80,18 +78,18 @@ return /******/ (function(modules) { // webpackBootstrap
return keys;
};
- var _isPromiseLike = function (v) {
- return v && typeof v.then === "function";
+ var _isPromiseLike = function _isPromiseLike(v) {
+ return v && typeof v.then === 'function';
};
- var _stringifyNumber = function (number) {
+ var _stringifyNumber = function _stringifyNumber(number) {
if (angular.isNumber(number)) {
return number.toString();
}
return number;
};
- var _keySet = function (collection) {
+ var _keySet = function _keySet(collection) {
var keySet = {},
key = undefined;
for (key in collection) {
@@ -134,7 +132,7 @@ return /******/ (function(modules) { // webpackBootstrap
* @param {function} weightFunc The weight function.
* @param {number} n The index of the element to sink down.
*/
- var bubbleDown = function (heap, weightFunc, n) {
+ var bubbleDown = function bubbleDown(heap, weightFunc, n) {
var length = heap.length;
var node = heap[n];
var nodeWeight = weightFunc(node);
@@ -185,11 +183,11 @@ return /******/ (function(modules) { // webpackBootstrap
return x === y;
};
}
- if (typeof weightFunc !== "function") {
- throw new Error("BinaryHeap([weightFunc][, compareFunc]): \"weightFunc\" must be a function!");
+ 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!");
+ if (typeof compareFunc !== 'function') {
+ throw new Error('BinaryHeap([weightFunc][, compareFunc]): "compareFunc" must be a function!');
}
this.weightFunc = weightFunc;
this.compareFunc = compareFunc;
@@ -249,33 +247,33 @@ return /******/ (function(modules) { // webpackBootstrap
};
var CacheFactoryProvider = function CacheFactoryProvider() {
- var _this = this;
+ var _this5 = this;
_classCallCheck(this, CacheFactoryProvider);
var defaults = this.defaults = {
capacity: Number.MAX_VALUE,
maxAge: Number.MAX_VALUE,
- deleteOnExpire: "none",
+ deleteOnExpire: 'none',
onExpire: null,
cacheFlushInterval: null,
recycleFreq: 1000,
- storageMode: "memory",
+ storageMode: 'memory',
storageImpl: null,
disabled: false,
- storagePrefix: "angular-cache.caches.",
+ storagePrefix: 'angular-cache.caches.',
storeOnResolve: false,
storeOnReject: false
};
- this.$get = ["$q", function ($q) {
+ this.$get = ['$q', function ($q) {
var caches = {};
- var createCache = function (cacheId, options) {
+ var createCache = function createCache(cacheId, options) {
if (cacheId in caches) {
- throw new Error("" + cacheId + " already exists!");
+ throw new Error(cacheId + ' already exists!');
} else if (!angular.isString(cacheId)) {
- throw new Error("cacheId must be a string!");
+ throw new Error('cacheId must be a string!');
}
var $$data = {};
@@ -297,7 +295,7 @@ return /******/ (function(modules) { // webpackBootstrap
clearInterval(this.$$recycleFreqId);
this.removeAll();
if ($$storage) {
- $$storage().removeItem("" + this.$$prefix + ".keys");
+ $$storage().removeItem(this.$$prefix + '.keys');
$$storage().removeItem(this.$$prefix);
}
$$storage = null;
@@ -336,9 +334,7 @@ return /******/ (function(modules) { // webpackBootstrap
};
})();
- if (typeof _ret === "object") {
- return _ret.v;
- }
+ if (typeof _ret === 'object') return _ret.v;
} else {
key = _stringifyNumber(key);
@@ -349,11 +345,11 @@ return /******/ (function(modules) { // webpackBootstrap
options = options || {};
if (!angular.isString(key)) {
- throw new Error("key must be a string!");
+ throw new Error('key must be a string!');
} else if (options && !angular.isObject(options)) {
- throw new Error("options must be an object!");
+ throw new Error('options must be an object!');
} else if (options.onExpire && !angular.isFunction(options.onExpire)) {
- throw new Error("options.onExpire must be a function!");
+ throw new Error('options.onExpire must be a function!');
}
var item = undefined;
@@ -363,7 +359,7 @@ return /******/ (function(modules) { // webpackBootstrap
return $$promises[key];
}
- var itemJson = $$storage().getItem("" + this.$$prefix + ".data." + key);
+ var itemJson = $$storage().getItem(this.$$prefix + '.data.' + key);
if (itemJson) {
item = angular.fromJson(itemJson);
@@ -397,7 +393,7 @@ return /******/ (function(modules) { // webpackBootstrap
$$lruHeap.push(item);
}
- if (this.$$deleteOnExpire === "passive" && "expires" in item && item.expires < now) {
+ if (this.$$deleteOnExpire === 'passive' && 'expires' in item && item.expires < now) {
this.remove(key);
if (this.$$onExpire) {
@@ -407,7 +403,7 @@ return /******/ (function(modules) { // webpackBootstrap
}
value = undefined;
} else if ($$storage) {
- $$storage().setItem("" + this.$$prefix + ".data." + key, JSON.stringify(item));
+ $$storage().setItem(this.$$prefix + '.data.' + key, JSON.stringify(item));
}
return value;
@@ -417,7 +413,7 @@ return /******/ (function(modules) { // webpackBootstrap
if (key) {
var item = undefined;
if ($$storage) {
- var itemJson = $$storage().getItem("" + this.$$prefix + ".data." + key);
+ var itemJson = $$storage().getItem(this.$$prefix + '.data.' + key);
if (itemJson) {
item = angular.fromJson(itemJson);
@@ -463,7 +459,7 @@ return /******/ (function(modules) { // webpackBootstrap
keys: function keys() {
if ($$storage) {
- var keysJson = $$storage().getItem("" + this.$$prefix + ".keys");
+ var keysJson = $$storage().getItem(this.$$prefix + '.keys');
if (keysJson) {
return angular.fromJson(keysJson);
@@ -477,7 +473,7 @@ return /******/ (function(modules) { // webpackBootstrap
keySet: function keySet() {
if ($$storage) {
- var keysJson = $$storage().getItem("" + this.$$prefix + ".keys");
+ var keysJson = $$storage().getItem(this.$$prefix + '.keys');
var kSet = {};
if (keysJson) {
@@ -494,22 +490,22 @@ return /******/ (function(modules) { // webpackBootstrap
},
put: function put(key, value, options) {
- var _this2 = this;
+ var _this3 = this;
options = options || {};
- var storeOnResolve = "storeOnResolve" in options ? !!options.storeOnResolve : this.$$storeOnResolve;
- var storeOnReject = "storeOnReject" in options ? !!options.storeOnReject : this.$$storeOnReject;
+ var storeOnResolve = 'storeOnResolve' in options ? !!options.storeOnResolve : this.$$storeOnResolve;
+ var storeOnReject = 'storeOnReject' in options ? !!options.storeOnReject : this.$$storeOnReject;
- var getHandler = function (store, isError) {
+ var getHandler = function getHandler(store, isError) {
return function (v) {
if (store) {
delete $$promises[key];
- if (angular.isObject(v) && "status" in v && "data" in v) {
+ if (angular.isObject(v) && 'status' in v && 'data' in v) {
v = [v.status, v.data, v.headers(), v.statusText];
- _this2.put(key, v);
+ _this3.put(key, v);
} else {
- _this2.put(key, v);
+ _this3.put(key, v);
}
}
if (isError) {
@@ -526,7 +522,7 @@ return /******/ (function(modules) { // webpackBootstrap
key = _stringifyNumber(key);
if (!angular.isString(key)) {
- throw new Error("key must be a string!");
+ throw new Error('key must be a string!');
}
var now = new Date().getTime();
@@ -544,9 +540,9 @@ return /******/ (function(modules) { // webpackBootstrap
$$promises[key] = item.value;
return $$promises[key];
}
- var keysJson = $$storage().getItem("" + this.$$prefix + ".keys");
+ var keysJson = $$storage().getItem(this.$$prefix + '.keys');
var keys = keysJson ? angular.fromJson(keysJson) : [];
- var itemJson = $$storage().getItem("" + this.$$prefix + ".data." + key);
+ var itemJson = $$storage().getItem(this.$$prefix + '.data.' + key);
// Remove existing
if (itemJson) {
@@ -563,7 +559,7 @@ return /******/ (function(modules) { // webpackBootstrap
accessed: item.accessed
});
// Set item
- $$storage().setItem("" + this.$$prefix + ".data." + key, JSON.stringify(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) {
@@ -574,7 +570,7 @@ return /******/ (function(modules) { // webpackBootstrap
if (!exists) {
keys.push(key);
}
- $$storage().setItem("" + this.$$prefix + ".keys", JSON.stringify(keys));
+ $$storage().setItem(this.$$prefix + '.keys', JSON.stringify(keys));
} else {
// Remove existing
if ($$data[key]) {
@@ -598,10 +594,10 @@ return /******/ (function(modules) { // webpackBootstrap
},
remove: function remove(key) {
- key += "";
+ key += '';
delete $$promises[key];
if ($$storage) {
- var itemJson = $$storage().getItem("" + this.$$prefix + ".data." + key);
+ var itemJson = $$storage().getItem(this.$$prefix + '.data.' + key);
if (itemJson) {
var item = angular.fromJson(itemJson);
@@ -613,15 +609,15 @@ return /******/ (function(modules) { // webpackBootstrap
key: key,
expires: item.expires
});
- $$storage().removeItem("" + this.$$prefix + ".data." + key);
- var keysJson = $$storage().getItem("" + this.$$prefix + ".keys");
+ $$storage().removeItem(this.$$prefix + '.data.' + key);
+ var keysJson = $$storage().getItem(this.$$prefix + '.keys');
var keys = keysJson ? angular.fromJson(keysJson) : [];
var index = keys.indexOf(key);
if (index >= 0) {
keys.splice(index, 1);
}
- $$storage().setItem("" + this.$$prefix + ".keys", JSON.stringify(keys));
+ $$storage().setItem(this.$$prefix + '.keys', JSON.stringify(keys));
return item.value;
}
} else {
@@ -638,7 +634,7 @@ return /******/ (function(modules) { // webpackBootstrap
if ($$storage) {
$$lruHeap.removeAll();
$$expiresHeap.removeAll();
- var keysJson = $$storage().getItem("" + this.$$prefix + ".keys");
+ var keysJson = $$storage().getItem(this.$$prefix + '.keys');
if (keysJson) {
var keys = angular.fromJson(keysJson);
@@ -647,7 +643,7 @@ return /******/ (function(modules) { // webpackBootstrap
this.remove(keys[i]);
}
}
- $$storage().setItem("" + this.$$prefix + ".keys", JSON.stringify([]));
+ $$storage().setItem(this.$$prefix + '.keys', JSON.stringify([]));
} else {
$$lruHeap.removeAll();
$$expiresHeap.removeAll();
@@ -672,7 +668,7 @@ return /******/ (function(modules) { // webpackBootstrap
if ($$storage) {
for (key in expired) {
- var itemJson = $$storage().getItem("" + this.$$prefix + ".data." + key);
+ var itemJson = $$storage().getItem(this.$$prefix + '.data.' + key);
if (itemJson) {
expired[key] = angular.fromJson(itemJson).value;
this.remove(key);
@@ -697,9 +693,9 @@ return /******/ (function(modules) { // webpackBootstrap
if (cacheFlushInterval === null) {
delete this.$$cacheFlushInterval;
} else if (!angular.isNumber(cacheFlushInterval)) {
- throw new Error("cacheFlushInterval must be a number!");
+ throw new Error('cacheFlushInterval must be a number!');
} else if (cacheFlushInterval < 0) {
- throw new Error("cacheFlushInterval must be greater than zero!");
+ throw new Error('cacheFlushInterval must be greater than zero!');
} else if (cacheFlushInterval !== this.$$cacheFlushInterval) {
this.$$cacheFlushInterval = cacheFlushInterval;
clearInterval(this.$$cacheFlushIntervalId);
@@ -715,9 +711,9 @@ return /******/ (function(modules) { // webpackBootstrap
if (capacity === null) {
delete this.$$capacity;
} else if (!angular.isNumber(capacity)) {
- throw new Error("capacity must be a number!");
+ throw new Error('capacity must be a number!');
} else if (capacity < 0) {
- throw new Error("capacity must be greater than zero!");
+ throw new Error('capacity must be greater than zero!');
} else {
this.$$capacity = capacity;
}
@@ -732,9 +728,9 @@ return /******/ (function(modules) { // webpackBootstrap
if (deleteOnExpire === null) {
delete this.$$deleteOnExpire;
} else if (!angular.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\"!");
+ 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;
}
@@ -747,9 +743,9 @@ return /******/ (function(modules) { // webpackBootstrap
if (maxAge === null) {
this.$$maxAge = Number.MAX_VALUE;
} else if (!angular.isNumber(maxAge)) {
- throw new Error("maxAge must be a number!");
+ throw new Error('maxAge must be a number!');
} else if (maxAge < 0) {
- throw new Error("maxAge must be greater than zero!");
+ throw new Error('maxAge must be greater than zero!');
} else {
this.$$maxAge = maxAge;
}
@@ -760,13 +756,13 @@ return /******/ (function(modules) { // webpackBootstrap
$$expiresHeap.removeAll();
if ($$storage) {
- var keysJson = $$storage().getItem("" + this.$$prefix + ".keys");
+ var keysJson = $$storage().getItem(this.$$prefix + '.keys');
keys = keysJson ? angular.fromJson(keysJson) : [];
for (i = 0; i < keys.length; i++) {
key = keys[i];
- var itemJson = $$storage().getItem("" + this.$$prefix + ".data." + key);
+ var itemJson = $$storage().getItem(this.$$prefix + '.data.' + key);
if (itemJson) {
var item = angular.fromJson(itemJson);
@@ -794,7 +790,7 @@ return /******/ (function(modules) { // webpackBootstrap
$$expiresHeap.push($$data[key]);
}
}
- if (this.$$deleteOnExpire === "aggressive") {
+ if (this.$$deleteOnExpire === 'aggressive') {
return this.removeExpired();
} else {
return {};
@@ -805,7 +801,7 @@ return /******/ (function(modules) { // webpackBootstrap
if (onExpire === null) {
delete this.$$onExpire;
} else if (!angular.isFunction(onExpire)) {
- throw new Error("onExpire must be a function!");
+ throw new Error('onExpire must be a function!');
} else {
this.$$onExpire = onExpire;
}
@@ -815,10 +811,10 @@ return /******/ (function(modules) { // webpackBootstrap
cacheOptions = cacheOptions || {};
strict = !!strict;
if (!angular.isObject(cacheOptions)) {
- throw new Error("cacheOptions must be an object!");
+ throw new Error('cacheOptions must be an object!');
}
- if ("storagePrefix" in cacheOptions) {
+ if ('storagePrefix' in cacheOptions) {
this.$$storagePrefix = cacheOptions.storagePrefix;
} else if (strict) {
this.$$storagePrefix = defaults.storagePrefix;
@@ -826,61 +822,61 @@ return /******/ (function(modules) { // webpackBootstrap
this.$$prefix = this.$$storagePrefix + this.$$id;
- if ("disabled" in cacheOptions) {
+ if ('disabled' in cacheOptions) {
this.$$disabled = !!cacheOptions.disabled;
} else if (strict) {
this.$$disabled = defaults.disabled;
}
- if ("storageMode" in cacheOptions || "storageImpl" in cacheOptions) {
+ if ('storageMode' in cacheOptions || 'storageImpl' in cacheOptions) {
this.setStorageMode(cacheOptions.storageMode, cacheOptions.storageImpl);
} else if (strict) {
this.setStorageMode(defaults.storageMode, defaults.storageImpl);
}
- if ("storeOnResolve" in cacheOptions) {
+ if ('storeOnResolve' in cacheOptions) {
this.$$storeOnResolve = !!cacheOptions.storeOnResolve;
} else if (strict) {
this.$$storeOnResolve = defaults.storeOnResolve;
}
- if ("storeOnReject" in cacheOptions) {
+ if ('storeOnReject' in cacheOptions) {
this.$$storeOnReject = !!cacheOptions.storeOnReject;
} else if (strict) {
this.$$storeOnReject = defaults.storeOnReject;
}
- if ("capacity" in cacheOptions) {
+ if ('capacity' in cacheOptions) {
this.setCapacity(cacheOptions.capacity);
} else if (strict) {
this.setCapacity(defaults.capacity);
}
- if ("deleteOnExpire" in cacheOptions) {
+ if ('deleteOnExpire' in cacheOptions) {
this.setDeleteOnExpire(cacheOptions.deleteOnExpire, false);
} else if (strict) {
this.setDeleteOnExpire(defaults.deleteOnExpire, false);
}
- if ("maxAge" in cacheOptions) {
+ if ('maxAge' in cacheOptions) {
this.setMaxAge(cacheOptions.maxAge);
} else if (strict) {
this.setMaxAge(defaults.maxAge);
}
- if ("recycleFreq" in cacheOptions) {
+ if ('recycleFreq' in cacheOptions) {
this.setRecycleFreq(cacheOptions.recycleFreq);
} else if (strict) {
this.setRecycleFreq(defaults.recycleFreq);
}
- if ("cacheFlushInterval" in cacheOptions) {
+ if ('cacheFlushInterval' in cacheOptions) {
this.setCacheFlushInterval(cacheOptions.cacheFlushInterval);
} else if (strict) {
this.setCacheFlushInterval(defaults.cacheFlushInterval);
}
- if ("onExpire" in cacheOptions) {
+ if ('onExpire' in cacheOptions) {
this.setOnExpire(cacheOptions.onExpire);
} else if (strict) {
this.setOnExpire(defaults.onExpire);
@@ -891,14 +887,14 @@ return /******/ (function(modules) { // webpackBootstrap
if (recycleFreq === null) {
delete this.$$recycleFreq;
} else if (!angular.isNumber(recycleFreq)) {
- throw new Error("recycleFreq must be a number!");
+ throw new Error('recycleFreq must be a number!');
} else if (recycleFreq < 0) {
- throw new Error("recycleFreq must be greater than zero!");
+ throw new Error('recycleFreq must be greater than zero!');
} else {
this.$$recycleFreq = recycleFreq;
}
clearInterval(this.$$recycleFreqId);
- if (this.$$deleteOnExpire === "aggressive") {
+ if (this.$$deleteOnExpire === 'aggressive') {
(function (self) {
self.$$recycleFreqId = setInterval(function () {
self.removeExpired();
@@ -911,15 +907,15 @@ return /******/ (function(modules) { // webpackBootstrap
setStorageMode: function setStorageMode(storageMode, storageImpl) {
if (!angular.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\"!");
+ 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 shouldReInsert = false;
var items = {};
- if (typeof this.$$storageMode === "string" && this.$$storageMode !== storageMode) {
+ if (typeof this.$$storageMode === 'string' && this.$$storageMode !== storageMode) {
var keys = this.keys();
if (keys.length) {
@@ -937,38 +933,38 @@ return /******/ (function(modules) { // webpackBootstrap
if (storageImpl) {
if (!angular.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)\"!");
+ 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 () {
return storageImpl;
};
- } else if (this.$$storageMode === "localStorage") {
+ } else if (this.$$storageMode === 'localStorage') {
try {
- localStorage.setItem("angular-cache", "angular-cache");
- localStorage.removeItem("angular-cache");
+ localStorage.setItem('angular-cache', 'angular-cache');
+ localStorage.removeItem('angular-cache');
$$storage = function () {
return localStorage;
};
} catch (e) {
$$storage = null;
- this.$$storageMode = "memory";
+ this.$$storageMode = 'memory';
}
- } else if (this.$$storageMode === "sessionStorage") {
+ } else if (this.$$storageMode === 'sessionStorage') {
try {
- sessionStorage.setItem("angular-cache", "angular-cache");
- sessionStorage.removeItem("angular-cache");
+ sessionStorage.setItem('angular-cache', 'angular-cache');
+ sessionStorage.removeItem('angular-cache');
$$storage = function () {
return sessionStorage;
};
} catch (e) {
$$storage = null;
- this.$$storageMode = "memory";
+ this.$$storageMode = 'memory';
}
}
@@ -980,12 +976,12 @@ return /******/ (function(modules) { // webpackBootstrap
},
touch: function touch(key) {
- var _this2 = this;
+ var _this4 = this;
if (key) {
var val = this.get(key, {
- onExpire: function (k, v) {
- return _this2.put(k, v);
+ onExpire: function onExpire(k, v) {
+ return _this4.put(k, v);
}
});
if (val) {
@@ -1017,7 +1013,7 @@ return /******/ (function(modules) { // webpackBootstrap
size: keys.length,
caches: {}
};
- angular.extend(info, _this.defaults);
+ angular.extend(info, _this5.defaults);
for (var i = 0; i < keys.length; i++) {
var key = keys[i];
info.caches[key] = caches[key].info();
@@ -1087,9 +1083,10 @@ return /******/ (function(modules) { // webpackBootstrap
}];
};
- angular.module("angular-cache", []).provider("BinaryHeap", BinaryHeapProvider).provider("CacheFactory", CacheFactoryProvider);
+ angular.module('angular-cache', []).provider('BinaryHeap', BinaryHeapProvider).provider('CacheFactory', CacheFactoryProvider);
- module.exports = "angular-cache";
+ module.exports = 'angular-cache';
+ module.exports.name = 'angular-cache';
/***/ },
/* 1 */
diff --git a/dist/angular-cache.min.js b/dist/angular-cache.min.js
index 8d86830..502ed24 100644
--- a/dist/angular-cache.min.js
+++ b/dist/angular-cache.min.js
@@ -1,6 +1,6 @@
/*!
* angular-cache
-* @version 4.2.0 - Homepage
+* @version 4.2.1 - Homepage
* @author Jason Dobry
* @copyright (c) 2013-2015 Jason Dobry
* @license MIT
@@ -8,5 +8,5 @@
* @overview angular-cache is a very useful replacement for Angular's $cacheFactory.
*/
-!function(a,b){"object"==typeof exports&&"object"==typeof module?module.exports=b(require("angular")):"function"==typeof define&&define.amd?define(["angular"],b):"object"==typeof exports?exports.angularCacheModuleName=b(require("angular")):a.angularCacheModuleName=b(a.angular)}(this,function(a){return function(a){function b(d){if(c[d])return c[d].exports;var e=c[d]={exports:{},id:d,loaded:!1};return a[d].call(e.exports,e,e.exports,b),e.loaded=!0,e.exports}var c={};return b.m=a,b.c=c,b.p="",b(0)}([function(a,b,c){function d(a,b,c){for(var d=a[c],e=b(d);c>0;){var f=Math.floor((c+1)/2)-1,g=a[f];if(e>=b(g))break;a[f]=d,a[c]=g,c=f}}var e=function(a){return a&&a.__esModule?a["default"]:a},f=function(a,b){if(!(a instanceof b))throw new TypeError("Cannot call a class as a function")},g=e(c(1)),h=function(a){var b=[],c=void 0;for(c in a)a.hasOwnProperty(c)&&b.push(c);return b},i=function(a){return a&&"function"==typeof a.then},j=function(a){return g.isNumber(a)?a.toString():a},k=function(a){var b={},c=void 0;for(c in a)a.hasOwnProperty(c)&&(b[c]=c);return b},l=function(a,b,c){for(var d=a.length,e=a[c],f=b(e);;){var g=2*(c+1),h=g-1,i=null;if(d>h){var j=a[h],k=b(j);f>k&&(i=h)}if(d>g){var l=a[g],m=b(l);m<(null===i?f:b(a[h]))&&(i=g)}if(null===i)break;a[c]=a[i],a[i]=e,c=i}},m=function p(a,b){var c=this;if(f(this,p),a||(a=function(a){return a}),b||(b=function(a,b){return a===b}),"function"!=typeof a)throw new Error('BinaryHeap([weightFunc][, compareFunc]): "weightFunc" must be a function!');if("function"!=typeof b)throw new Error('BinaryHeap([weightFunc][, compareFunc]): "compareFunc" must be a function!');this.weightFunc=a,this.compareFunc=b,this.heap=[],this.push=function(a){c.heap.push(a),d(c.heap,c.weightFunc,c.heap.length-1)},this.peek=function(){return c.heap.length?c.heap[0]:void 0},this.pop=function(){var a=c.heap[0],b=c.heap.pop();return c.heap.length>0&&(c.heap[0]=b,l(c.heap,c.weightFunc,0)),a},this.remove=function(a){for(var b=c.heap.length,e=0;b>e;e++)if(c.compareFunc(c.heap[e],a)){var f=c.heap[e],g=c.heap.pop();return e!==b-1&&(c.heap[e]=g,d(c.heap,c.weightFunc,e),l(c.heap,c.weightFunc,e)),f}return null},this.removeAll=function(){c.heap=[]},this.size=function(){return c.heap.length}},n=function q(){f(this,q),this.$get=function(){return m}},o=function r(){var a=this;f(this,r);var b=this.defaults={capacity:Number.MAX_VALUE,maxAge:Number.MAX_VALUE,deleteOnExpire:"none",onExpire:null,cacheFlushInterval:null,recycleFreq:1e3,storageMode:"memory",storageImpl:null,disabled:!1,storagePrefix:"angular-cache.caches.",storeOnResolve:!1,storeOnReject:!1};this.$get=["$q",function(c){function d(a,b){return f(a,b)}var e={},f=function(a,d){if(a in e)throw new Error(""+a+" already exists!");if(!g.isString(a))throw new Error("cacheId must be a string!");var f={},l={},n=null,o=new m(function(a){return a.expires},g.equals),p=new m(function(a){return a.accessed},g.equals),q=e[a]={$$id:a,destroy:function(){clearInterval(this.$$cacheFlushIntervalId),clearInterval(this.$$recycleFreqId),this.removeAll(),n&&(n().removeItem(""+this.$$prefix+".keys"),n().removeItem(this.$$prefix)),n=null,f=null,p=null,o=null,this.$$prefix=null,delete e[this.$$id]},disable:function(){this.$$disabled=!0},enable:function(){delete this.$$disabled},get:function(a,b){var c=this;if(g.isArray(a)){var d=function(){var d=a,e=[];return g.forEach(d,function(a){var d=c.get(a,b);null!==d&&void 0!==d&&e.push(d)}),{v:e}}();if("object"==typeof d)return d.v}else if(a=j(a),this.$$disabled)return;if(b=b||{},!g.isString(a))throw new Error("key must be a string!");if(b&&!g.isObject(b))throw new Error("options must be an object!");if(b.onExpire&&!g.isFunction(b.onExpire))throw new Error("options.onExpire must be a function!");var e=void 0;if(n){if(l[a])return l[a];var h=n().getItem(""+this.$$prefix+".data."+a);if(!h)return;e=g.fromJson(h)}else{if(!(a in f))return;e=f[a]}var i=e.value,k=(new Date).getTime();return n?(p.remove({key:a,accessed:e.accessed}),e.accessed=k,p.push({key:a,accessed:k})):(p.remove(e),e.accessed=k,p.push(e)),"passive"===this.$$deleteOnExpire&&"expires"in e&&e.expiresthis.$$maxAge}):void 0}return a in f?(b=f[a],{created:b.created,accessed:b.accessed,expires:b.expires,isExpired:(new Date).getTime()-b.created>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:n?n():void 0,disabled:!!this.$$disabled,size:p&&p.size()||0}},keys:function(){if(n){var a=n().getItem(""+this.$$prefix+".keys");return a?g.fromJson(a):[]}return h(f)},keySet:function(){if(n){var a=n().getItem(""+this.$$prefix+".keys"),b={};if(a)for(var c=g.fromJson(a),d=0;dthis.$$capacity&&this.remove(p.peek().key),b}},remove:function(a){if(a+="",delete l[a],!n){var b=f[a]?f[a].value:void 0;return p.remove(f[a]),o.remove(f[a]),f[a]=null,delete f[a],b}var c=n().getItem(""+this.$$prefix+".data."+a);if(c){var d=g.fromJson(c);p.remove({key:a,accessed:d.accessed}),o.remove({key:a,expires:d.expires}),n().removeItem(""+this.$$prefix+".data."+a);var e=n().getItem(""+this.$$prefix+".keys"),h=e?g.fromJson(e):[],i=h.indexOf(a);return i>=0&&h.splice(i,1),n().setItem(""+this.$$prefix+".keys",JSON.stringify(h)),d.value}},removeAll:function(){if(n){p.removeAll(),o.removeAll();var a=n().getItem(""+this.$$prefix+".keys");if(a)for(var b=g.fromJson(a),c=0;ca)throw new Error("cacheFlushInterval must be greater than zero!");a!==this.$$cacheFlushInterval&&(this.$$cacheFlushInterval=a,clearInterval(this.$$cacheFlushIntervalId),function(a){a.$$cacheFlushIntervalId=setInterval(function(){a.removeAll()},a.$$cacheFlushInterval)}(this))}},setCapacity:function(a){if(null===a)delete this.$$capacity;else{if(!g.isNumber(a))throw new Error("capacity must be a number!");if(0>a)throw new Error("capacity must be greater than zero!");this.$$capacity=a}for(var b={};p.size()>this.$$capacity;)b[p.peek().key]=this.remove(p.peek().key);return b},setDeleteOnExpire:function(a,b){if(null===a)delete this.$$deleteOnExpire;else{if(!g.isString(a))throw new Error("deleteOnExpire must be a string!");if("none"!==a&&"passive"!==a&&"aggressive"!==a)throw new Error('deleteOnExpire must be "none", "passive" or "aggressive"!');this.$$deleteOnExpire=a}b!==!1&&this.setRecycleFreq(this.$$recycleFreq)},setMaxAge:function(a){if(null===a)this.$$maxAge=Number.MAX_VALUE;else{if(!g.isNumber(a))throw new Error("maxAge must be a number!");if(0>a)throw new Error("maxAge must be greater than zero!");this.$$maxAge=a}var b=void 0,c=void 0,d=void 0;if(o.removeAll(),n){var e=n().getItem(""+this.$$prefix+".keys");for(c=e?g.fromJson(e):[],b=0;ba)throw new Error("recycleFreq must be greater than zero!");this.$$recycleFreq=a}clearInterval(this.$$recycleFreqId),"aggressive"===this.$$deleteOnExpire?!function(a){a.$$recycleFreqId=setInterval(function(){a.removeExpired()},a.$$recycleFreq)}(this):delete this.$$recycleFreqId},setStorageMode:function(a,b){if(!g.isString(a))throw new Error("storageMode must be a string!");if("memory"!==a&&"localStorage"!==a&&"sessionStorage"!==a)throw new Error('storageMode must be "memory", "localStorage" or "sessionStorage"!');var c=!1,d={};if("string"==typeof this.$$storageMode&&this.$$storageMode!==a){var e=this.keys();if(e.length){for(var f=0;f0;){var f=Math.floor((c+1)/2)-1,g=a[f];if(e>=b(g))break;a[f]=d,a[c]=g,c=f}}var f=c(1),g=function(a){var b=[],c=void 0;for(c in a)a.hasOwnProperty(c)&&b.push(c);return b},h=function(a){return a&&"function"==typeof a.then},i=function(a){return f.isNumber(a)?a.toString():a},j=function(a){var b={},c=void 0;for(c in a)a.hasOwnProperty(c)&&(b[c]=c);return b},k=function(a,b,c){for(var d=a.length,e=a[c],f=b(e);;){var g=2*(c+1),h=g-1,i=null;if(d>h){var j=a[h],k=b(j);f>k&&(i=h)}if(d>g){var l=a[g],m=b(l);m<(null===i?f:b(a[h]))&&(i=g)}if(null===i)break;a[c]=a[i],a[i]=e,c=i}},l=function o(a,b){var c=this;if(d(this,o),a||(a=function(a){return a}),b||(b=function(a,b){return a===b}),"function"!=typeof a)throw new Error('BinaryHeap([weightFunc][, compareFunc]): "weightFunc" must be a function!');if("function"!=typeof b)throw new Error('BinaryHeap([weightFunc][, compareFunc]): "compareFunc" must be a function!');this.weightFunc=a,this.compareFunc=b,this.heap=[],this.push=function(a){c.heap.push(a),e(c.heap,c.weightFunc,c.heap.length-1)},this.peek=function(){return c.heap.length?c.heap[0]:void 0},this.pop=function(){var a=c.heap[0],b=c.heap.pop();return c.heap.length>0&&(c.heap[0]=b,k(c.heap,c.weightFunc,0)),a},this.remove=function(a){for(var b=c.heap.length,d=0;b>d;d++)if(c.compareFunc(c.heap[d],a)){var f=c.heap[d],g=c.heap.pop();return d!==b-1&&(c.heap[d]=g,e(c.heap,c.weightFunc,d),k(c.heap,c.weightFunc,d)),f}return null},this.removeAll=function(){c.heap=[]},this.size=function(){return c.heap.length}},m=function p(){d(this,p),this.$get=function(){return l}},n=function q(){var a=this;d(this,q);var b=this.defaults={capacity:Number.MAX_VALUE,maxAge:Number.MAX_VALUE,deleteOnExpire:"none",onExpire:null,cacheFlushInterval:null,recycleFreq:1e3,storageMode:"memory",storageImpl:null,disabled:!1,storagePrefix:"angular-cache.caches.",storeOnResolve:!1,storeOnReject:!1};this.$get=["$q",function(c){function d(a,b){return k(a,b)}var e={},k=function(a,d){if(a in e)throw new Error(a+" already exists!");if(!f.isString(a))throw new Error("cacheId must be a string!");var k={},m={},n=null,o=new l(function(a){return a.expires},f.equals),p=new l(function(a){return a.accessed},f.equals),q=e[a]={$$id:a,destroy:function(){clearInterval(this.$$cacheFlushIntervalId),clearInterval(this.$$recycleFreqId),this.removeAll(),n&&(n().removeItem(this.$$prefix+".keys"),n().removeItem(this.$$prefix)),n=null,k=null,p=null,o=null,this.$$prefix=null,delete e[this.$$id]},disable:function(){this.$$disabled=!0},enable:function(){delete this.$$disabled},get:function(a,b){var c=this;if(f.isArray(a)){var d=function(){var d=a,e=[];return f.forEach(d,function(a){var d=c.get(a,b);null!==d&&void 0!==d&&e.push(d)}),{v:e}}();if("object"==typeof d)return d.v}else if(a=i(a),this.$$disabled)return;if(b=b||{},!f.isString(a))throw new Error("key must be a string!");if(b&&!f.isObject(b))throw new Error("options must be an object!");if(b.onExpire&&!f.isFunction(b.onExpire))throw new Error("options.onExpire must be a function!");var e=void 0;if(n){if(m[a])return m[a];var g=n().getItem(this.$$prefix+".data."+a);if(!g)return;e=f.fromJson(g)}else{if(!(a in k))return;e=k[a]}var h=e.value,j=(new Date).getTime();return n?(p.remove({key:a,accessed:e.accessed}),e.accessed=j,p.push({key:a,accessed:j})):(p.remove(e),e.accessed=j,p.push(e)),"passive"===this.$$deleteOnExpire&&"expires"in e&&e.expiresthis.$$maxAge}):void 0}return a in k?(b=k[a],{created:b.created,accessed:b.accessed,expires:b.expires,isExpired:(new Date).getTime()-b.created>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:n?n():void 0,disabled:!!this.$$disabled,size:p&&p.size()||0}},keys:function(){if(n){var a=n().getItem(this.$$prefix+".keys");return a?f.fromJson(a):[]}return g(k)},keySet:function(){if(n){var a=n().getItem(this.$$prefix+".keys"),b={};if(a)for(var c=f.fromJson(a),d=0;dthis.$$capacity&&this.remove(p.peek().key),b}},remove:function(a){if(a+="",delete m[a],!n){var b=k[a]?k[a].value:void 0;return p.remove(k[a]),o.remove(k[a]),k[a]=null,delete k[a],b}var c=n().getItem(this.$$prefix+".data."+a);if(c){var d=f.fromJson(c);p.remove({key:a,accessed:d.accessed}),o.remove({key:a,expires:d.expires}),n().removeItem(this.$$prefix+".data."+a);var e=n().getItem(this.$$prefix+".keys"),g=e?f.fromJson(e):[],h=g.indexOf(a);return h>=0&&g.splice(h,1),n().setItem(this.$$prefix+".keys",JSON.stringify(g)),d.value}},removeAll:function(){if(n){p.removeAll(),o.removeAll();var a=n().getItem(this.$$prefix+".keys");if(a)for(var b=f.fromJson(a),c=0;ca)throw new Error("cacheFlushInterval must be greater than zero!");a!==this.$$cacheFlushInterval&&(this.$$cacheFlushInterval=a,clearInterval(this.$$cacheFlushIntervalId),function(a){a.$$cacheFlushIntervalId=setInterval(function(){a.removeAll()},a.$$cacheFlushInterval)}(this))}},setCapacity:function(a){if(null===a)delete this.$$capacity;else{if(!f.isNumber(a))throw new Error("capacity must be a number!");if(0>a)throw new Error("capacity must be greater than zero!");this.$$capacity=a}for(var b={};p.size()>this.$$capacity;)b[p.peek().key]=this.remove(p.peek().key);return b},setDeleteOnExpire:function(a,b){if(null===a)delete this.$$deleteOnExpire;else{if(!f.isString(a))throw new Error("deleteOnExpire must be a string!");if("none"!==a&&"passive"!==a&&"aggressive"!==a)throw new Error('deleteOnExpire must be "none", "passive" or "aggressive"!');this.$$deleteOnExpire=a}b!==!1&&this.setRecycleFreq(this.$$recycleFreq)},setMaxAge:function(a){if(null===a)this.$$maxAge=Number.MAX_VALUE;else{if(!f.isNumber(a))throw new Error("maxAge must be a number!");if(0>a)throw new Error("maxAge must be greater than zero!");this.$$maxAge=a}var b=void 0,c=void 0,d=void 0;if(o.removeAll(),n){var e=n().getItem(this.$$prefix+".keys");for(c=e?f.fromJson(e):[],b=0;ba)throw new Error("recycleFreq must be greater than zero!");this.$$recycleFreq=a}clearInterval(this.$$recycleFreqId),"aggressive"===this.$$deleteOnExpire?!function(a){a.$$recycleFreqId=setInterval(function(){a.removeExpired()},a.$$recycleFreq)}(this):delete this.$$recycleFreqId},setStorageMode:function(a,b){if(!f.isString(a))throw new Error("storageMode must be a string!");if("memory"!==a&&"localStorage"!==a&&"sessionStorage"!==a)throw new Error('storageMode must be "memory", "localStorage" or "sessionStorage"!');var c=!1,d={};if("string"==typeof this.$$storageMode&&this.$$storageMode!==a){var e=this.keys();if(e.length){for(var g=0;g {
let keys = [], key;
@@ -976,4 +976,5 @@ angular.module('angular-cache', [])
.provider('BinaryHeap', BinaryHeapProvider)
.provider('CacheFactory', CacheFactoryProvider);
-export default 'angular-cache';
+module.exports = 'angular-cache';
+module.exports.name = 'angular-cache';