| 743 | // usage reasonable. |
| 744 | const resultStream = new types.ResultStream({ objectMode: 1 }); |
| 745 | function onFinish(err, result) { |
| 746 | if (err) { |
| 747 | resultStream.emit('error', err); |
| 748 | } |
| 749 | if (result && result.nextPage ) { |
| 750 | // allows for throttling as per the |
| 751 | // default nodejs stream implementation |
| 752 | resultStream._valve(function pageValve() { |
| 753 | try { |
| 754 | result.nextPage(); |
| 755 | } |
| 756 | catch( ex ) { |
| 757 | resultStream.emit('error', ex ); |
| 758 | } |
| 759 | }); |
| 760 | return; |
| 761 | } |
| 762 | // Explicitly dropping the valve (closure) |
| 763 | resultStream._valve(null); |
| 764 | resultStream.add(null); |
| 765 | callback(err); |
| 766 | } |
| 767 | let sync = true; |
| 768 | this.eachRow(query, params, options, function rowCallback(n, row) { |
| 769 | resultStream.add(row); |