[d24f17c] | 1 | "use strict";
|
---|
| 2 | // NOTE: don't construct errors here or they'll have the wrong stack trace.
|
---|
| 3 | // NOTE: don't make custom error class; the JS engines use `SyntaxError`
|
---|
| 4 | Object.defineProperty(exports, "__esModule", { value: true });
|
---|
| 5 | exports.errorMessages = exports.ErrorType = void 0;
|
---|
| 6 | /**
|
---|
| 7 | * Keys for possible error messages used by `unraw`.
|
---|
| 8 | * Note: These do _not_ map to actual error object types. All errors thrown
|
---|
| 9 | * are `SyntaxError`.
|
---|
| 10 | */
|
---|
| 11 | // Don't use const enum or JS users won't be able to access the enum values
|
---|
| 12 | var ErrorType;
|
---|
| 13 | (function (ErrorType) {
|
---|
| 14 | /**
|
---|
| 15 | * Thrown when a badly formed Unicode escape sequence is found. Possible
|
---|
| 16 | * reasons include the code being too short (`"\u25"`) or having invalid
|
---|
| 17 | * characters (`"\u2$A5"`).
|
---|
| 18 | */
|
---|
| 19 | ErrorType["MalformedUnicode"] = "MALFORMED_UNICODE";
|
---|
| 20 | /**
|
---|
| 21 | * Thrown when a badly formed hexadecimal escape sequence is found. Possible
|
---|
| 22 | * reasons include the code being too short (`"\x2"`) or having invalid
|
---|
| 23 | * characters (`"\x2$"`).
|
---|
| 24 | */
|
---|
| 25 | ErrorType["MalformedHexadecimal"] = "MALFORMED_HEXADECIMAL";
|
---|
| 26 | /**
|
---|
| 27 | * Thrown when a Unicode code point escape sequence has too high of a code
|
---|
| 28 | * point. The maximum code point allowed is `\u{10FFFF}`, so `\u{110000}` and
|
---|
| 29 | * higher will throw this error.
|
---|
| 30 | */
|
---|
| 31 | ErrorType["CodePointLimit"] = "CODE_POINT_LIMIT";
|
---|
| 32 | /**
|
---|
| 33 | * Thrown when an octal escape sequences is encountered and `allowOctals` is
|
---|
| 34 | * `false`. For example, `unraw("\234", false)`.
|
---|
| 35 | */
|
---|
| 36 | ErrorType["OctalDeprecation"] = "OCTAL_DEPRECATION";
|
---|
| 37 | /**
|
---|
| 38 | * Thrown only when a single backslash is found at the end of a string. For
|
---|
| 39 | * example, `"\\"` or `"test\\x24\\"`.
|
---|
| 40 | */
|
---|
| 41 | ErrorType["EndOfString"] = "END_OF_STRING";
|
---|
| 42 | })(ErrorType = exports.ErrorType || (exports.ErrorType = {}));
|
---|
| 43 | /** Map of error message names to the full text of the message. */
|
---|
| 44 | exports.errorMessages = new Map([
|
---|
| 45 | [ErrorType.MalformedUnicode, "malformed Unicode character escape sequence"],
|
---|
| 46 | [
|
---|
| 47 | ErrorType.MalformedHexadecimal,
|
---|
| 48 | "malformed hexadecimal character escape sequence"
|
---|
| 49 | ],
|
---|
| 50 | [
|
---|
| 51 | ErrorType.CodePointLimit,
|
---|
| 52 | "Unicode codepoint must not be greater than 0x10FFFF in escape sequence"
|
---|
| 53 | ],
|
---|
| 54 | [
|
---|
| 55 | ErrorType.OctalDeprecation,
|
---|
| 56 | '"0"-prefixed octal literals and octal escape sequences are deprecated; ' +
|
---|
| 57 | 'for octal literals use the "0o" prefix instead'
|
---|
| 58 | ],
|
---|
| 59 | [ErrorType.EndOfString, "malformed escape sequence at end of string"]
|
---|
| 60 | ]);
|
---|