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 — buffer: add indexOf/lastIndexOf method by algesten · Pull Request #161 · nodejs/node

Conversation

@algesten

@algesten algesten commented Dec 14, 2014

Copy link
Copy Markdown

Expanded on @srijs code to add a Buffer.prototype.lastIndexOf. I used a strategy of divide/conquer, but since I'm a total c++ idiot, I have no idea whether there is a better way (some reverse memcmp variant?). Also I rebased both srijs and these commits against v0.12 hoping it would make it out sooner :)

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@srijs @algesten
buffer: add indexOf method
4dedc09
Adds a `.indexOf` method to `Buffer`, which borrows semantics from
both `Array.prototype.indexOf` and `String.prototype.indexOf`.

`Buffer.prototype.indexOf` can be invoked with a Buffer, a string
or a number as the needle.  If the needle a Buffer or string, it will
find the first occurrence of this sequence of bytes.  If the needle is
a number, it will find the first occurrence of this byte.

Reviewed-by: Sam Rijs <[email protected]>
Fixes: #95
PR-URL: #160
@piscisaureus piscisaureus added the unknown label Dec 14, 2014
@algesten
buffer: add lastIndexOf method
b36c6f1
Expanding and reusing code by Sam Rijs in commit 4dedc09 to also add a
`.lastIndexOf` method to `Buffer`.

`Buffer.prototype.lastIndexOf` takes the same arguments as its
predecessor and uses a divide-and-conquer method to find the last
occurrence of the sequence of byte.

Reviewed-by: Martin Algesten <[email protected]>
Related-To: #95
Original PR-URL: #160
PR-URL: #161
@piscisaureus piscisaureus removed the unknown label Dec 16, 2014
@piscisaureus piscisaureus closed this Dec 30, 2014
@piscisaureus piscisaureus reopened this Dec 30, 2014
@rvagg rvagg mentioned this pull request Jan 23, 2015
buffer: add indexOf() method #561
Closed
@rvagg rvagg added the semver-minor PRs that contain new features and should be released in the next minor version. label Jan 23, 2015
@brendanashworth

brendanashworth commented Feb 13, 2015

Copy link
Copy Markdown
Contributor

I have no opinion on the subject but from what I'm seeing is that #561 will supersede this PR. However, it has been indicated that there will be no .lastIndexOf() method added in that PR, so I think that is still up for grabs.

I'm unsure with how to proceed with this specific PR, as only one commit seems to be prevalent now. @algesten?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@trevnorris

trevnorris commented Feb 13, 2015

Copy link
Copy Markdown
Contributor

I'm really sorry. Been tied up with work, which is why I haven't finished my lastIndexOf() PR. I'll finish that this weekend and get it merged in. @algesten if you then want to replicate the same structure for lastIndexOf() and submit another PR that would be great. :)

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@Fishrock123 Fishrock123 assigned trevnorris Feb 16, 2015
@chrisdickinson

chrisdickinson commented Feb 23, 2015

Copy link
Copy Markdown
Contributor

Closing this in favor of #561. @algesten, if you're interested in adding lastIndexOf based on @trevnorris' code, please open another PR. Thanks!

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@chrisdickinson chrisdickinson closed this Feb 23, 2015
@algesten

algesten commented Feb 23, 2015

Copy link
Copy Markdown
Author

Thanks @chrisdickinson I'll try to make some time to look into it.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

boingoing pushed a commit to boingoing/node that referenced this pull request Apr 6, 2017
@jasongin
napi: Remove regfunc cast from NAPI_MODULE (nodejs#161)
7f0d031
This was referenced May 26, 2021
[Snyk] Security upgrade eslint-plugin-markdown from 1.0.2 to 2.2.0 olegnn/node#29
Open
[Snyk] Security upgrade eslint-plugin-markdown from 1.0.0-beta.7 to 2.2.0 erdun/node#34
Open
[Snyk] Security upgrade eslint-plugin-markdown from 1.0.2 to 2.2.0 saeedahassan/node#28
Open
@snyk-bot snyk-bot mentioned this pull request Jun 22, 2021
[Snyk] Upgrade sprintf-js from 1.0.3 to 1.1.2 aliscco/alisco-node#5
Open
@verdinjoshua1982 verdinjoshua1982 mentioned this pull request Oct 14, 2022
[Snyk] Upgrade make-fetch-happen from 9.1.0 to 10.2.1 verdinjoshua1982/node#2
Open
@H1Gdev H1Gdev mentioned this pull request Mar 21, 2023
filehandle.read(buffer) can't read file when options are omitted #47183
Closed
@nickfnblum nickfnblum mentioned this pull request Nov 30, 2023
[Snyk] Fix for 1 vulnerabilities nickfnblum/node#12
Open
This was referenced Nov 30, 2023
[Snyk] Security upgrade make-fetch-happen from 9.1.0 to 11.0.0 dannybrown13/node#50
Open
[Snyk] Fix for 1 vulnerabilities dannybrown13/node#53
Open
@ryan-ally ryan-ally mentioned this pull request Nov 30, 2023
[Snyk] Fix for 1 vulnerabilities ryan-ally/node#90
Open
@BryanLaura BryanLaura mentioned this pull request Nov 30, 2023
[Snyk] Security upgrade make-fetch-happen from 9.1.0 to 11.0.0 BryanLaura/node#52
Open
@baby636 baby636 mentioned this pull request Nov 30, 2023
[Snyk] Fix for 1 vulnerabilities baby636/node#113
Open
@pratapadi pratapadi mentioned this pull request Nov 30, 2023
[Snyk] Security upgrade make-fetch-happen from 9.1.0 to 11.0.0 pratapadi/node#82
Open
@dewaynesmith3711 dewaynesmith3711 mentioned this pull request Nov 30, 2023
[Snyk] Fix for 1 vulnerabilities dewaynesmith3711/node#49
Open
@xphillyx xphillyx mentioned this pull request Nov 30, 2023
[Snyk] Fix for 1 vulnerabilities xphillyx/node#27
Open
@terrorizer1980 terrorizer1980 mentioned this pull request Dec 1, 2023
[Snyk] Fix for 3 vulnerabilities terrorizer1980/node-1#15
Open
@kaocher82 kaocher82 mentioned this pull request Dec 1, 2023
[Snyk] Fix for 1 vulnerabilities Xtuden-com/node#39
Open
@terrorizer1980 terrorizer1980 mentioned this pull request Dec 1, 2023
[Snyk] Fix for 1 vulnerabilities Exhorder6/node#24
Open
eti-p-doray pushed a commit to eti-p-doray/node that referenced this pull request Dec 5, 2023
@victorgomes
Adapt tests for increased TypedArray sizes (nodejs#161)
61d7098
V8 will increase the maximum TypedArray size in
https://crrev.com/c/4872536; this CL adapts the tests to allow for that.

Tests that hard-code smaller sizes or are already tested in V8 are
removed; one test is adapted to not rely on a specific limit.
# Conflicts:
#	test/parallel/test-buffer-alloc.js
#	test/parallel/test-buffer-tostring-rangeerror.js
eti-p-doray pushed a commit to eti-p-doray/node that referenced this pull request May 28, 2024
@victorgomes
Adapt tests for increased TypedArray sizes (nodejs#161)
5413b21
V8 will increase the maximum TypedArray size in
https://crrev.com/c/4872536; this CL adapts the tests to allow for that.

Tests that hard-code smaller sizes or are already tested in V8 are
removed; one test is adapted to not rely on a specific limit.
# Conflicts:
#	test/parallel/test-buffer-alloc.js
#	test/parallel/test-buffer-tostring-rangeerror.js
syg pushed a commit to syg/node that referenced this pull request Jun 20, 2024
@victorgomes
Adapt tests for increased TypedArray sizes (nodejs#161)
fc5de5f
V8 will increase the maximum TypedArray size in
https://crrev.com/c/4872536; this CL adapts the tests to allow for that.

Tests that hard-code smaller sizes or are already tested in V8 are
removed; one test is adapted to not rely on a specific limit.
# Conflicts:
#	test/parallel/test-buffer-alloc.js
#	test/parallel/test-buffer-tostring-rangeerror.js
eti-p-doray pushed a commit to eti-p-doray/node that referenced this pull request Aug 28, 2024
@victorgomes
Adapt tests for increased TypedArray sizes (nodejs#161)
7947269
V8 will increase the maximum TypedArray size in
https://crrev.com/c/4872536; this CL adapts the tests to allow for that.

Tests that hard-code smaller sizes or are already tested in V8 are
removed; one test is adapted to not rely on a specific limit.
# Conflicts:
#	test/parallel/test-buffer-alloc.js
#	test/parallel/test-buffer-tostring-rangeerror.js
syg pushed a commit to syg/node that referenced this pull request May 5, 2025
@victorgomes pthier
Adapt tests for increased TypedArray sizes (nodejs#161)
132d327
V8 will increase the maximum TypedArray size in
https://crrev.com/c/4872536; this CL adapts the tests to allow for that.

Tests that hard-code smaller sizes or are already tested in V8 are
removed; one test is adapted to not rely on a specific limit.
# Conflicts:
#	test/parallel/test-buffer-alloc.js
#	test/parallel/test-buffer-tostring-rangeerror.js
bakkot pushed a commit to bakkot/node that referenced this pull request May 11, 2026
@victorgomes pthier
Adapt tests for increased TypedArray sizes (nodejs#161)
0b3d8b5
V8 will increase the maximum TypedArray size in
https://crrev.com/c/4872536; this CL adapts the tests to allow for that.

Tests that hard-code smaller sizes or are already tested in V8 are
removed; one test is adapted to not rely on a specific limit.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

No reviews

Uh oh!

There was an error while loading. Please reload this page.

Assignees

@trevnorris trevnorris

Labels

semver-minor PRs that contain new features and should be released in the next minor version.

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

7 participants

@algesten @brendanashworth @trevnorris @chrisdickinson @piscisaureus @rvagg @srijs
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.