GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Add Buffer#includes() · Issue #3552 · nodejs/node

Add Buffer#includes() #3552

New issue
Copy link
New issue
Copy link
Closed
Closed
Add Buffer#includes()#3552
Copy link
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.

Description

@sindresorhus
sindresorhus
opened on Oct 27, 2015
Issue body actions

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. evanlucas
    added
    feature requestIssues requesting new Node.js features.
    on Oct 27, 2015
  2. targos commented on Oct 27, 2015

    @targos
    targos
    on Oct 27, 2015
    Member
    More actions

    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
  3. mscdex
    added
    bufferIssues and PRs related to the buffer subsystem.
    v8 engineIssues and PRs related to the V8 dependency.
    on Oct 27, 2015
  4. trevnorris commented on Oct 27, 2015

    @trevnorris
    trevnorris
    on Oct 27, 2015
    Contributor
    More actions

    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.

  5. targos commented on Oct 28, 2015

    @targos
    targos
    on Oct 28, 2015
    Member
    More actions

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

  6. trevnorris commented on Oct 28, 2015

    @trevnorris
    trevnorris
    on Oct 28, 2015
    Contributor
    More actions

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

  7. sindresorhus commented on Oct 28, 2015

    @sindresorhus
    sindresorhus
    on Oct 28, 2015
    Author
    More actions

    I made a polyfill: https://github.com/sindresorhus/buffer-includes

  8. cjihrig
    added
    good first issueIssues that are suitable for first-time contributors.
    on Oct 28, 2015
  9. rodmachen commented on Oct 28, 2015

    @rodmachen
    rodmachen
    on Oct 28, 2015
    Contributor
    More actions

    Just added a PR to implement this.

    #3568

  10. Fishrock123 commented on Dec 9, 2015

    @Fishrock123
    Fishrock123
    on Dec 9, 2015
    Contributor
    More actions

    PR is #3567

  11. trevnorris
    closed this as completedin 67e1819on Dec 10, 2015
  12. cjihrig
    added a commit that references this issue on Dec 16, 2015

    buffer: add includes() for parity with TypedArray

    9ab669f
  13. scovetta
    added a commit that references this issue on Apr 2, 2016

    buffer: add includes() for parity with TypedArray

    ff8a634
  14. sjarmak
    added a commit that references this issue on Jul 27, 2026

    buffer: add includes() for parity with TypedArray

    67e1819
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

      You are visitor 01402775 — GeezerVison does not store the pages you look up.
      Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.