@@ -6,6 +6,7 @@ const char = (acc, [k, v]) => (acc[k.charCodeAt(0)] = v, acc)
6
6
module . exports = Backend
7
7
8
8
function Backend ( {
9
+ onparse,
9
10
onparameter,
10
11
parsers,
11
12
onauth,
@@ -53,7 +54,10 @@ function Backend({
53
54
54
55
return backend
55
56
56
- function ParseComplete ( ) { /* No handling needed */ }
57
+ function ParseComplete ( ) {
58
+ onparse ( )
59
+ }
60
+
57
61
function BindComplete ( ) { /* No handling needed */ }
58
62
function CloseComplete ( ) { /* No handling needed */ }
59
63
@@ -75,7 +79,7 @@ function Backend({
75
79
76
80
for ( let i = x . length - 1 ; i > 0 ; i -- ) {
77
81
if ( x [ i ] === 32 && x [ i + 1 ] < 58 && backend . query . result . count === null )
78
- backend . query . result . count = + x . utf8Slice ( i + 1 , x . length - 1 ) // eslint-disable-line
82
+ backend . query . result . count = + x . utf8Slice ( i + 1 , x . length - 1 )
79
83
if ( x [ i - 1 ] >= 65 ) {
80
84
backend . query . result . command = x . utf8Slice ( 5 , i )
81
85
break
@@ -88,7 +92,7 @@ function Backend({
88
92
)
89
93
}
90
94
91
- function CopyDone ( x ) { /* No handling needed */ }
95
+ function CopyDone ( ) { /* No handling needed */ }
92
96
93
97
function DataRow ( x ) {
94
98
let index = 7
@@ -115,20 +119,24 @@ function Backend({
115
119
: backend . query . result . push ( row )
116
120
}
117
121
118
- function CopyData ( x ) { /* No handling needed until implemented */ }
122
+ /* c8 ignore next */
123
+ function CopyData ( ) { /* No handling needed until implemented */ }
119
124
120
125
function ErrorResponse ( x ) {
121
126
reject ( errors . generic ( error ( x ) ) )
122
127
}
123
128
129
+ /* c8 ignore next */
124
130
function CopyInResponse ( ) {
125
131
reject ( errors . notSupported ( 'CopyInResponse' ) )
126
132
}
127
133
134
+ /* c8 ignore next */
128
135
function CopyOutResponse ( ) {
129
136
reject ( errors . notSupported ( 'CopyOutResponse' ) )
130
137
}
131
138
139
+ /* c8 ignore next */
132
140
function EmptyQueryResponse ( ) { /* No handling needed */ }
133
141
134
142
function BackendKeyData ( x ) {
@@ -139,26 +147,32 @@ function Backend({
139
147
function NoticeResponse ( x ) {
140
148
onnotice
141
149
? onnotice ( error ( x ) )
142
- : console . log ( error ( x ) )
150
+ : console . log ( error ( x ) ) // eslint-disable-line
143
151
}
144
152
145
- function NoData ( x ) { /* No handling needed */ }
153
+ function NoData ( ) { /* No handling needed */ }
146
154
147
155
function Authentication ( x ) {
148
156
const type = x . readInt32BE ( 5 )
149
- type !== 0 && onauth ( type , x )
157
+ try {
158
+ type !== 0 && onauth ( type , x )
159
+ } catch ( err ) {
160
+ reject ( err )
161
+ }
150
162
}
151
163
152
164
function ParameterStatus ( x ) {
153
165
const [ k , v ] = x . utf8Slice ( 5 , x . length - 1 ) . split ( N )
154
166
onparameter ( k , v )
155
167
}
156
168
157
- function PortalSuspended ( x ) {
169
+ /* c8 ignore next */
170
+ function PortalSuspended ( ) {
158
171
reject ( errors . notSupported ( 'PortalSuspended' ) )
159
172
}
160
173
161
- function ParameterDescription ( x ) {
174
+ /* c8 ignore next */
175
+ function ParameterDescription ( ) {
162
176
reject ( errors . notSupported ( 'ParameterDescription' ) )
163
177
}
164
178
@@ -185,22 +199,24 @@ function Backend({
185
199
}
186
200
}
187
201
188
- function FunctionCallResponse ( x ) {
202
+ /* c8 ignore next */
203
+ function FunctionCallResponse ( ) {
189
204
reject ( errors . notSupported ( 'FunctionCallResponse' ) )
190
205
}
191
206
192
- function NegotiateProtocolVersion ( x ) {
207
+ /* c8 ignore next */
208
+ function NegotiateProtocolVersion ( ) {
193
209
reject ( errors . notSupported ( 'NegotiateProtocolVersion' ) )
194
210
}
195
211
196
- function CopyBothResponse ( x ) {
212
+ /* c8 ignore next */
213
+ function CopyBothResponse ( ) {
197
214
reject ( errors . notSupported ( 'CopyBothResponse' ) )
198
215
}
199
216
200
- function ReadyForQuery ( x ) {
217
+ function ReadyForQuery ( ) {
201
218
onready ( )
202
219
}
203
-
204
220
}
205
221
206
222
function error ( x ) {
0 commit comments