Something went wrong. Try again.
[READ-ONLY] Mirror of https://github.com/samualtnorman/lib. A collection of common utilities I need. www.npmjs.com/package/@samual/lib
Something went wrong. Try again.
12345678910111213export function positionToLine(positionIndex: number, string: string) { for (const [ lineNumber, { length } ] of string.split(`\n`).entries()) { positionIndex -= length + 1
if (positionIndex < 0) return lineNumber + 1 }
throw new Error(`\`positionIndex\` must be smaller than \`string\`'s length`)}
export default positionToLine