Skip to content

A simple implementation of the Boyer-Moore-Horspool string search algorithm for use with buffers or typed arrays

License

Notifications You must be signed in to change notification settings

jhermsmeier/node-buffer-horspool

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Buffer-Horspool

npm npm license npm downloads

Note

Node's builtin buffer.indexOf() and typed array .indexOf() are way faster than this nowadays – this was originally written before either of those existed, so you probably don't want to use this, unless you know you need it.

What is this?

A simple implementation of the Boyer-Moore-Horspool string search algorithm for use with Buffers or Uint8Arrays.

Why is this?

I needed it for one of my projects in the days before buffer.indexOf() existed, wrote a gist, others kept finding it useful, so now it's on npm.

Shoutout to @dubiousjim for finding a bug in the original gist!

Installation

$ npm install --save buffer-horspool

Usage

var horspool = require( 'buffer-horspool' )

Just like the native .indexOf() methods, given a haystack and a needle, either the index at which the substring is found is returned, otherwise -1:

var index = horspool.indexOf( haystack: Buffer|Uint8Array, needle: Buffer|Uint8Array, startOffset: Number )

About

A simple implementation of the Boyer-Moore-Horspool string search algorithm for use with buffers or typed arrays

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published