react-native-storage
Advanced tools
Comparing version 0.0.11 to 0.0.12
{ | ||
"name": "react-native-storage", | ||
"version": "0.0.11", | ||
"version": "0.0.12", | ||
"description": "This is a local storage wrapper for both react-native(AsyncStorage) and browser(localStorage). ES6/babel is needed.", | ||
@@ -5,0 +5,0 @@ "main": "storage.js", |
/* | ||
* local storage(web/react native) wrapper | ||
* sunnylqm 2016-01-03 | ||
* version 0.0.10 | ||
* sunnylqm 2016-01-26 | ||
* version 0.0.12 | ||
*/ | ||
@@ -30,2 +30,3 @@ | ||
console.warn(e); | ||
delete me._s; | ||
throw e; | ||
@@ -39,3 +40,3 @@ } | ||
me._mapPromise = me.getItem('map').then( map => { | ||
me._m = me._checkMap(JSON.parse(map)); | ||
me._m = me._checkMap(map && JSON.parse(map) || {}); | ||
delete me._mapPromise; | ||
@@ -45,9 +46,20 @@ }); | ||
getItem(key) { | ||
return this.isBrowser ? new Promise((resolve, reject) => resolve(this._s.getItem(key))) : this._s.getItem(key); | ||
return this._s | ||
? | ||
this.isBrowser ? new Promise((resolve, reject) => resolve(this._s.getItem(key))) : this._s.getItem(key) | ||
: | ||
Promise.resolve(); | ||
} | ||
setItem(key, value) { | ||
return this.isBrowser ? new Promise((resolve, reject) => resolve(this._s.setItem(key, value))) : this._s.setItem(key, value); | ||
return this._s | ||
? | ||
this.isBrowser ? new Promise((resolve, reject) => resolve(this._s.setItem(key, value))) : this._s.setItem(key, value) | ||
: | ||
Promise.resolve(); | ||
} | ||
removeItem(key) { | ||
return this.isBrowser ? new Promise((resolve, reject) => resolve(this._s.removeItem(key))) : this._s.removeItem(key); | ||
return this._s | ||
? this.isBrowser ? new Promise((resolve, reject) => resolve(this._s.removeItem(key))) : this._s.removeItem(key) | ||
: | ||
Promise.resolve(); | ||
} | ||
@@ -54,0 +66,0 @@ _checkMap(map) { |
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
44884
944