* Add similar promise variables to read() and close() as seen in query()
* Add testing for promise specific usage
* Simplify tests as no real callbacks are involved
Removes usage of `done()` since we can end the test when we exit the function
Co-Authored-By: Charmander <~@charmander.me>
* Switch to let over var
Co-authored-by: Charmander <~@charmander.me>
* Turn Cursor into an ES6 class
* Fix incorrect syntax in Cursor.end()
* Remove extraneous empty line
* Revert es6 change for end()
* Revert back to defining the end() method inside the class
* Use hanging indent to satisfy Prettier
* Adding pg to peerDependencies
Yarn2 requires strict imports, I.E. all project dependencies need to exist in that project's package.json.
* pg version should be locked on the major version
Co-authored-by: Charmander <~@charmander.me>
Co-authored-by: Charmander <~@charmander.me>
This is fixing a double readyForQuery message being sent from the backend (because we were calling sync after an error, which I already fixed in the main driver). Also closes#2333
* Fix pg-query-stream
There were some subtle behaviors with the stream being implemented incorrectly & not working as expected with async iteration. I've modified the code based on #2050 and comments in #2035 to have better test coverage of async iterables and update the internals significantly to more closely match the readable stream interface.
Note: this is a __breaking__ (semver major) change to this package as the close event behavior is changed slightly, and `highWaterMark` is no longer supported. It shouldn't impact most usage, but breaking regardless.
* Remove a bunch of additional code
* Add test for destroy + error propagation
* Add failing test for destroying unsubmitted stream
* Do not throw an uncatchable error when closing an unused cursor
Working on fixing some timing issues in pg-query-stream it uncovered an issue where the cursor is firing its 'close' callback before it's actually entirely ready to dispatch another query. This change makes the close callback trigger when the connection re-enters `readyForQuery` state.