Skip to content

Commit 84616a9

Browse files
committed
Fixes #200.
Fixes #201. Stable Version 4.4.0
1 parent 70a5884 commit 84616a9

7 files changed

+69
-40
lines changed

CHANGELOG.md

+5
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
##### 4.4.0 12 October 2015
2+
3+
- #200 - 4.3 storagePrefix is not backwards compatible
4+
- #201 - webpack minification error
5+
16
##### 4.3.2 10 July 2015
27

38
- #191 - yabh issue with ie8

Gruntfile.js

+14
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,19 @@ module.exports = function (grunt) {
106106
'test/**/*.js'
107107
]
108108
}
109+
},
110+
c9: {
111+
browsers: ['PhantomJS'],
112+
options: {
113+
files: [
114+
'bower_components/angular-1.2.25/angular.js',
115+
'bower_components/angular-resource/angular-resource.js',
116+
'bower_components/angular-mocks-1.2.25/angular-mocks.js',
117+
'dist/angular-cache.min.js',
118+
'./karma.start.js',
119+
'test/**/*.js'
120+
]
121+
}
109122
}
110123
},
111124
coveralls: {
@@ -116,6 +129,7 @@ module.exports = function (grunt) {
116129
});
117130

118131
grunt.registerTask('test', ['build', 'karma:dist', 'karma:min']);
132+
grunt.registerTask('test_c9', ['build', 'karma:c9']);
119133
grunt.registerTask('build', [
120134
'clean',
121135
'webpack',

dist/angular-cache.js

+25-20
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*!
22
* angular-cache
3-
* @version 4.3.2 - Homepage <http://jmdobry.github.io/angular-cache/>
3+
* @version 4.4.0 - Homepage <http://jmdobry.github.io/angular-cache/>
44
* @author Jason Dobry <[email protected]>
55
* @copyright (c) 2013-2015 Jason Dobry
66
* @license MIT <https://github.com/jmdobry/angular-cache/blob/master/LICENSE>
@@ -84,6 +84,7 @@ return /******/ (function(modules) { // webpackBootstrap
8484
_classCallCheck(this, CacheFactoryProvider);
8585

8686
this.defaults = CacheFactory.defaults;
87+
this.defaults.storagePrefix = 'angular-cache.caches.';
8788

8889
this.$get = ['$q', function ($q) {
8990
CacheFactory.utils.Promise = $q;
@@ -94,11 +95,13 @@ return /******/ (function(modules) { // webpackBootstrap
9495
angular.module('angular-cache', []).provider('BinaryHeap', BinaryHeapProvider).provider('CacheFactory', CacheFactoryProvider);
9596

9697
module.exports = 'angular-cache';
97-
module.exports.name = 'angular-cache';
98+
try {
99+
module.exports.name = 'angular-cache';
100+
} catch (err) {}
98101

99102
/***/ },
100103
/* 1 */
101-
/***/ function(module, exports, __webpack_require__) {
104+
/***/ function(module, exports) {
102105

103106
module.exports = __WEBPACK_EXTERNAL_MODULE_1__;
104107

@@ -108,7 +111,7 @@ return /******/ (function(modules) { // webpackBootstrap
108111

109112
/*!
110113
* cachefactory
111-
* @version 1.1.0 - Homepage <http://jmdobry.github.io/cachefactory/>
114+
* @version 1.2.0 - Homepage <http://jmdobry.github.io/cachefactory/>
112115
* @author Jason Dobry <[email protected]>
113116
* @copyright (c) 2013-2015 Jason Dobry
114117
* @license MIT <https://github.com/jmdobry/cachefactory/blob/master/LICENSE>
@@ -119,7 +122,7 @@ return /******/ (function(modules) { // webpackBootstrap
119122
if(true)
120123
module.exports = factory();
121124
else if(typeof define === 'function' && define.amd)
122-
define(factory);
125+
define([], factory);
123126
else if(typeof exports === 'object')
124127
exports["CacheFactory"] = factory();
125128
else
@@ -407,7 +410,7 @@ return /******/ (function(modules) { // webpackBootstrap
407410
created: item.created,
408411
accessed: item.accessed,
409412
expires: item.expires,
410-
isExpired: new Date().getTime() - item.created > this.$$maxAge
413+
isExpired: new Date().getTime() - item.created > (item.maxAge || this.$$maxAge)
411414
};
412415
} else {
413416
return undefined;
@@ -420,7 +423,7 @@ return /******/ (function(modules) { // webpackBootstrap
420423
created: item.created,
421424
accessed: item.accessed,
422425
expires: item.expires,
423-
isExpired: new Date().getTime() - item.created > this.$$maxAge
426+
isExpired: new Date().getTime() - item.created > (item.maxAge || this.$$maxAge)
424427
};
425428
} else {
426429
return undefined;
@@ -523,7 +526,11 @@ return /******/ (function(modules) { // webpackBootstrap
523526
accessed: now
524527
};
525528

526-
item.expires = item.created + this.$$maxAge;
529+
if (options.maxAge) {
530+
item.maxAge = options.maxAge;
531+
}
532+
533+
item.expires = item.created + (item.maxAge || this.$$maxAge);
527534

528535
if ($$storage) {
529536
if (_isPromiseLike(item.value)) {
@@ -759,7 +766,7 @@ return /******/ (function(modules) { // webpackBootstrap
759766
if (this.$$maxAge === Number.MAX_VALUE) {
760767
item.expires = Number.MAX_VALUE;
761768
} else {
762-
item.expires = item.created + this.$$maxAge;
769+
item.expires = item.created + (item.maxAge || this.$$maxAge);
763770
}
764771
$$expiresHeap.push({
765772
key: key,
@@ -775,7 +782,7 @@ return /******/ (function(modules) { // webpackBootstrap
775782
if (this.$$maxAge === Number.MAX_VALUE) {
776783
$$data[key].expires = Number.MAX_VALUE;
777784
} else {
778-
$$data[key].expires = $$data[key].created + this.$$maxAge;
785+
$$data[key].expires = $$data[key].created + ($$data[key].maxAge || this.$$maxAge);
779786
}
780787
$$expiresHeap.push($$data[key]);
781788
}
@@ -905,18 +912,16 @@ return /******/ (function(modules) { // webpackBootstrap
905912
var shouldReInsert = false;
906913
var items = {};
907914

908-
if (typeof this.$$storageMode === 'string' && this.$$storageMode !== storageMode) {
909-
var keys = this.keys();
915+
var keys = this.keys();
910916

911-
if (keys.length) {
912-
for (var i = 0; i < keys.length; i++) {
913-
items[keys[i]] = this.get(keys[i]);
914-
}
915-
for (i = 0; i < keys.length; i++) {
916-
this.remove(keys[i]);
917-
}
918-
shouldReInsert = true;
917+
if (keys.length) {
918+
for (var i = 0; i < keys.length; i++) {
919+
items[keys[i]] = this.get(keys[i]);
920+
}
921+
for (i = 0; i < keys.length; i++) {
922+
this.remove(keys[i]);
919923
}
924+
shouldReInsert = true;
920925
}
921926

922927
this.$$storageMode = storageMode;

0 commit comments

Comments
 (0)