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

terminal-nerds / snippets / 5113553229

pending completion
5113553229

Pull #105

github

web-flow
Merge 5e619d6af into e71a93724
Pull Request #105: Major reorganization

267 of 329 branches covered (81.16%)

Branch coverage included in aggregate %.

377 of 377 new or added lines in 13 files covered. (100.0%)

3396 of 3511 relevant lines covered (96.72%)

34.38 hits per line

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

82.86
/packages/string/source/char/sub/type.ts
1
import { z } from "zod";
1✔
2

1✔
3
import {
1✔
4
        CHARS_LATIN,
1✔
5
        CHARS_LATIN_LOWER_CASE,
1✔
6
        CHARS_LATIN_UPPER_CASE,
1✔
7
        SCHEMA_CHAR_LATIN,
1✔
8
        SCHEMA_CHAR_LATIN_LOWER_CASE,
1✔
9
        SCHEMA_CHAR_LATIN_UPPER_CASE,
1✔
10
} from "./latin.ts";
1✔
11
import { CHARS_NUMBER, SCHEMA_CHAR_NUMBER } from "./number.ts";
1✔
12
import { type Char, validateChar } from "./single.ts";
1✔
13
import { CHARS_SPECIAL, SCHEMA_CHAR_SPECIAL } from "./special.ts";
1✔
14

1✔
15
/* prettier-ignore */
1✔
16
export const CHAR_TYPES = [
1✔
17
        "latin",
1✔
18
        "latinLowerCase",
1✔
19
        "latinUpperCase",
1✔
20
        "number",
1✔
21
        "special",
1✔
22
] as const;
1✔
23

1✔
24
export type CharType = (typeof CHAR_TYPES)[number];
1✔
25

1✔
26
export const CHAR_TYPE_SCHEMA = z.enum(CHAR_TYPES);
1✔
27

1✔
28
export function validateCharType(type: string): asserts type is CharType {
1✔
29
        CHAR_TYPE_SCHEMA.parse(type);
9✔
30
}
9✔
31

1✔
32
export function isValidCharType(type: string): type is CharType {
1✔
33
        return CHAR_TYPE_SCHEMA.safeParse(type).success;
×
34
}
×
35

1✔
36
/* c8 ignore start */
1✔
37
export const CHARS_BY_TYPE = {
1✔
38
        latin: CHARS_LATIN,
1✔
39
        latinLowerCase: CHARS_LATIN_LOWER_CASE,
1✔
40
        latinUpperCase: CHARS_LATIN_UPPER_CASE,
1✔
41
        number: CHARS_NUMBER,
1✔
42
        special: CHARS_SPECIAL,
1✔
43
} as const satisfies Record<CharType, unknown>;
1✔
44
/* c8 ignore stop */
1✔
45

1✔
46
export type CharsByType<T extends CharType> = (typeof CHARS_BY_TYPE)[T];
1✔
47
export type CharByType<T extends CharType> = CharsByType<T>[number];
1✔
48

1✔
49
/* c8 ignore start */
1✔
50
export const SCHEMAS_CHARS = {
1✔
51
        latin: SCHEMA_CHAR_LATIN,
1✔
52
        latinLowerCase: SCHEMA_CHAR_LATIN_LOWER_CASE,
1✔
53
        latinUpperCase: SCHEMA_CHAR_LATIN_UPPER_CASE,
1✔
54
        number: SCHEMA_CHAR_NUMBER,
1✔
55
        special: SCHEMA_CHAR_SPECIAL,
1✔
56
} as const satisfies Record<CharType, unknown>;
1✔
57
/* c8 ignore stop */
1✔
58

1✔
59
export function getCharType<C extends Char>(char: C): CharType {
1✔
60
        validateChar(char);
×
61

×
62
        for (const type of CHAR_TYPES) {
×
63
                if (new Set(CHARS_BY_TYPE[type]).has(char)) {
×
64
                        return type;
×
65
                }
×
66
        }
×
67

×
68
        throw new TypeError(`Unrecognized char type for: "${char}"`);
×
69
}
×
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

© 2026 Coveralls, Inc