Skip to content

Commit

Permalink
refactor: better getLinesInString fn
Browse files Browse the repository at this point in the history
  • Loading branch information
chhoumann committed Feb 14, 2024
1 parent 0454b19 commit 419df6b
Showing 1 changed file with 1 addition and 12 deletions.
13 changes: 1 addition & 12 deletions src/utility.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,7 @@ export function waitFor(ms: number): Promise<unknown> {
}

export function getLinesInString(input: string) {
const lines: string[] = [];
let tempString = input;

while (tempString.includes("\n")) {
const lineEndIndex = tempString.indexOf("\n");
lines.push(tempString.slice(0, lineEndIndex));
tempString = tempString.slice(lineEndIndex + 1);
}

lines.push(tempString);

return lines;
return input.split("\n");
}

// https://stackoverflow.com/questions/3115150/how-to-escape-regular-expression-special-characters-using-javascript
Expand Down

0 comments on commit 419df6b

Please sign in to comment.