karp-rabin-search
v1.0.6
Published
A string searching algorithm for finding instances of a pattern in text
Downloads
6
Maintainers
Readme
Rabin Karp Search Algorithm
A Javascript implementation of the Rabin-Karp Algorithm.
It can be used for detecting occurrences of a string in another string. Can be used to detect plagiarism. Note I advise not to use this algo, iteratively calling indexOf yields better performance in V8.
Usage
npm install
var rks = require('rabin-karp-search')
rks.search('There is a pattern in this string', 'pattern') // prints [ 11 ]
rks.search('A pattern and another pattern', 'pattern') // prints [ 2, 22 ]
Tests
run npm test
Dependencies
https://github.com/rsandor/number-theory
License
MIT