Skip to content

Commit a9ad988

Browse files
committed
Merge pull request #190 from stephenmathieson/browser/expose-storage
browser: expose `storage`
2 parents 9feaf47 + a6e8154 commit a9ad988

File tree

1 file changed

+7
-14
lines changed

1 file changed

+7
-14
lines changed

browser.js

+7-14
Original file line numberDiff line numberDiff line change
@@ -11,17 +11,10 @@ exports.formatArgs = formatArgs;
1111
exports.save = save;
1212
exports.load = load;
1313
exports.useColors = useColors;
14-
15-
/**
16-
* Use chrome.storage.local if we are in an app
17-
*/
18-
19-
var storage;
20-
21-
if (typeof chrome !== 'undefined' && typeof chrome.storage !== 'undefined')
22-
storage = chrome.storage.local;
23-
else
24-
storage = localstorage();
14+
exports.storage = 'undefined' != typeof chrome
15+
&& 'undefined' != typeof chrome.storage
16+
? chrome.storage.local
17+
: localstorage();
2518

2619
/**
2720
* Colors.
@@ -129,9 +122,9 @@ function log() {
129122
function save(namespaces) {
130123
try {
131124
if (null == namespaces) {
132-
storage.removeItem('debug');
125+
exports.storage.removeItem('debug');
133126
} else {
134-
storage.debug = namespaces;
127+
exports.storage.debug = namespaces;
135128
}
136129
} catch(e) {}
137130
}
@@ -146,7 +139,7 @@ function save(namespaces) {
146139
function load() {
147140
var r;
148141
try {
149-
r = storage.debug;
142+
r = exports.storage.debug;
150143
} catch(e) {}
151144
return r;
152145
}

0 commit comments

Comments
 (0)