@gtkx/utils 1.1.0 → 1.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,3 @@
1
+ declare const errorCode: (error: unknown) => string | undefined;
2
+ export { errorCode };
3
+ //# sourceMappingURL=error-code.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"error-code.d.ts","sourceRoot":"","sources":["../../src/error/error-code.ts"],"names":[],"mappings":"AAAA,QAAA,MAAM,SAAS,GAAI,OAAO,OAAO,KAAG,MAAM,GAAG,SAC2D,CAAC;AAEzG,OAAO,EAAE,SAAS,EAAE,CAAC"}
@@ -0,0 +1,3 @@
1
+ const errorCode = (error) => error instanceof Error && "code" in error && typeof error.code === "string" ? error.code : undefined;
2
+ export { errorCode };
3
+ //# sourceMappingURL=error-code.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"error-code.js","sourceRoot":"","sources":["../../src/error/error-code.ts"],"names":[],"mappings":"AAAA,MAAM,SAAS,GAAG,CAAC,KAAc,EAAsB,EAAE,CACrD,KAAK,YAAY,KAAK,IAAI,MAAM,IAAI,KAAK,IAAI,OAAO,KAAK,CAAC,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC;AAEzG,OAAO,EAAE,SAAS,EAAE,CAAC","sourcesContent":["const errorCode = (error: unknown): string | undefined =>\n error instanceof Error && \"code\" in error && typeof error.code === \"string\" ? error.code : undefined;\n\nexport { errorCode };\n"]}
@@ -1,3 +1,4 @@
1
+ export { errorCode } from "./error-code.ts";
1
2
  export { errorMessage } from "./error-message.ts";
2
3
  export { formatChildProcessError } from "./format-child-process-error.ts";
3
4
  export { normalizeError } from "./normalize-error.ts";
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/error/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,uBAAuB,EAAE,MAAM,iCAAiC,CAAC;AAC1E,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/error/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,uBAAuB,EAAE,MAAM,iCAAiC,CAAC;AAC1E,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC"}
@@ -1,3 +1,4 @@
1
+ export { errorCode } from "./error-code.js";
1
2
  export { errorMessage } from "./error-message.js";
2
3
  export { formatChildProcessError } from "./format-child-process-error.js";
3
4
  export { normalizeError } from "./normalize-error.js";
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/error/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,uBAAuB,EAAE,MAAM,iCAAiC,CAAC;AAC1E,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC","sourcesContent":["export { errorMessage } from \"./error-message.ts\";\nexport { formatChildProcessError } from \"./format-child-process-error.ts\";\nexport { normalizeError } from \"./normalize-error.ts\";\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/error/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,uBAAuB,EAAE,MAAM,iCAAiC,CAAC;AAC1E,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC","sourcesContent":["export { errorCode } from \"./error-code.ts\";\nexport { errorMessage } from \"./error-message.ts\";\nexport { formatChildProcessError } from \"./format-child-process-error.ts\";\nexport { normalizeError } from \"./normalize-error.ts\";\n"]}
@@ -0,0 +1,3 @@
1
+ declare const escapeIdentifierStart: (name: string) => string;
2
+ export { escapeIdentifierStart };
3
+ //# sourceMappingURL=escape-identifier-start.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"escape-identifier-start.d.ts","sourceRoot":"","sources":["../../src/source/escape-identifier-start.ts"],"names":[],"mappings":"AAEA,QAAA,MAAM,qBAAqB,GAAI,MAAM,MAAM,KAAG,MAAsD,CAAC;AAErG,OAAO,EAAE,qBAAqB,EAAE,CAAC"}
@@ -0,0 +1,4 @@
1
+ const DIGIT_START = /^\d/;
2
+ const escapeIdentifierStart = (name) => (DIGIT_START.test(name) ? `_${name}` : name);
3
+ export { escapeIdentifierStart };
4
+ //# sourceMappingURL=escape-identifier-start.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"escape-identifier-start.js","sourceRoot":"","sources":["../../src/source/escape-identifier-start.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,GAAG,KAAK,CAAC;AAE1B,MAAM,qBAAqB,GAAG,CAAC,IAAY,EAAU,EAAE,CAAC,CAAC,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,IAAI,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;AAErG,OAAO,EAAE,qBAAqB,EAAE,CAAC","sourcesContent":["const DIGIT_START = /^\\d/;\n\nconst escapeIdentifierStart = (name: string): string => (DIGIT_START.test(name) ? `_${name}` : name);\n\nexport { escapeIdentifierStart };\n"]}
@@ -1,3 +1,4 @@
1
+ export { escapeIdentifierStart } from "./escape-identifier-start.ts";
1
2
  export { sanitizeIdentifier } from "./sanitize-identifier.ts";
2
3
  export { sanitizeTypeIdentifier } from "./sanitize-type-identifier.ts";
3
4
  export { sourceStringLiteral } from "./source-string-literal.ts";
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/source/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AAC9D,OAAO,EAAE,sBAAsB,EAAE,MAAM,+BAA+B,CAAC;AACvE,OAAO,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AACjE,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/source/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,MAAM,8BAA8B,CAAC;AACrE,OAAO,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AAC9D,OAAO,EAAE,sBAAsB,EAAE,MAAM,+BAA+B,CAAC;AACvE,OAAO,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AACjE,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC"}
@@ -1,3 +1,4 @@
1
+ export { escapeIdentifierStart } from "./escape-identifier-start.js";
1
2
  export { sanitizeIdentifier } from "./sanitize-identifier.js";
2
3
  export { sanitizeTypeIdentifier } from "./sanitize-type-identifier.js";
3
4
  export { sourceStringLiteral } from "./source-string-literal.js";
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/source/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AAC9D,OAAO,EAAE,sBAAsB,EAAE,MAAM,+BAA+B,CAAC;AACvE,OAAO,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AACjE,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC","sourcesContent":["export { sanitizeIdentifier } from \"./sanitize-identifier.ts\";\nexport { sanitizeTypeIdentifier } from \"./sanitize-type-identifier.ts\";\nexport { sourceStringLiteral } from \"./source-string-literal.ts\";\nexport { toCamelIdentifier } from \"./to-camel-identifier.ts\";\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/source/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,MAAM,8BAA8B,CAAC;AACrE,OAAO,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AAC9D,OAAO,EAAE,sBAAsB,EAAE,MAAM,+BAA+B,CAAC;AACvE,OAAO,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AACjE,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC","sourcesContent":["export { escapeIdentifierStart } from \"./escape-identifier-start.ts\";\nexport { sanitizeIdentifier } from \"./sanitize-identifier.ts\";\nexport { sanitizeTypeIdentifier } from \"./sanitize-type-identifier.ts\";\nexport { sourceStringLiteral } from \"./source-string-literal.ts\";\nexport { toCamelIdentifier } from \"./to-camel-identifier.ts\";\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"sanitize-identifier.d.ts","sourceRoot":"","sources":["../../src/source/sanitize-identifier.ts"],"names":[],"mappings":"AAEA,QAAA,MAAM,QAAQ,EAAE,GAAG,CAAC,MAAM,CAiDxB,CAAC;AAEH,iBAAS,kBAAkB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAEhD;AAED,OAAO,EAAE,QAAQ,EAAE,kBAAkB,EAAE,CAAC"}
1
+ {"version":3,"file":"sanitize-identifier.d.ts","sourceRoot":"","sources":["../../src/source/sanitize-identifier.ts"],"names":[],"mappings":"AAGA,QAAA,MAAM,QAAQ,EAAE,GAAG,CAAC,MAAM,CAiDxB,CAAC;AAEH,iBAAS,kBAAkB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAEhD;AAED,OAAO,EAAE,QAAQ,EAAE,kBAAkB,EAAE,CAAC"}
@@ -1,3 +1,4 @@
1
+ import { escapeIdentifierStart } from "./escape-identifier-start.js";
1
2
  import { escapeReserved } from "./escape-reserved.js";
2
3
  const RESERVED = new Set([
3
4
  "arguments",
@@ -50,7 +51,7 @@ const RESERVED = new Set([
50
51
  "yield",
51
52
  ]);
52
53
  function sanitizeIdentifier(name) {
53
- return escapeReserved(name, RESERVED);
54
+ return escapeIdentifierStart(escapeReserved(name, RESERVED));
54
55
  }
55
56
  export { RESERVED, sanitizeIdentifier };
56
57
  //# sourceMappingURL=sanitize-identifier.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"sanitize-identifier.js","sourceRoot":"","sources":["../../src/source/sanitize-identifier.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAEtD,MAAM,QAAQ,GAAgB,IAAI,GAAG,CAAC;IAClC,WAAW;IACX,OAAO;IACP,OAAO;IACP,MAAM;IACN,OAAO;IACP,OAAO;IACP,OAAO;IACP,UAAU;IACV,UAAU;IACV,SAAS;IACT,QAAQ;IACR,IAAI;IACJ,MAAM;IACN,MAAM;IACN,MAAM;IACN,QAAQ;IACR,SAAS;IACT,OAAO;IACP,SAAS;IACT,KAAK;IACL,UAAU;IACV,IAAI;IACJ,YAAY;IACZ,QAAQ;IACR,IAAI;IACJ,YAAY;IACZ,WAAW;IACX,KAAK;IACL,KAAK;IACL,MAAM;IACN,SAAS;IACT,SAAS;IACT,WAAW;IACX,QAAQ;IACR,QAAQ;IACR,QAAQ;IACR,OAAO;IACP,QAAQ;IACR,MAAM;IACN,OAAO;IACP,MAAM;IACN,KAAK;IACL,QAAQ;IACR,KAAK;IACL,MAAM;IACN,OAAO;IACP,MAAM;IACN,OAAO;CACV,CAAC,CAAC;AAEH,SAAS,kBAAkB,CAAC,IAAY;IACpC,OAAO,cAAc,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;AAC1C,CAAC;AAED,OAAO,EAAE,QAAQ,EAAE,kBAAkB,EAAE,CAAC","sourcesContent":["import { escapeReserved } from \"./escape-reserved.ts\";\n\nconst RESERVED: Set<string> = new Set([\n \"arguments\",\n \"await\",\n \"break\",\n \"case\",\n \"catch\",\n \"class\",\n \"const\",\n \"continue\",\n \"debugger\",\n \"default\",\n \"delete\",\n \"do\",\n \"else\",\n \"enum\",\n \"eval\",\n \"export\",\n \"extends\",\n \"false\",\n \"finally\",\n \"for\",\n \"function\",\n \"if\",\n \"implements\",\n \"import\",\n \"in\",\n \"instanceof\",\n \"interface\",\n \"let\",\n \"new\",\n \"null\",\n \"package\",\n \"private\",\n \"protected\",\n \"public\",\n \"return\",\n \"static\",\n \"super\",\n \"switch\",\n \"this\",\n \"throw\",\n \"true\",\n \"try\",\n \"typeof\",\n \"var\",\n \"void\",\n \"while\",\n \"with\",\n \"yield\",\n]);\n\nfunction sanitizeIdentifier(name: string): string {\n return escapeReserved(name, RESERVED);\n}\n\nexport { RESERVED, sanitizeIdentifier };\n"]}
1
+ {"version":3,"file":"sanitize-identifier.js","sourceRoot":"","sources":["../../src/source/sanitize-identifier.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,MAAM,8BAA8B,CAAC;AACrE,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAEtD,MAAM,QAAQ,GAAgB,IAAI,GAAG,CAAC;IAClC,WAAW;IACX,OAAO;IACP,OAAO;IACP,MAAM;IACN,OAAO;IACP,OAAO;IACP,OAAO;IACP,UAAU;IACV,UAAU;IACV,SAAS;IACT,QAAQ;IACR,IAAI;IACJ,MAAM;IACN,MAAM;IACN,MAAM;IACN,QAAQ;IACR,SAAS;IACT,OAAO;IACP,SAAS;IACT,KAAK;IACL,UAAU;IACV,IAAI;IACJ,YAAY;IACZ,QAAQ;IACR,IAAI;IACJ,YAAY;IACZ,WAAW;IACX,KAAK;IACL,KAAK;IACL,MAAM;IACN,SAAS;IACT,SAAS;IACT,WAAW;IACX,QAAQ;IACR,QAAQ;IACR,QAAQ;IACR,OAAO;IACP,QAAQ;IACR,MAAM;IACN,OAAO;IACP,MAAM;IACN,KAAK;IACL,QAAQ;IACR,KAAK;IACL,MAAM;IACN,OAAO;IACP,MAAM;IACN,OAAO;CACV,CAAC,CAAC;AAEH,SAAS,kBAAkB,CAAC,IAAY;IACpC,OAAO,qBAAqB,CAAC,cAAc,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC,CAAC;AACjE,CAAC;AAED,OAAO,EAAE,QAAQ,EAAE,kBAAkB,EAAE,CAAC","sourcesContent":["import { escapeIdentifierStart } from \"./escape-identifier-start.ts\";\nimport { escapeReserved } from \"./escape-reserved.ts\";\n\nconst RESERVED: Set<string> = new Set([\n \"arguments\",\n \"await\",\n \"break\",\n \"case\",\n \"catch\",\n \"class\",\n \"const\",\n \"continue\",\n \"debugger\",\n \"default\",\n \"delete\",\n \"do\",\n \"else\",\n \"enum\",\n \"eval\",\n \"export\",\n \"extends\",\n \"false\",\n \"finally\",\n \"for\",\n \"function\",\n \"if\",\n \"implements\",\n \"import\",\n \"in\",\n \"instanceof\",\n \"interface\",\n \"let\",\n \"new\",\n \"null\",\n \"package\",\n \"private\",\n \"protected\",\n \"public\",\n \"return\",\n \"static\",\n \"super\",\n \"switch\",\n \"this\",\n \"throw\",\n \"true\",\n \"try\",\n \"typeof\",\n \"var\",\n \"void\",\n \"while\",\n \"with\",\n \"yield\",\n]);\n\nfunction sanitizeIdentifier(name: string): string {\n return escapeIdentifierStart(escapeReserved(name, RESERVED));\n}\n\nexport { RESERVED, sanitizeIdentifier };\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"sanitize-type-identifier.d.ts","sourceRoot":"","sources":["../../src/source/sanitize-type-identifier.ts"],"names":[],"mappings":"AAiBA,iBAAS,sBAAsB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAEpD;AAED,OAAO,EAAE,sBAAsB,EAAE,CAAC"}
1
+ {"version":3,"file":"sanitize-type-identifier.d.ts","sourceRoot":"","sources":["../../src/source/sanitize-type-identifier.ts"],"names":[],"mappings":"AAkBA,iBAAS,sBAAsB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAEpD;AAED,OAAO,EAAE,sBAAsB,EAAE,CAAC"}
@@ -1,3 +1,4 @@
1
+ import { escapeIdentifierStart } from "./escape-identifier-start.js";
1
2
  import { escapeReserved } from "./escape-reserved.js";
2
3
  import { RESERVED } from "./sanitize-identifier.js";
3
4
  const TYPE_RESERVED = new Set([
@@ -14,7 +15,7 @@ const TYPE_RESERVED = new Set([
14
15
  "unknown",
15
16
  ]);
16
17
  function sanitizeTypeIdentifier(name) {
17
- return escapeReserved(name, TYPE_RESERVED);
18
+ return escapeIdentifierStart(escapeReserved(name, TYPE_RESERVED));
18
19
  }
19
20
  export { sanitizeTypeIdentifier };
20
21
  //# sourceMappingURL=sanitize-type-identifier.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"sanitize-type-identifier.js","sourceRoot":"","sources":["../../src/source/sanitize-type-identifier.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AAEpD,MAAM,aAAa,GAAgB,IAAI,GAAG,CAAC;IACvC,GAAG,QAAQ;IACX,KAAK;IACL,QAAQ;IACR,SAAS;IACT,OAAO;IACP,QAAQ;IACR,QAAQ;IACR,QAAQ;IACR,QAAQ;IACR,WAAW;IACX,SAAS;CACZ,CAAC,CAAC;AAEH,SAAS,sBAAsB,CAAC,IAAY;IACxC,OAAO,cAAc,CAAC,IAAI,EAAE,aAAa,CAAC,CAAC;AAC/C,CAAC;AAED,OAAO,EAAE,sBAAsB,EAAE,CAAC","sourcesContent":["import { escapeReserved } from \"./escape-reserved.ts\";\nimport { RESERVED } from \"./sanitize-identifier.ts\";\n\nconst TYPE_RESERVED: Set<string> = new Set([\n ...RESERVED,\n \"any\",\n \"bigint\",\n \"boolean\",\n \"never\",\n \"number\",\n \"object\",\n \"string\",\n \"symbol\",\n \"undefined\",\n \"unknown\",\n]);\n\nfunction sanitizeTypeIdentifier(name: string): string {\n return escapeReserved(name, TYPE_RESERVED);\n}\n\nexport { sanitizeTypeIdentifier };\n"]}
1
+ {"version":3,"file":"sanitize-type-identifier.js","sourceRoot":"","sources":["../../src/source/sanitize-type-identifier.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,MAAM,8BAA8B,CAAC;AACrE,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AAEpD,MAAM,aAAa,GAAgB,IAAI,GAAG,CAAC;IACvC,GAAG,QAAQ;IACX,KAAK;IACL,QAAQ;IACR,SAAS;IACT,OAAO;IACP,QAAQ;IACR,QAAQ;IACR,QAAQ;IACR,QAAQ;IACR,WAAW;IACX,SAAS;CACZ,CAAC,CAAC;AAEH,SAAS,sBAAsB,CAAC,IAAY;IACxC,OAAO,qBAAqB,CAAC,cAAc,CAAC,IAAI,EAAE,aAAa,CAAC,CAAC,CAAC;AACtE,CAAC;AAED,OAAO,EAAE,sBAAsB,EAAE,CAAC","sourcesContent":["import { escapeIdentifierStart } from \"./escape-identifier-start.ts\";\nimport { escapeReserved } from \"./escape-reserved.ts\";\nimport { RESERVED } from \"./sanitize-identifier.ts\";\n\nconst TYPE_RESERVED: Set<string> = new Set([\n ...RESERVED,\n \"any\",\n \"bigint\",\n \"boolean\",\n \"never\",\n \"number\",\n \"object\",\n \"string\",\n \"symbol\",\n \"undefined\",\n \"unknown\",\n]);\n\nfunction sanitizeTypeIdentifier(name: string): string {\n return escapeIdentifierStart(escapeReserved(name, TYPE_RESERVED));\n}\n\nexport { sanitizeTypeIdentifier };\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gtkx/utils",
3
- "version": "1.1.0",
3
+ "version": "1.2.1",
4
4
  "description": "Cross-package utilities shared by the GTKX packages and toolchain: logging, error formatting, string and class helpers",
5
5
  "keywords": [
6
6
  "gtkx",
@@ -0,0 +1,4 @@
1
+ const errorCode = (error: unknown): string | undefined =>
2
+ error instanceof Error && "code" in error && typeof error.code === "string" ? error.code : undefined;
3
+
4
+ export { errorCode };
@@ -1,3 +1,4 @@
1
+ export { errorCode } from "./error-code.ts";
1
2
  export { errorMessage } from "./error-message.ts";
2
3
  export { formatChildProcessError } from "./format-child-process-error.ts";
3
4
  export { normalizeError } from "./normalize-error.ts";
@@ -0,0 +1,5 @@
1
+ const DIGIT_START = /^\d/;
2
+
3
+ const escapeIdentifierStart = (name: string): string => (DIGIT_START.test(name) ? `_${name}` : name);
4
+
5
+ export { escapeIdentifierStart };
@@ -1,3 +1,4 @@
1
+ export { escapeIdentifierStart } from "./escape-identifier-start.ts";
1
2
  export { sanitizeIdentifier } from "./sanitize-identifier.ts";
2
3
  export { sanitizeTypeIdentifier } from "./sanitize-type-identifier.ts";
3
4
  export { sourceStringLiteral } from "./source-string-literal.ts";
@@ -1,3 +1,4 @@
1
+ import { escapeIdentifierStart } from "./escape-identifier-start.ts";
1
2
  import { escapeReserved } from "./escape-reserved.ts";
2
3
 
3
4
  const RESERVED: Set<string> = new Set([
@@ -52,7 +53,7 @@ const RESERVED: Set<string> = new Set([
52
53
  ]);
53
54
 
54
55
  function sanitizeIdentifier(name: string): string {
55
- return escapeReserved(name, RESERVED);
56
+ return escapeIdentifierStart(escapeReserved(name, RESERVED));
56
57
  }
57
58
 
58
59
  export { RESERVED, sanitizeIdentifier };
@@ -1,3 +1,4 @@
1
+ import { escapeIdentifierStart } from "./escape-identifier-start.ts";
1
2
  import { escapeReserved } from "./escape-reserved.ts";
2
3
  import { RESERVED } from "./sanitize-identifier.ts";
3
4
 
@@ -16,7 +17,7 @@ const TYPE_RESERVED: Set<string> = new Set([
16
17
  ]);
17
18
 
18
19
  function sanitizeTypeIdentifier(name: string): string {
19
- return escapeReserved(name, TYPE_RESERVED);
20
+ return escapeIdentifierStart(escapeReserved(name, TYPE_RESERVED));
20
21
  }
21
22
 
22
23
  export { sanitizeTypeIdentifier };