路泰科技体检小程序UI设计新版本
1
wwl
6 天以前 a6cdbcfe28fcc40ebb4919f57d60fb20122e8e57
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
/*
    MIT License http://www.opensource.org/licenses/mit-license.php
    Author Tobias Koppers @sokra
*/
 
"use strict";
 
const getGeneratedSourceInfo = require("./getGeneratedSourceInfo");
const splitIntoLines = require("./splitIntoLines");
 
/** @typedef {import("./getGeneratedSourceInfo").GeneratedSourceInfo} GeneratedSourceInfo */
/** @typedef {import("./streamChunks").OnChunk} OnChunk */
/** @typedef {import("./streamChunks").OnName} OnName */
/** @typedef {import("./streamChunks").OnSource} OnSource */
 
/**
 * @param {string} source source
 * @param {OnChunk} onChunk on chunk
 * @param {OnSource} _onSource on source
 * @param {OnName} _onName on name
 * @returns {GeneratedSourceInfo} source info
 */
const streamChunksOfRawSource = (source, onChunk, _onSource, _onName) => {
    let line = 1;
    const matches = splitIntoLines(source);
    /** @type {undefined | string} */
    let match;
    for (match of matches) {
        onChunk(match, line, 0, -1, -1, -1, -1);
        line++;
    }
    return matches.length === 0 || /** @type {string} */ (match).endsWith("\n")
        ? {
                generatedLine: matches.length + 1,
                generatedColumn: 0,
            }
        : {
                generatedLine: matches.length,
                generatedColumn: /** @type {string} */ (match).length,
            };
};
 
/**
 * @param {string} source source
 * @param {OnChunk} onChunk on chunk
 * @param {OnSource} onSource on source
 * @param {OnName} onName on name
 * @param {boolean} finalSource is final source
 * @returns {GeneratedSourceInfo} source info
 */
module.exports = (source, onChunk, onSource, onName, finalSource) =>
    finalSource
        ? getGeneratedSourceInfo(source)
        : streamChunksOfRawSource(source, onChunk, onSource, onName);