@o3co/ts.hocon 0.1.1 → 0.1.2

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
@@ -86,13 +86,21 @@ var Config = class _Config {
86
86
  }
87
87
  getNumber(path2) {
88
88
  const v = this.requireScalar(path2);
89
- if (typeof v !== "number") throw new ConfigError(`expected number at ${path2}, got ${typeof v}`, path2);
90
- return v;
89
+ if (typeof v === "number") return v;
90
+ if (typeof v === "string") {
91
+ const n = Number(v);
92
+ if (!Number.isNaN(n)) return n;
93
+ }
94
+ throw new ConfigError(`expected number at ${path2}, got ${typeof v}`, path2);
91
95
  }
92
96
  getBoolean(path2) {
93
97
  const v = this.requireScalar(path2);
94
- if (typeof v !== "boolean") throw new ConfigError(`expected boolean at ${path2}, got ${typeof v}`, path2);
95
- return v;
98
+ if (typeof v === "boolean") return v;
99
+ if (typeof v === "string") {
100
+ if (v === "true") return true;
101
+ if (v === "false") return false;
102
+ }
103
+ throw new ConfigError(`expected boolean at ${path2}, got ${typeof v}`, path2);
96
104
  }
97
105
  getConfig(path2) {
98
106
  const v = this.lookupNode(path2);
package/dist/index.js CHANGED
@@ -43,13 +43,21 @@ var Config = class _Config {
43
43
  }
44
44
  getNumber(path2) {
45
45
  const v = this.requireScalar(path2);
46
- if (typeof v !== "number") throw new ConfigError(`expected number at ${path2}, got ${typeof v}`, path2);
47
- return v;
46
+ if (typeof v === "number") return v;
47
+ if (typeof v === "string") {
48
+ const n = Number(v);
49
+ if (!Number.isNaN(n)) return n;
50
+ }
51
+ throw new ConfigError(`expected number at ${path2}, got ${typeof v}`, path2);
48
52
  }
49
53
  getBoolean(path2) {
50
54
  const v = this.requireScalar(path2);
51
- if (typeof v !== "boolean") throw new ConfigError(`expected boolean at ${path2}, got ${typeof v}`, path2);
52
- return v;
55
+ if (typeof v === "boolean") return v;
56
+ if (typeof v === "string") {
57
+ if (v === "true") return true;
58
+ if (v === "false") return false;
59
+ }
60
+ throw new ConfigError(`expected boolean at ${path2}, got ${typeof v}`, path2);
53
61
  }
54
62
  getConfig(path2) {
55
63
  const v = this.lookupNode(path2);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@o3co/ts.hocon",
3
- "version": "0.1.1",
3
+ "version": "0.1.2",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": {