Skip to content

Add Buffer#includes() #3552

Description

@sindresorhus

For convenience, code clarity, and parity with TypedArray. See TypedArray#includes().

The includes() method determines whether a typed array includes a certain element, returning true or false as appropriate.

Activity

  1. targos commented on Oct 27, 2015

    @targos
    Member

    TypedArray#includes and Array#includes are not shipped in V8 yet.
    When it happens, buffers will have the method. You can test it with the harmony flag:

    % node -v
    v5.0.0-rc.1
    % node --harmony
    > var buffer = new Buffer(1).fill(1)
    undefined
    > buffer.includes(1)
    true
  2. added
    bufferIssues and PRs related to the buffer subsystem.
    v8 engineIssues and PRs related to the V8 dependency.
    on Oct 27, 2015
  3. trevnorris commented on Oct 27, 2015

    @trevnorris
    Contributor

    Though we might want to override it. v8's implementation (following the spec) is restrictive and slow. e.g. indexOf(), fill(). Instead, to have feature parity with current Buffer API's we should consider our own impl that accepts multi-char strings, etc.

  4. targos commented on Oct 28, 2015

    @targos
    Member

    @trevnorris good point! Then we can just wrap it around indexOf.

  5. trevnorris commented on Oct 28, 2015

    @trevnorris
    Contributor

    Oh yeah. Good call. Easy PR for the taking.

  6. sindresorhus commented on Oct 28, 2015

    @sindresorhus
    Author
  7. rodmachen commented on Oct 28, 2015

    @rodmachen
    Contributor

    Just added a PR to implement this.

    #3568

  8. Fishrock123 commented on Dec 9, 2015

    @Fishrock123
    Contributor

    PR is #3567

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

    bufferIssues and PRs related to the buffer subsystem.feature requestIssues requesting new Node.js features.good first issueIssues that are suitable for first-time contributors.v8 engineIssues and PRs related to the V8 dependency.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions