Created
June 21, 2014 08:41
-
-
Save stu43005/cd3aea3b2618afa75506 to your computer and use it in GitHub Desktop.
chrome.storage.local for [MinDB](https://github.com/iwillwen/mindb)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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