Skip to content

Commit 9935c92

Browse files
committed
chore(): rename class to match ts-defs
1 parent 66d4bb4 commit 9935c92

File tree

1 file changed

+11
-10
lines changed

1 file changed

+11
-10
lines changed

Diff for: packages/pg-query-stream/src/index.ts

+11-10
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,17 @@ import { Readable } from 'stream'
22
import { Submittable, Connection } from 'pg'
33
import Cursor from 'pg-cursor'
44

5-
interface PgQueryStreamConfig {
5+
interface QueryStreamConfig {
66
batchSize?: number
77
highWaterMark?: number
88
rowMode?: 'array'
99
types?: any
1010
}
1111

12-
class PgQueryStream extends Readable implements Submittable {
12+
class QueryStream extends Readable implements Submittable {
1313
cursor: any
14+
_result: any
15+
1416
handleRowDescription: Function
1517
handleDataRow: Function
1618
handlePortalSuspended: Function
@@ -19,9 +21,7 @@ class PgQueryStream extends Readable implements Submittable {
1921
handleError: Function
2022
handleEmptyQuery: Function
2123

22-
_result: any
23-
24-
constructor(text: string, values?: any[], config: PgQueryStreamConfig = {}) {
24+
public constructor(text: string, values?: any[], config: QueryStreamConfig = {}) {
2525
const { batchSize, highWaterMark = 100 } = config
2626

2727
super({ objectMode: true, autoDestroy: true, highWaterMark: batchSize || highWaterMark })
@@ -40,20 +40,21 @@ class PgQueryStream extends Readable implements Submittable {
4040
this._result = this.cursor._result
4141
}
4242

43-
submit(connection: Connection): void {
43+
public submit(connection: Connection): void {
4444
this.cursor.submit(connection)
4545
}
4646

47-
_destroy(_err: Error, cb: Function) {
47+
public _destroy(_err: Error, cb: Function) {
4848
this.cursor.close((err?: Error) => {
4949
cb(err || _err)
5050
})
5151
}
5252

5353
// https://nodejs.org/api/stream.html#stream_readable_read_size_1
54-
_read(size: number) {
55-
this.cursor.read(size, (err: Error, rows: any[], result: any) => {
54+
public _read(size: number) {
55+
this.cursor.read(size, (err: Error, rows: any[]) => {
5656
if (err) {
57+
// https://nodejs.org/api/stream.html#stream_errors_while_reading
5758
this.destroy(err)
5859
} else {
5960
for (const row of rows) this.push(row)
@@ -63,4 +64,4 @@ class PgQueryStream extends Readable implements Submittable {
6364
}
6465
}
6566

66-
export = PgQueryStream
67+
export = QueryStream

0 commit comments

Comments
 (0)