Files
termos/src/util/posix.ts
T
ChaosMaker 20718604e4 - fixed a bug in dnTaverseTree where children would get pushed into the result in reverse order
- added an inode display to the `printTree` algorithm

- removed a redundant type in *`signal.ts`*
- improved `resolveInode` to now take `ShellState` instead of `FileSystem` and added an optional `abs` *`boolean`* argument to determine if the retuned path should be normalized or absolute

- implemented a builtin `TreeNode` quicksort function
- changed the `TreeNodeType` to a numeric enum
- added a standalone `Posix` class that holds a const with character weights compliant with posix
2026-08-25 06:34:23 +02:00

113 lines
1.9 KiB
TypeScript

export class Posix {
private static readonly CharTable = {
// Space and punctuation (32-47)
" ": 32,
"!": 33,
'"': 34,
"#": 35,
$: 36,
"%": 37,
"&": 38,
"'": 39,
"(": 40,
")": 41,
"*": 42,
"+": 43,
",": 44,
"-": 45,
".": 46,
"/": 47,
// Numbers 0-9 (48-57)
"0": 48,
"1": 49,
"2": 50,
"3": 51,
"4": 52,
"5": 53,
"6": 54,
"7": 55,
"8": 56,
"9": 57,
// More punctuation (58-64)
":": 58,
";": 59,
"<": 60,
"=": 61,
">": 62,
"?": 63,
"@": 64,
// LETTERS - INTERLEAVED AaBbCc... (65-116)
A: 65,
a: 66,
B: 67,
b: 68,
C: 69,
c: 70,
D: 71,
d: 72,
E: 73,
e: 74,
F: 75,
f: 76,
G: 77,
g: 78,
H: 79,
h: 80,
I: 81,
i: 82,
J: 83,
j: 84,
K: 85,
k: 86,
L: 87,
l: 88,
M: 89,
m: 90,
N: 91,
n: 92,
O: 93,
o: 94,
P: 95,
p: 96,
Q: 97,
q: 98,
R: 99,
r: 100,
S: 101,
s: 102,
T: 103,
t: 104,
U: 105,
u: 106,
V: 107,
v: 108,
W: 109,
w: 110,
X: 111,
x: 112,
Y: 113,
y: 114,
Z: 115,
z: 116,
// Specials after letters (now 117-126)
"[": 117,
"\\": 118,
"]": 119,
"^": 120,
_: 121,
"`": 122,
"{": 123,
"|": 124,
"}": 125,
"~": 126,
} as const;
public static GetCharWeight(char: string): number {
return this.CharTable[char as keyof typeof this.CharTable];
}
}