cross-domain-storage
Advanced tools
Comparing version 2.0.7 to 2.1.0-beta.0
@@ -118,2 +118,18 @@ 'use strict'; | ||
function getSession(key, callback) { | ||
if (!callback) { | ||
throw new Error('callback required for get'); | ||
} | ||
message('getSession', key, null, callback); | ||
} | ||
function setSession(key, value, callback) { | ||
message('setSession', key, value, callback); | ||
} | ||
function removeSession(key, callback) { | ||
message('removeSession', key, null, callback); | ||
} | ||
function checkConnected() { | ||
@@ -138,4 +154,7 @@ if (connected) { | ||
remove: remove, | ||
getSession: getSession, | ||
setSession: setSession, | ||
removeSession: removeSession, | ||
close: close | ||
}; | ||
}; |
'use strict'; | ||
var connectId = 'sessionAccessId-connected'; | ||
var LOCAL_STORAGE = 'localStorage'; | ||
var SESSION_STORAGE = 'sessionStorage'; | ||
module.exports = { | ||
get: function get(event, data) { | ||
var storageType = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : LOCAL_STORAGE; | ||
event.source.postMessage({ | ||
id: data.id, | ||
data: window.localStorage.getItem(data.key) | ||
data: window[storageType].getItem(data.key) | ||
}, event.origin); | ||
}, | ||
set: function set(event, data) { | ||
window.localStorage.setItem(data.key, data.value); | ||
var storageType = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : LOCAL_STORAGE; | ||
window[storageType].setItem(data.key, data.value); | ||
event.source.postMessage({ | ||
@@ -20,4 +26,6 @@ id: data.id | ||
remove: function remove(event, data) { | ||
window.localStorage.removeItem(data.key); | ||
var storageType = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : LOCAL_STORAGE; | ||
window[storageType].removeItem(data.key); | ||
event.source.postMessage({ | ||
@@ -27,2 +35,11 @@ id: data.id | ||
}, | ||
getSession: function getSession(event, data) { | ||
this.get(event, data, SESSION_STORAGE); | ||
}, | ||
setSession: function setSession(event, data) { | ||
this.set(event, data, SESSION_STORAGE); | ||
}, | ||
removeSession: function removeSession(event, data) { | ||
this.remove(event, data, SESSION_STORAGE); | ||
}, | ||
connect: function connect(event) { | ||
@@ -29,0 +46,0 @@ event.source.postMessage({ |
{ | ||
"name": "cross-domain-storage", | ||
"version": "2.0.7", | ||
"version": "2.1.0-beta.0", | ||
"description": "Cross domain local storage", | ||
@@ -5,0 +5,0 @@ "main": "./", |
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
11376
213
1