Skip to content

Support Browser environments #4

@MarcoPolo

Description

@MarcoPolo

Hey Paolo, thanks for making this. It's just what I needed for the js-libp2p implementation of libp2p+HTTP (tl;dr - partial summary - run HTTP request/response on top of libp2p streams).

I got milo working as the HTTP parser in the browser, with a couple of changes to use TypedArrays instead of the Node-only Buffer. It's not too much work.

Would you be open to merging a change to support browser (and non-node) environments?

I see a couple of options:

  1. Add a small polyfill for the methods we use. Buffer.from and check for typeof Buffer !== 'undefined'.
  2. Just use TypedArrays everywhere instead of Buffer.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions