路泰科技体检小程序UI设计新版本
1
wwl
2025-08-05 5bfc1352e82140ac098b9f0537cc7d1457c87122
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
/*
    MIT License http://www.opensource.org/licenses/mit-license.php
    Author Tobias Koppers @sokra
*/
 
"use strict";
 
/**
 * @param {string} str string
 * @returns {string[]} array of string separated by lines
 */
const splitIntoLines = (str) => {
    const results = [];
    const len = str.length;
    let i = 0;
    while (i < len) {
        const cc = str.charCodeAt(i);
        // 10 is "\n".charCodeAt(0)
        if (cc === 10) {
            results.push("\n");
            i++;
        } else {
            let j = i + 1;
            // 10 is "\n".charCodeAt(0)
            while (j < len && str.charCodeAt(j) !== 10) j++;
            results.push(str.slice(i, j + 1));
            i = j + 1;
        }
    }
    return results;
};
 
module.exports = splitIntoLines;