angular-marshall.storage
Advanced tools
Comparing version 0.1.3 to 0.2.0
{ | ||
"name": "angular-marshall.storage", | ||
"version": "0.1.3", | ||
"version": "0.2.0", | ||
"description": "A simple localStorage service for angular.", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
@@ -22,2 +22,22 @@ # Angular LocalStorage Service | ||
.module('example', ['marshall.storage']) | ||
.run(function () { | ||
var storage = storageService('example.'); | ||
// Number | ||
storage.set('foobar', 123); | ||
console.log(storage.get('foobar')); // '123' (String) | ||
console.log(storage.get('foobar', Number)); // 123 (Number) | ||
// JSON | ||
storage.set('foobar', JSON.stringify({ one: 'two' })); | ||
console.log(storage.get('foobar')); // '{"one":"two"}' (String) | ||
console.log(storage.get('foobar', JSON.parse)); // { one: 'two' } (Object) | ||
}); | ||
``` | ||
```js | ||
angular | ||
.module('example', ['marshall.storage']) | ||
.run(function (storageService) { | ||
@@ -24,0 +44,0 @@ var storage = storageService('example.'); |
@@ -60,6 +60,11 @@ /*! | ||
* @param {String} key | ||
* @param {Function} [parser] | ||
* @returns {String|null} | ||
*/ | ||
proto.get = function (key) { | ||
return priv.safeStorage.call(this, 'getItem', this.prefix + key); | ||
proto.get = function (key, parser) { | ||
if (typeof parser !== 'function') { | ||
parser = function (value) { return value; }; | ||
} | ||
return parser(priv.safeStorage.call(this, 'getItem', this.prefix + key)); | ||
}; | ||
@@ -66,0 +71,0 @@ |
Sorry, the diff of this file is not supported yet
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
48738
376
102