@o3co/ts.hocon 1.6.1 → 1.7.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.
package/dist/index.cjs CHANGED
@@ -2974,9 +2974,8 @@ function renderHoconAsJSON(v) {
2974
2974
  case "boolean":
2975
2975
  return v.raw;
2976
2976
  case "number": {
2977
- const n = Number(v.raw);
2978
- if (Number.isFinite(n)) return v.raw;
2979
- return JSON.stringify(v.raw);
2977
+ const norm = normalizeLeadingZeroNumber(v.raw);
2978
+ return JSON_NUMBER_RE.test(norm) ? norm : JSON.stringify(v.raw);
2980
2979
  }
2981
2980
  case "string":
2982
2981
  return JSON.stringify(v.raw);
@@ -2998,6 +2997,10 @@ function renderHoconAsJSON(v) {
2998
2997
  }
2999
2998
  throw new Error(`renderHoconAsJSON: unsupported value kind (unresolved placeholder?)`);
3000
2999
  }
3000
+ var JSON_NUMBER_RE = /^-?(?:0|[1-9]\d*)(?:\.\d+)?(?:[eE][+-]?\d+)?$/;
3001
+ function normalizeLeadingZeroNumber(raw) {
3002
+ return raw.replace(/^([+-]?)0+(\d)/, "$1$2");
3003
+ }
3001
3004
 
3002
3005
  // src/parse.ts
3003
3006
  var fs = __toESM(require("fs"), 1);
package/dist/index.js CHANGED
@@ -2921,9 +2921,8 @@ function renderHoconAsJSON(v) {
2921
2921
  case "boolean":
2922
2922
  return v.raw;
2923
2923
  case "number": {
2924
- const n = Number(v.raw);
2925
- if (Number.isFinite(n)) return v.raw;
2926
- return JSON.stringify(v.raw);
2924
+ const norm = normalizeLeadingZeroNumber(v.raw);
2925
+ return JSON_NUMBER_RE.test(norm) ? norm : JSON.stringify(v.raw);
2927
2926
  }
2928
2927
  case "string":
2929
2928
  return JSON.stringify(v.raw);
@@ -2945,6 +2944,10 @@ function renderHoconAsJSON(v) {
2945
2944
  }
2946
2945
  throw new Error(`renderHoconAsJSON: unsupported value kind (unresolved placeholder?)`);
2947
2946
  }
2947
+ var JSON_NUMBER_RE = /^-?(?:0|[1-9]\d*)(?:\.\d+)?(?:[eE][+-]?\d+)?$/;
2948
+ function normalizeLeadingZeroNumber(raw) {
2949
+ return raw.replace(/^([+-]?)0+(\d)/, "$1$2");
2950
+ }
2948
2951
 
2949
2952
  // src/parse.ts
2950
2953
  import * as fs from "fs";
package/dist/zod.cjs CHANGED
@@ -2961,9 +2961,8 @@ function renderHoconAsJSON(v) {
2961
2961
  case "boolean":
2962
2962
  return v.raw;
2963
2963
  case "number": {
2964
- const n = Number(v.raw);
2965
- if (Number.isFinite(n)) return v.raw;
2966
- return JSON.stringify(v.raw);
2964
+ const norm = normalizeLeadingZeroNumber(v.raw);
2965
+ return JSON_NUMBER_RE.test(norm) ? norm : JSON.stringify(v.raw);
2967
2966
  }
2968
2967
  case "string":
2969
2968
  return JSON.stringify(v.raw);
@@ -2985,6 +2984,10 @@ function renderHoconAsJSON(v) {
2985
2984
  }
2986
2985
  throw new Error(`renderHoconAsJSON: unsupported value kind (unresolved placeholder?)`);
2987
2986
  }
2987
+ var JSON_NUMBER_RE = /^-?(?:0|[1-9]\d*)(?:\.\d+)?(?:[eE][+-]?\d+)?$/;
2988
+ function normalizeLeadingZeroNumber(raw) {
2989
+ return raw.replace(/^([+-]?)0+(\d)/, "$1$2");
2990
+ }
2988
2991
 
2989
2992
  // src/parse.ts
2990
2993
  function getEnv(opts) {
package/dist/zod.js CHANGED
@@ -2921,9 +2921,8 @@ function renderHoconAsJSON(v) {
2921
2921
  case "boolean":
2922
2922
  return v.raw;
2923
2923
  case "number": {
2924
- const n = Number(v.raw);
2925
- if (Number.isFinite(n)) return v.raw;
2926
- return JSON.stringify(v.raw);
2924
+ const norm = normalizeLeadingZeroNumber(v.raw);
2925
+ return JSON_NUMBER_RE.test(norm) ? norm : JSON.stringify(v.raw);
2927
2926
  }
2928
2927
  case "string":
2929
2928
  return JSON.stringify(v.raw);
@@ -2945,6 +2944,10 @@ function renderHoconAsJSON(v) {
2945
2944
  }
2946
2945
  throw new Error(`renderHoconAsJSON: unsupported value kind (unresolved placeholder?)`);
2947
2946
  }
2947
+ var JSON_NUMBER_RE = /^-?(?:0|[1-9]\d*)(?:\.\d+)?(?:[eE][+-]?\d+)?$/;
2948
+ function normalizeLeadingZeroNumber(raw) {
2949
+ return raw.replace(/^([+-]?)0+(\d)/, "$1$2");
2950
+ }
2948
2951
 
2949
2952
  // src/parse.ts
2950
2953
  function getEnv(opts) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@o3co/ts.hocon",
3
- "version": "1.6.1",
3
+ "version": "1.7.1",
4
4
  "description": "Full Lightbend HOCON spec-compliant parser and config library for TypeScript",
5
5
  "keywords": [
6
6
  "hocon",