indexOfEither

Array-specialization of indexOf with default predicate.

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

Examples

assert("_".indexOfEither("a") == -1);
assert("_a".indexOfEither("a") == 1);
assert("_a".indexOfEither("ab") == 1);
assert("_b".indexOfEither("ab") == 1);
assert("_b".indexOfEither("_") == 0);
assert("_b".indexOfEither("xy") == -1);
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