godaddy / datastar

A robust and feature rich ODM for Cassandra.
MIT License
40 stars 12 forks source link

Simplify streams #31

Closed DullReferenceException closed 5 years ago

DullReferenceException commented 5 years ago

This change is part of the effort outlined in this priam PR. It also seeks to reduce the number of intermediate streams to streamline data processing, and it adds the ability to consume data as an async iterable without a node stream wrapper. Like the priam update, this breaks compatibility with versions of node without async iterables.

A pass was made to "modernize" the code as well to make it a bit easier for modern eyes to grok. This includes restructuring code as classes and replacing var-defined variables throughout. A bump to eslint being necessary to support async iterable syntax, so some eslint changes are also included.

Another refactoring was to change the common pattern throughout of functions returning instead of throwing errors. I believe this makes the code much easier to reason about and removed the need for a bunch of type checks on return values.

The refactoring will probably make the code a bit harder to review; you may find it easier to look commit-by-commit to see this as the incremental changes instead of one huge set of changes.