SpanTo
SpanTo is a JavaScript function used for working with strings. It is part of the `String` prototype, meaning it can be called directly on any string variable. The primary purpose of SpanTo is to extract a portion of a string based on a specified delimiter and a direction. It takes two arguments: the delimiter string and a boolean indicating the direction. If the direction is true (or omitted), SpanTo searches for the delimiter from the beginning of the string and returns the substring up to, but not including, the first occurrence of the delimiter. If the direction is false, it searches from the end of the string, returning the substring from the last occurrence of the delimiter to the end of the string. If the delimiter is not found in the string, SpanTo's behavior depends on the direction. When searching forward, it returns the original string. When searching backward, it returns an empty string. SpanTo is useful for tasks such as parsing data, extracting file extensions, or separating parts of a URL. It provides a concise way to perform common string manipulation operations.