Skip to content

Commit a67ccfe

Browse files
Fix mapping to avoid duplicate values
Signed-off-by: Dimitri Papadopoulos <3234522+DimitriPapadopoulos@users.noreply.github.com>
1 parent 156ea83 commit a67ccfe

2 files changed

Lines changed: 8 additions & 2 deletions

File tree

‎src/llhttp/c-headers.ts‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,11 @@ export class CHeaders {
5757
private buildEnum(name: Lowercase<string>, prefix: string, map: IntDict,
5858
encoding: Encoding = 'none'): string {
5959
let res = '';
60+
const seen = new Set<number>();
6061

61-
for (const [ key, value ] of Object.entries(map).sort((a,b) => a[1] - b[1])) {
62+
for (const [ key, value ] of Object.entries(map)
63+
.filter(x => !seen.has(x[1]) && seen.add(x[1]))
64+
.sort((a,b) => a[1] - b[1])) {
6265
if (res !== "") {
6366
res += ',\n';
6467
}

‎src/llhttp/constants.ts‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,6 @@ export const STATUSES = {
174174
CONNECTION_TIMEOUT: 522, // Unofficial
175175
ORIGIN_IS_UNREACHABLE: 523, // Unofficial
176176
TIMEOUT_OCCURED: 524, // Unofficial
177-
TIMEOUT_OCCURRED: 524, // Unofficial
178177
SSL_HANDSHAKE_FAILED: 525, // Unofficial
179178
INVALID_SSL_CERTIFICATE: 526, // Unofficial
180179
RAILGUN_ERROR: 527, // Unofficial
@@ -185,6 +184,10 @@ export const STATUSES = {
185184
NETWORK_CONNECT_TIMEOUT: 599, // Unofficial
186185
} as const;
187186

187+
export const TYPOS = {
188+
TIMEOUT_OCCURRED: 524, // Alias to fix typo in TIMEOUT_OCCURED
189+
} as const;
190+
188191
export const FINISH = {
189192
SAFE: 0,
190193
SAFE_WITH_CB: 1,

0 commit comments

Comments
 (0)