Skip to content

Latest commit

 

History

History
39 lines (31 loc) · 2.61 KB

README.md

File metadata and controls

39 lines (31 loc) · 2.61 KB

Rabin-Karp algorithm for JavaScript. See docs.

⚠️ Depending on your environment, the code may require regeneratorRuntime to be defined, for instance by importing regenerator-runtime/runtime.

import {rabinKarp} from '@string-searching/rabin-karp';

const code = (c) => c.charCodeAt(0);
const d = 256;
const q = 13;
const findAll = rabinKarp(code, d, q);

const string = 'aaabaaa';
const pattern = 'aa';

for (const i of findAll(string, 0, string.length, pattern, 0, pattern.length)) {
	// yields 0 1 4 5
}

License Version Tests Dependencies GitHub issues Downloads

Code issues Code maintainability Code coverage (cov) Code technical debt Documentation Package size