UNPKG

newline-iterator

Version:
16 lines (15 loc) 524 B
/** * Create a newline iterator recognizing CR, LF, and CRLF using the Symbol.iterator interface * * @param string The string to iterate through * * ```typescript * import newlineIterator from "newline-iterator"; * * const iterator = newlineIterator("some\r\nstring\ncombination\r"); * const results = []; * for (const line of iterator) results.push(line); * console.log(results); // ["some", "string", "combination"]; * ``` */ export default function newlineIterator(string: string): IterableIterator<string>;