Implementation of the Boyer-Moore algorithm in Javascript