mirror of
https://github.com/brianc/node-postgres.git
synced 2025-12-08 20:16:25 +00:00
* feat(): start converting pg-query stream * feat(): solution project, initial version of typescript-pg-query stream * chore(): mocha with typescript * fix(): eslint ignore query stream dist * refactor(pg-query-stream): convert test to ts * chore(): fixed type errors * chore(): fix helper usage * chore(): use ts-node compatibile with node v8 * fix(): addd es extension * chore(): remove emitClose and added compilation for async iterators * chore(): condition for asyc iteration test * chore(): rename class to match ts-defs * chore(): tests to import from src instead of dist * chore(): remove prettier from peer deps: * chore(): update lock file
32 lines
711 B
TypeScript
32 lines
711 B
TypeScript
import helper from './helper'
|
|
import QueryStream from '../src'
|
|
import concat from 'concat-stream'
|
|
|
|
import { Transform } from 'stream'
|
|
|
|
const mapper = new Transform({ objectMode: true })
|
|
|
|
mapper._transform = function (obj, enc, cb) {
|
|
this.push(obj)
|
|
setTimeout(cb, 5)
|
|
}
|
|
|
|
helper('slow reader', function (client) {
|
|
it('works', function (done) {
|
|
this.timeout(50000)
|
|
const stream = new QueryStream('SELECT * FROM generate_series(0, 201) num', [], {
|
|
highWaterMark: 100,
|
|
batchSize: 50,
|
|
})
|
|
stream.on('end', function () {
|
|
// console.log('stream end')
|
|
})
|
|
client.query(stream)
|
|
stream.pipe(mapper).pipe(
|
|
concat(function (res) {
|
|
done()
|
|
})
|
|
)
|
|
})
|
|
})
|