Skip to content

Cannot invoke Uint8Array.prototype.toBase64 in browsers because typed-array-byte-offset is not browser-safe #2

@andy0130tw

Description

@andy0130tw

Basically I stumbled upon this issue:

inspect-js/typed-array-byte-offset#2

Some implementations like Uint8Array.prototype.toBase64 depends on your npm library typed-array-byte-offset. It crashes in the browsers because there are references to variable name global that is only meaningful in Node.js, not in browsers.

From the above issue being closed as not planned, can I say that the library is not browser-safe? And from the readme of this library, one usage of this library is to fix Safari's incorrect behavior. To allow using this library to polyfill all provided functions in browsers (hopefully without bundlers), I suggest inlining the code from that library into this and changing global to globalThis.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions