Get the distance of a substring from the start of a line
npm install substr-distance
const substrDistance = ;const page = `<html><body><p id="thing">Find me!</p></body></html>`;; // => 4
haystack, and return the number of characters
needle sits from the beginning of the line.
- haystack (String): String to search in.
- needle (String): String to search for.
Returns distance from start of line to
needle is not found at all,
-1 is returned.
git clone https://github.com/gakimball/substr-distancecd substr-distancenpm installnpm test
MIT © Geoff Kimball