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