Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@ describe('PolynomialHash', () => {

// Check hashing for different word lengths.
frameSizes.forEach((frameSize) => {
let previousWord = text.substr(0, frameSize);
let previousWord = text.substring(0, frameSize);
let previousHash = polynomialHash.hash(previousWord);

// Shift frame through the whole text.
for (let frameShift = 1; frameShift < (text.length - frameSize); frameShift += 1) {
const currentWord = text.substr(frameShift, frameSize);
const currentWord = text.substring(frameShift, frameShift + frameSize);
const currentHash = polynomialHash.hash(currentWord);
const currentRollingHash = polynomialHash.roll(previousHash, previousWord, currentWord);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@ describe('PolynomialHash', () => {

// Check hashing for different word lengths.
frameSizes.forEach((frameSize) => {
let previousWord = text.substr(0, frameSize);
let previousWord = text.substring(0, frameSize);
let previousHash = polynomialHash.hash(previousWord);

// Shift frame through the whole text.
for (let frameShift = 1; frameShift < (text.length - frameSize); frameShift += 1) {
const currentWord = text.substr(frameShift, frameSize);
const currentWord = text.substring(frameShift, frameShift + frameSize);
const currentHash = polynomialHash.hash(currentWord);
const currentRollingHash = polynomialHash.roll(previousHash, previousWord, currentWord);

Expand Down
2 changes: 1 addition & 1 deletion src/algorithms/string/rabin-karp/rabinKarp.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export default function rabinKarp(text, word) {
// In case of hash collision the strings may not be equal.
if (
wordHash === currentFrameHash
&& text.substr(charIndex, word.length) === word
&& text.substring(charIndex, charIndex + word.length) === word
) {
return charIndex;
}
Expand Down