-
Notifications
You must be signed in to change notification settings - Fork 29.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feature: Buffer.prototype.indexOf #95
Closed
srijs opened this issue
Dec 6, 2014
· 11 comments
· May be fixed by solebox/node#25, UbuntuEvangelist/node#17, saeedahassan/node#35, erdun/node#41 or enterstudio/node#24
Closed
feature: Buffer.prototype.indexOf #95
srijs opened this issue
Dec 6, 2014
· 11 comments
· May be fixed by solebox/node#25, UbuntuEvangelist/node#17, saeedahassan/node#35, erdun/node#41 or enterstudio/node#24
Labels
buffer
Issues and PRs related to the buffer subsystem.
Comments
+1, also everything else from |
.indexOf() and .lastIndexOf() seem unobjectionable to me. PR welcome! |
+1 |
+1 for this, definitely something I needed before and didn't have. |
Summoning @caineio |
|
👍 |
+1, also for |
srijs
added a commit
to srijs/io.js
that referenced
this issue
Dec 14, 2014
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 <srijs@airpost.net> Fixes: nodejs#95 PR-URL: nodejs#160
PR: #160 |
Closed
Closing as #561 was merged. |
kunalspathak
added a commit
to kunalspathak/node
that referenced
this issue
Feb 26, 2017
Earlier whenever repl was created (`node.exe` with zero parameters), global context was reused. However https://github.com/nodejs/node/ pull/5703 fixed it by creating new context for repl. This broke the chakrashim because the context was getting collected immediately. The reason was we were adding the reference of global context to the sandboxed object instead of newly created context. Fixed it by ensuring we add reference to right context. Also contextShim is always initialized when current context was pushed on the scope. However for scenarios like this, we might just create the context and access the objects like global, etc. of that context without going to push scope path. In that case ensure that things are initialized in the new context. But, @jianchun brought a good point offline of perf impact because of additional checks if context is initialized in getters. So I re-verified all the references of getters and noticed that all of them are called on ` ContextShim::GetCurrent()`. Context returned through this API is always the one that is set in PushScope/ PopScope code path, where we do initialize contextShim. Hence I have reverted `EnsureInitialize()` call in all the getters except ` GetProxyOfGlobal()`. Once nodejs#95 is fixed, this need to be revisited and `EnsureInitialized` will need to be added in getters that can be called from different context. PR-URL: nodejs/node-chakracore#96 Reviewed-By: Jianchun Xu <Jianchun.Xu@microsoft.com>
boingoing
pushed a commit
to boingoing/node
that referenced
this issue
Apr 6, 2017
This was referenced Sep 15, 2021
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This has been nagging me for a while, wanting to efficiently search a buffer for a sub-string/buffer, similar to memchr/memcmp, joining
Array.prototype.indexOf
andString.prototype.indexOf
.I finally got around to implement it as a native module: buffer-indexof-fast (on npm and github). The semantics are 100% compatible to
String.prototype.indexOf
.I know there is some discussion going on in terms of what to put into core and what not, but I figured since Buffers are such a fundamental means of sharing information, especially also with the "core", I'll just as the following question...
Would you like to have such a functionality in node-buffers? I would be open to do the work necessary to get it cleaned up and match the code quality of core, if it shows that there is the demand for it.
The text was updated successfully, but these errors were encountered: