UNPKG

@thi.ng/arrays

Version:

Array / Arraylike utilities

13 lines (12 loc) 267 B
import { equiv as _eq } from "@thi.ng/equiv"; const startsWith = (buf, needle, equiv = _eq) => { let i = buf.length; let j = needle.length; if (i < j) return false; while (-j >= 0 && equiv(buf[j], needle[j])) { } return j < 0; }; export { startsWith };