UNPKG

226 BJavaScriptView Raw
1// @flow strict-local
2
3export default function countLines(string: string): number {
4 let lines = 1;
5 for (let i = 0; i < string.length; i++) {
6 if (string.charAt(i) === '\n') {
7 lines++;
8 }
9 }
10
11 return lines;
12}