(name, callback)
| 161 | } |
| 162 | |
| 163 | function adapterFun(name, callback) { |
| 164 | return toPromise(function (...args) { |
| 165 | if (this._closed) { |
| 166 | return Promise.reject(new Error('database is closed')); |
| 167 | } |
| 168 | if (this._destroyed) { |
| 169 | return Promise.reject(new Error('database is destroyed')); |
| 170 | } |
| 171 | var self = this; |
| 172 | logApiCall(self, name, args); |
| 173 | if (!this.taskqueue.isReady) { |
| 174 | return new Promise(function (fulfill, reject) { |
| 175 | self.taskqueue.addTask(function (failed) { |
| 176 | if (failed) { |
| 177 | reject(failed); |
| 178 | } else { |
| 179 | fulfill(self[name].apply(self, args)); |
| 180 | } |
| 181 | }); |
| 182 | }); |
| 183 | } |
| 184 | return callback.apply(this, args); |
| 185 | }); |
| 186 | } |
| 187 | |
| 188 | // like underscore/lodash _.pick() |
| 189 | function pick(obj, arr) { |
no test coverage detected
searching dependent graphs…