Skip to content

Provide a new Buffer::NewOrCopy method #1257

Description

@Julusian

Background:

After nodejs/node#45181 it is possible for Buffer::new to fail with napi_no_external_buffers_allowed. A helper method Buffer::NewOrCopy which would try to do a Buffer::new and fallback to doing a Buffer::copy would be helpful and encourage users to code in a way which provides compatibility for both electron and nodejs, without them having to implement the method themselves.

The npm package sharp has implemented this themselves already lovell/sharp@584807b#diff-53a01d31aa585021f8f316c6613dadef86bf1f9ac2070d52daa68adbefbb6ef4.

Activity

  1. mhdawson commented on Jan 13, 2023

    @mhdawson
    Member

    We discussed in the team meeting today, and we agreed it would make sense to add. @legendecas volunteered to put together a PR.

  2. github-actions commented on Apr 14, 2023

    @github-actions
    Contributor

    This issue is stale because it has been open many days with no activity. It will be closed soon unless the stale label is removed or a comment is made.

  3. legendecas commented on Apr 14, 2023

    @legendecas
    Member

    Landed in #1273.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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