Skip to content

Commit

Permalink
Merge pull request #190 from stephenmathieson/browser/expose-storage
Browse files Browse the repository at this point in the history
browser: expose `storage`
  • Loading branch information
TooTallNate committed Mar 26, 2015
2 parents 9feaf47 + a6e8154 commit a9ad988
Showing 1 changed file with 7 additions and 14 deletions.
21 changes: 7 additions & 14 deletions browser.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,10 @@ exports.formatArgs = formatArgs;
exports.save = save;
exports.load = load;
exports.useColors = useColors;

/**
* Use chrome.storage.local if we are in an app
*/

var storage;

if (typeof chrome !== 'undefined' && typeof chrome.storage !== 'undefined')
storage = chrome.storage.local;
else
storage = localstorage();
exports.storage = 'undefined' != typeof chrome
&& 'undefined' != typeof chrome.storage
? chrome.storage.local
: localstorage();

/**
* Colors.
Expand Down Expand Up @@ -129,9 +122,9 @@ function log() {
function save(namespaces) {
try {
if (null == namespaces) {
storage.removeItem('debug');
exports.storage.removeItem('debug');
} else {
storage.debug = namespaces;
exports.storage.debug = namespaces;
}
} catch(e) {}
}
Expand All @@ -146,7 +139,7 @@ function save(namespaces) {
function load() {
var r;
try {
r = storage.debug;
r = exports.storage.debug;
} catch(e) {}
return r;
}
Expand Down

0 comments on commit a9ad988

Please sign in to comment.