indexOfAmong

Array-specialization of indexOf with default predicate.

TODO: Add optimized implementation for needles with length >= largeNeedleLength with no repeat of elements.

Examples

assert("_abc_abc_".indexOf("abc") == 1);
assert("__abc_".indexOf("abc") == 2);
assert("a".indexOf("a") == 0);
assert("abc".indexOf("abc") == 0);
assert("_".indexOf("a") == -1);
assert("_".indexOf("__") == -1);
assert("__".indexOf("a") == -1);
assert("_".indexOf('a') == -1);
assert("a".indexOf('a') == 0);
assert("_a".indexOf('a') == 1);
assert("__a".indexOf('a') == 2);

Meta