(key, callback)
| 63 | } |
| 64 | |
| 65 | function getItem(key, callback) { |
| 66 | var self = this; |
| 67 | |
| 68 | // Cast the key to a string, as that's all we can set as a key. |
| 69 | if (typeof key !== 'string') { |
| 70 | window.console.warn( |
| 71 | key + ' used as a key, but it is not a string.' |
| 72 | ); |
| 73 | key = String(key); |
| 74 | } |
| 75 | |
| 76 | var promise = new Promise(function(resolve, reject) { |
| 77 | self |
| 78 | .ready() |
| 79 | .then(function() { |
| 80 | try { |
| 81 | var db = self._dbInfo.db; |
| 82 | var result = db[key]; |
| 83 | |
| 84 | if (result) { |
| 85 | result = _deserialize(result); |
| 86 | } |
| 87 | |
| 88 | resolve(result); |
| 89 | } catch (e) { |
| 90 | reject(e); |
| 91 | } |
| 92 | }) |
| 93 | .catch(reject); |
| 94 | }); |
| 95 | |
| 96 | executeCallback(promise, callback); |
| 97 | return promise; |
| 98 | } |
| 99 | |
| 100 | function iterate(callback) { |
| 101 | var self = this; |
nothing calls this directly
no test coverage detected
searching dependent graphs…