Skip to content

Reducing Buffer.from(str, ENC_1).toString(ENC_2) usage across Node #16

@anonrig

Description

@anonrig

There are lots of Buffer.from(value, ENC).toString(ENC_2) code duplication in Node. I recommend creating a C++ function to do the same execution with less JS/C++ calls. bufferToString(value, encoding_1, encoding_2); that returns a string.

For example:

  • buffer.js - btoa - Buffer.from(input, 'latin1').toString('base64');
  • buffer.js - atob - Buffer.from(input, 'base64').toString('latin1')
  • _http_client.js - Buffer.from(options.auth).toString('base64')
  • random.js - Buffer.from(arrayBuffer).toString('hex')

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions