Skip to content

Allow browser parse API to consume Uint8Array #458

@imirkin

Description

@imirkin

Summary

The current types accepted by e.g. esm/sync.d.ts::parse() are Buffer | string. But there's no way to access the Buffer class as it is not exported.

Motivation

I have a Uint8Array that I would like to pass in. Given that the built-in Buffer class is an overlay on top of Uint8Array, seems like that should be easy to hook up.

Alternative

I've been implementing this by importing a different Buffer implementation which apparently is close enough to fool the typescript types and the internal processing of csv-parse to work out. This is not ideal.

Draft

Change esm/sync.js::parse() and related APIs to explicitly allow a Uint8Array to be passed in, and wrap it in the local Buffer type directly (or copy it to a fresh one if that's preferable). Perhaps it makes sense to include other TypedArray types as well.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions