Skip to content

Instantly share code, notes, and snippets.

@stu43005
Created June 21, 2014 08:41
Show Gist options
  • Save stu43005/cd3aea3b2618afa75506 to your computer and use it in GitHub Desktop.
Save stu43005/cd3aea3b2618afa75506 to your computer and use it in GitHub Desktop.
chrome.storage.local for [MinDB](https://github.com/iwillwen/mindb)
function chromeStorageLocal() {
this.storageArea = chrome.storage.local;
this.async = true;
}
chromeStorageLocal.prototype.get = function(key, callback) {
this.storageArea.get(key, function(items) {
if (chrome.runtime.lastError) {
callback(chrome.runtime.lastError);
} else {
callback(null, items[key]);
}
});
};
chromeStorageLocal.prototype.set = function(key, value, callback) {
var obj = {};
obj[key] = value;
this.storageArea.set(obj, function() {
if (chrome.runtime.lastError) {
callback(chrome.runtime.lastError);
} else {
callback();
}
});
};
chromeStorageLocal.prototype.remove = function(key, callback) {
this.storageArea.remove(key, function() {
if (chrome.runtime.lastError) {
callback(chrome.runtime.lastError);
} else {
callback();
}
});
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment