mirror of
https://github.com/brianc/node-postgres.git
synced 2026-01-25 16:03:13 +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
27 lines
678 B
TypeScript
27 lines
678 B
TypeScript
import helper from './helper'
|
|
import concat from 'concat-stream'
|
|
import tester from 'stream-tester'
|
|
import JSONStream from 'JSONStream'
|
|
import QueryStream from '../src'
|
|
|
|
helper('pauses', function (client) {
|
|
it('pauses', function (done) {
|
|
this.timeout(5000)
|
|
const stream = new QueryStream('SELECT * FROM generate_series(0, $1) num', [200], {
|
|
batchSize: 2,
|
|
highWaterMark: 2,
|
|
})
|
|
const query = client.query(stream)
|
|
const pauser = tester.createPauseStream(0.1, 100)
|
|
query
|
|
.pipe(JSONStream.stringify())
|
|
.pipe(pauser)
|
|
.pipe(
|
|
concat(function (json) {
|
|
JSON.parse(json)
|
|
done()
|
|
})
|
|
)
|
|
})
|
|
})
|