Open agladysh opened 1 year ago
Thanks, I like this idea, the only thing I would change is that I think streams can be more efficient than strings, and functionality-wise they are more basic/generic, so we actually need a stream API, similar to what your internal queryImpl does, and as your snippet shows it is fairly trivial to convert a string into a stream, so the API caller can easily do this outside the function.
IMO it should look something like this:
async function query_csv_stream(query_text, input_stream, input_delim, input_policy, output_stream, output_delim, output_policy, output_warnings, join_stream=null, with_headers=false, comment_prefix=null, user_init_code='', options=null)
I was looking for an easy way to handle CSV as strings (not files) today, and had to hack together a solution based on
query_csv()
, below.That could be a documentation issue (or even lack of attention on my end), but it seems that there are low-level (browser) APIs and a high-level (node) API, but no middle ground.
It might be nice to expose some friendly API to support middle ground use cases. The boilerplate is rather long now.
Or, for my case, just support CSV strings, if that is in scope of the library.
If I miss something and there is an easier solution, please do share. :-)
Sorry for the typescript, if you're interested, I can try to submit a pure-JS PR, provided you share your preferences on the API design.