Skip to content

Synchronous read and write #61645

@cyberphone

Description

@cyberphone

What is the problem this feature will solve?

I have a CBOR parser that in Java and Python reads one byte at a time from a virtual stream (like C's fgetc).
With this system I can provide a stream pointing to memory or received via an HTTP response.

There is (AFAICT) no such feature in JavaScript or Nodejs making the JavaScript version of the CBOR parser a bit underwhelming.

I believe there are a lot of machine to machine solutions that could benefit from a simple blocking stream solution. Trivial in Python. HTTP version:

import http.client

conn = http.client.HTTPSConnection("cyberphone.github.io")
conn.request("GET", "/javaapi/app-notes/large-payloads/metadata.cbor")
response = conn.getresponse()
print(response.status, response.reason)
CBOR.init_decoder(response, 10000).decode_with_options()

Memory buffer version:

CBOR.init_decoder(io.BytesIO(cbor_bytes), len(cbor_bytes)).decode_with_options()

For the CBOR parser these constructs appear identical.

Advanced example using Java:
https://github.com/cyberphone/javaapi/tree/gh-pages/app-notes/large-payloads

What is the feature you are proposing to solve the problem?

Something along the lines above

What alternatives have you considered?

I'm not aware of any workarounds that would require a completely redesigned parser

Metadata

Metadata

Assignees

No one assigned

    Labels

    feature requestIssues that request new features to be added to Node.js.

    Type

    No type

    Projects

    Status

    Awaiting Triage

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions