angular-storage
Advanced tools
Comparing version 0.0.6 to 0.0.8
@@ -20,8 +20,11 @@ { | ||
"dependencies": { | ||
"angular": "~1.2.21" | ||
"angular": "*" | ||
}, | ||
"devDependencies": { | ||
"angular-mocks": "~1.2.21", | ||
"angular-scenario": "~1.2.21" | ||
"angular-mocks": ">= 1.2", | ||
"angular-scenario": ">= 1.2" | ||
}, | ||
"resolutions": { | ||
"angular": "1.3.3" | ||
} | ||
} | ||
} |
{ | ||
"name": "angular-storage", | ||
"version": "0.0.6", | ||
"version": "0.0.8", | ||
"author": { | ||
@@ -34,2 +34,2 @@ "name": "Martin Gontovnikas", | ||
} | ||
} | ||
} |
@@ -9,4 +9,4 @@ # angular-storage | ||
* Lets you **save JS Objects** | ||
* If **you save an `Number`, you get an `Number`**, not a String | ||
* Uses a **caching system** so that if you already got a value, it won't get it from the store again. | ||
* If **you save a `Number`, you get a `Number`**, not a String | ||
* Uses a **caching system** so that if you already have a value, it won't get it from the store again. | ||
@@ -59,3 +59,3 @@ ## Installing it | ||
.factory('Auth0Store', function(store) { | ||
reutrn store.getNamespacedStore('auth0'); | ||
return store.getNamespacedStore('auth0'); | ||
}) | ||
@@ -75,8 +75,2 @@ .controller('Controller', function(Auth0Store) { | ||
angular.equals(myNewObject, myObj); // return true | ||
Auth0Store.remove('obj'); | ||
store.set('number', 2); | ||
typeof(store.get('number')) === 'number' | ||
}); | ||
@@ -101,3 +95,3 @@ ```` | ||
Returns a new `store` service that will use the `nanespace` and `delimiter` when saving and getting values like the following `namespace[delimiter]key`. For example `auth0.object` considering `auth0` as `namespace` and `.` as a `delimiter` | ||
Returns a new `store` service that will use the `namespace` and `delimiter` when saving and getting values like the following `namespace[delimiter]key`. For example `auth0.object` considering `auth0` as `namespace` and `.` as a `delimiter` | ||
@@ -112,2 +106,6 @@ ## Usages | ||
## Issue Reporting | ||
If you have found a bug or if you have a feature request, please report them at this repository issues section. Please do not report security vulnerabilities on the public GitHub issue tracker. The [Responsible Disclosure Program](https://auth0.com/whitehat) details the procedure for disclosing security issues. | ||
## License | ||
@@ -114,0 +112,0 @@ |
angular.module('angular-storage.internalStore', ['angular-storage.storage']) | ||
.factory('InternalStore', function(storage) { | ||
.factory('InternalStore', function(storage, $log) { | ||
@@ -16,3 +16,3 @@ function InternalStore(namespace, delimiter) { | ||
} | ||
} | ||
}; | ||
@@ -27,2 +27,3 @@ | ||
InternalStore.prototype.get = function(name) { | ||
var obj = null; | ||
if (name in this.inMemoryCache) { | ||
@@ -32,4 +33,15 @@ return this.inMemoryCache[name]; | ||
var saved = storage.get(this.getNamespacedKey(name)); | ||
var obj = saved ? JSON.parse(saved) : null; | ||
this.inMemoryCache[name] = obj; | ||
try { | ||
if (typeof saved ==="undefined" || saved === "undefined") { | ||
obj = undefined; | ||
} else { | ||
obj = JSON.parse(saved); | ||
} | ||
this.inMemoryCache[name] = obj; | ||
} catch(e) { | ||
$log.error("Error parsing saved value", e); | ||
this.remove(name); | ||
} | ||
return obj; | ||
@@ -41,3 +53,3 @@ }; | ||
storage.remove(this.getNamespacedKey(name)); | ||
} | ||
}; | ||
@@ -44,0 +56,0 @@ return InternalStore; |
angular.module('angular-storage.storage', []) | ||
.service('storage', function($window) { | ||
.service('storage', function($window, $injector) { | ||
if ($window.localStorage) { | ||
@@ -4,0 +4,0 @@ this.set = function(what, value) { |
@@ -15,2 +15,14 @@ 'use strict'; | ||
it('should save null items correctly in localStorage', inject(function(store) { | ||
store.set('gonto', null); | ||
store.inMemoryCache = {}; | ||
expect(store.get('gonto')).to.equal(null); | ||
})); | ||
it('should save undefined items correctly in localStorage', inject(function(store) { | ||
store.set('gonto', undefined); | ||
store.inMemoryCache = {}; | ||
expect(store.get('gonto')).to.equal(undefined); | ||
})); | ||
it('should delete items correctly from localStorage', inject(function(store) { | ||
@@ -17,0 +29,0 @@ var value = 1; |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
27080
567
129