MCPcopy Create free account
hub / github.com/EvoMap/evolver / envPositiveInt

Function envPositiveInt

src/config.js:21–39  ·  view source on GitHub ↗
(key, fallback)

Source from the content-addressed store, hash-verified

19// is not silently running a broken setup.
20const _envPositiveIntWarned = new Set();
21function envPositiveInt(key, fallback) {
22 const v = process.env[key];
23 if (v === undefined || v === '') return fallback;
24 const n = parseInt(v, 10);
25 const valid = Number.isFinite(n) && n > 0 && n < 2 ** 31;
26 if (!valid) {
27 if (!_envPositiveIntWarned.has(key)) {
28 _envPositiveIntWarned.add(key);
29 try {
30 console.warn(
31 '[config] ' + key + '=' + JSON.stringify(v) + ' is not a positive integer; ' +
32 'falling back to ' + fallback + '. Set a value in (0, 2^31) ms.'
33 );
34 } catch (_) {}
35 }
36 return fallback;
37 }
38 return n;
39}
40
41function envFloat(key, fallback) {
42 const v = process.env[key];

Callers 3

config.test.jsFile · 0.85
config.jsFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected