路泰科技体检小程序UI设计新版本
qx
2025-08-06 fe97f78b9a343ee9fa45a3531d03d73dcd1df31b
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
/*
    MIT License http://www.opensource.org/licenses/mit-license.php
    Author Tobias Koppers @sokra
*/
 
"use strict";
 
const Source = require("./Source");
 
/** @typedef {import("./Source").HashLike} HashLike */
/** @typedef {import("./Source").MapOptions} MapOptions */
/** @typedef {import("./Source").RawSourceMap} RawSourceMap */
/** @typedef {import("./Source").SourceAndMap} SourceAndMap */
/** @typedef {import("./Source").SourceValue} SourceValue */
 
/**
 * @typedef {object} SourceLike
 * @property {() => SourceValue} source source
 * @property {(() => Buffer)=} buffer buffer
 * @property {(() => number)=} size size
 * @property {((options?: MapOptions) => RawSourceMap | null)=} map map
 * @property {((options?: MapOptions) => SourceAndMap)=} sourceAndMap source and map
 * @property {((hash: HashLike) => void)=} updateHash hash updater
 */
 
class CompatSource extends Source {
    /**
     * @param {SourceLike} sourceLike source like
     * @returns {Source} source
     */
    static from(sourceLike) {
        return sourceLike instanceof Source
            ? sourceLike
            : new CompatSource(sourceLike);
    }
 
    /**
     * @param {SourceLike} sourceLike source like
     */
    constructor(sourceLike) {
        super();
        this._sourceLike = sourceLike;
    }
 
    /**
     * @returns {SourceValue} source
     */
    source() {
        return this._sourceLike.source();
    }
 
    buffer() {
        if (typeof this._sourceLike.buffer === "function") {
            return this._sourceLike.buffer();
        }
        return super.buffer();
    }
 
    size() {
        if (typeof this._sourceLike.size === "function") {
            return this._sourceLike.size();
        }
        return super.size();
    }
 
    /**
     * @param {MapOptions=} options map options
     * @returns {RawSourceMap | null} map
     */
    map(options) {
        if (typeof this._sourceLike.map === "function") {
            return this._sourceLike.map(options);
        }
        return super.map(options);
    }
 
    /**
     * @param {MapOptions=} options map options
     * @returns {SourceAndMap} source and map
     */
    sourceAndMap(options) {
        if (typeof this._sourceLike.sourceAndMap === "function") {
            return this._sourceLike.sourceAndMap(options);
        }
        return super.sourceAndMap(options);
    }
 
    /**
     * @param {HashLike} hash hash
     * @returns {void}
     */
    updateHash(hash) {
        if (typeof this._sourceLike.updateHash === "function") {
            return this._sourceLike.updateHash(hash);
        }
        if (typeof this._sourceLike.map === "function") {
            throw new Error(
                "A Source-like object with a 'map' method must also provide an 'updateHash' method",
            );
        }
        hash.update(this.buffer());
    }
}
 
module.exports = CompatSource;