Skip to content
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

buffer: add indexOf/lastIndexOf method #161

Closed
wants to merge 2 commits into from
Closed

buffer: add indexOf/lastIndexOf method #161

wants to merge 2 commits into from

Commits on Dec 14, 2014

  1. buffer: add indexOf method

    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
    srijs authored and algesten committed Dec 14, 2014
    Configuration menu
    Copy the full SHA
    4dedc09 View commit details
    Browse the repository at this point in the history
  2. buffer: add lastIndexOf method

    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
    algesten committed Dec 14, 2014
    Configuration menu
    Copy the full SHA
    b36c6f1 View commit details
    Browse the repository at this point in the history