• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

fb55 / entities / 14802994359

02 May 2025 08:38PM CUT coverage: 82.689%. First build
14802994359

Pull #1821

github

web-flow
Merge cd7844e58 into d7fc81819
Pull Request #1821: chore(deps): Bump github/codeql-action from 3.28.16 to 3.28.17

220 of 231 branches covered (95.24%)

Branch coverage included in aggregate %.

807 of 1011 relevant lines covered (79.82%)

498324.8 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

75.81
/src/decode-codepoint.ts
1
// Adapted from https://github.com/mathiasbynens/he/blob/36afe179392226cf1b6ccdb16ebbb7a5a844d93a/src/he.js#L106-L134
2

3
const decodeMap = new Map([
1✔
4
    [0, 65_533],
1✔
5
    // C1 Unicode control character reference replacements
6
    [128, 8364],
1✔
7
    [130, 8218],
1✔
8
    [131, 402],
1✔
9
    [132, 8222],
1✔
10
    [133, 8230],
1✔
11
    [134, 8224],
1✔
12
    [135, 8225],
1✔
13
    [136, 710],
1✔
14
    [137, 8240],
1✔
15
    [138, 352],
1✔
16
    [139, 8249],
1✔
17
    [140, 338],
1✔
18
    [142, 381],
1✔
19
    [145, 8216],
1✔
20
    [146, 8217],
1✔
21
    [147, 8220],
1✔
22
    [148, 8221],
1✔
23
    [149, 8226],
1✔
24
    [150, 8211],
1✔
25
    [151, 8212],
1✔
26
    [152, 732],
1✔
27
    [153, 8482],
1✔
28
    [154, 353],
1✔
29
    [155, 8250],
1✔
30
    [156, 339],
1✔
31
    [158, 382],
1✔
32
    [159, 376],
1✔
33
]);
1✔
34

35
/**
36
 * Polyfill for `String.fromCodePoint`. It is used to create a string from a Unicode code point.
37
 */
38
export const fromCodePoint: (...codePoints: number[]) => string =
1✔
39
    // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition, n/no-unsupported-features/es-builtins
40
    String.fromCodePoint ??
1!
41
    function (codePoint: number): string {
×
42
        let output = "";
×
43

44
        if (codePoint > 0xff_ff) {
×
45
            codePoint -= 0x1_00_00;
×
46
            output += String.fromCharCode(
×
47
                ((codePoint >>> 10) & 0x3_ff) | 0xd8_00,
×
48
            );
×
49
            codePoint = 0xdc_00 | (codePoint & 0x3_ff);
×
50
        }
×
51

52
        output += String.fromCharCode(codePoint);
×
53
        return output;
×
54
    };
×
55

56
/**
57
 * Replace the given code point with a replacement character if it is a
58
 * surrogate or is outside the valid range. Otherwise return the code
59
 * point unchanged.
60
 */
61
export function replaceCodePoint(codePoint: number): number {
1✔
62
    if (
31✔
63
        (codePoint >= 0xd8_00 && codePoint <= 0xdf_ff) ||
31✔
64
        codePoint > 0x10_ff_ff
31✔
65
    ) {
31✔
66
        return 0xff_fd;
1✔
67
    }
1✔
68

69
    return decodeMap.get(codePoint) ?? codePoint;
31✔
70
}
31✔
71

72
/**
73
 * Replace the code point if relevant, then convert it to a string.
74
 *
75
 * @deprecated Use `fromCodePoint(replaceCodePoint(codePoint))` instead.
76
 * @param codePoint The code point to decode.
77
 * @returns The decoded code point.
78
 */
79
export function decodeCodePoint(codePoint: number): string {
1✔
80
    return fromCodePoint(replaceCodePoint(codePoint));
×
81
}
×
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc