Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

src: add ASCII table constants #18743

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
144 changes: 132 additions & 12 deletions lib/internal/constants.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,136 @@
'use strict';

module.exports = {
// Alphabet chars.
CHAR_UPPERCASE_A: 65, /*A*/
CHAR_LOWERCASE_A: 97, /*a*/
CHAR_UPPERCASE_Z: 90, /*Z*/
CHAR_LOWERCASE_Z: 122, /*z*/
const ASCII = {
NUL: 0,
SOH: 1,
STX: 2,
ETX: 3,
EOT: 4,
ENQ: 5,
ACK: 6,
BEL: 7,
BS: 8,
HT: 9,
LF: 10,
VT: 11,
FF: 12,
CR: 13,
SO: 14,
SI: 15,
DLE: 16,
DC1: 17,
DC2: 18,
DC3: 19,
DC4: 20,
NAK: 21,
SYN: 22,
ETB: 23,
CAN: 24,
EM: 25,
SUB: 26,
ESC: 27,
FS: 28,
GS: 29,
RS: 30,
US: 31,
SPACE: 32,
EXMARK: 33,
QUOTES: 34,
NUMSIGN: 35,
DOLLAR: 36,
PERCENT: 37,
AMPERSAND: 38,
APOSTROPHE: 39,
LPAREN: 40,
RPAREN: 41,
ASTERISK: 42,
PLUS: 43,
COMMA: 44,
HYPHEN: 45,
PERIOD: 46,
SLASH: 47,
DIGIT_0: 48,
DIGIT_1: 49,
DIGIT_2: 50,
DIGIT_3: 51,
DIGIT_4: 52,
DIGIT_5: 53,
DIGIT_6: 54,
DIGIT_7: 55,
DIGIT_8: 56,
DIGIT_9: 57,
COLON: 58,
SEMICOLON: 59,
LT: 60,
EQ: 61,
GT: 62,
QUES: 63,
AT: 64,
UPPER_A: 65,
UPPER_B: 66,
UPPER_C: 67,
UPPER_D: 68,
UPPER_E: 69,
UPPER_F: 70,
UPPER_G: 71,
UPPER_H: 72,
UPPER_I: 73,
UPPER_J: 74,
UPPER_K: 75,
UPPER_L: 76,
UPPER_M: 77,
UPPER_N: 78,
UPPER_O: 79,
UPPER_P: 80,
UPPER_Q: 81,
UPPER_R: 82,
UPPER_S: 83,
UPPER_T: 84,
UPPER_U: 85,
UPPER_V: 86,
UPPER_W: 87,
UPPER_X: 88,
UPPER_Y: 89,
UPPER_Z: 90,
LBRACK: 91,
BSLASH: 92,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you spell out BACKSLASH, NUMBER_SIGN, LEFT_BRACKET etc?

Ideally we’d use something pretty close to the official Unicode identifiers, although those might be a bit too verbose sometimes.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure!

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I personally also preferred the former more verbose naming with LOWERCASE and UPPERCASE.

RBRACK: 93,
CARET: 94,
UNDERSCORE: 95,
GRAVE_ACCENT: 96,
LOWER_A: 97,
LOWER_B: 98,
LOWER_C: 99,
LOWER_D: 100,
LOWER_E: 101,
LOWER_F: 102,
LOWER_G: 103,
LOWER_H: 104,
LOWER_I: 105,
LOWER_J: 106,
LOWER_K: 107,
LOWER_L: 108,
LOWER_M: 109,
LOWER_N: 110,
LOWER_O: 111,
LOWER_P: 112,
LOWER_Q: 113,
LOWER_R: 114,
LOWER_S: 115,
LOWER_T: 116,
LOWER_U: 117,
LOWER_V: 118,
LOWER_W: 119,
LOWER_X: 120,
LOWER_Y: 121,
LOWER_Z: 122,
LBRACE: 123,
VBAR: 124,
RBRACE: 125,
TILDE: 126,
DEL: 127
};

// Non-alphabetic chars.
CHAR_DOT: 46, /*.*/
CHAR_FORWARD_SLASH: 47, /*/*/
CHAR_BACKWARD_SLASH: 92, /*\*/
CHAR_COLON: 58, /*:*/
CHAR_QUESTION_MARK: 63, /*?*/
module.exports = {
ASCII
};
Loading