(rows, cb)
| 232 | } |
| 233 | |
| 234 | read(rows, cb) { |
| 235 | let promise |
| 236 | |
| 237 | if (!cb) { |
| 238 | promise = new this._Promise((resolve, reject) => { |
| 239 | cb = (err, rows) => (err ? reject(err) : resolve(rows)) |
| 240 | }) |
| 241 | } |
| 242 | |
| 243 | if (this.state === 'idle' || this.state === 'submitted') { |
| 244 | this._getRows(rows, cb) |
| 245 | } else if (this.state === 'busy' || this.state === 'initialized') { |
| 246 | this._queue.push([rows, cb]) |
| 247 | } else if (this.state === 'error') { |
| 248 | setImmediate(() => cb(this._error)) |
| 249 | } else if (this.state === 'done') { |
| 250 | setImmediate(() => cb(null, [])) |
| 251 | } else { |
| 252 | throw new Error('Unknown state: ' + this.state) |
| 253 | } |
| 254 | |
| 255 | // Return the promise (or undefined) |
| 256 | return promise |
| 257 | } |
| 258 | } |
| 259 | |
| 260 | Cursor.prototype.end = util.deprecate( |
no test coverage detected