config 4.4.0 → 5.0.0-alpha.0

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/lib/defer.js CHANGED
@@ -1,4 +1,4 @@
1
- const { isAsyncFunction } = require('node:util/types');
1
+ import { isAsyncFunction } from 'node:util/types';
2
2
 
3
3
  /** @typedef {import('./config').Config} Config */
4
4
 
@@ -66,5 +66,4 @@ function deferConfig(func) {
66
66
  return obj;
67
67
  }
68
68
 
69
- module.exports.deferConfig = deferConfig;
70
- module.exports.DeferredConfig = DeferredConfig;
69
+ export { deferConfig, DeferredConfig };
package/lib/util.js CHANGED
@@ -5,11 +5,13 @@
5
5
 
6
6
  // Dependencies
7
7
  /** @typedef {typeof import('./../parser')} Parser */
8
- const { deferConfig, DeferredConfig } = require('./defer.js');
9
- const { resolveAsyncConfigs } = require('../async');
10
- const Path = require('path');
11
- const FileSystem = require('fs');
12
- const OS = require("os");
8
+ import Path from 'node:path';
9
+ import FileSystem from 'node:fs';
10
+ import OS from 'node:os';
11
+ import { createRequire } from 'node:module';
12
+
13
+ import defaultParser from '../parser.js';
14
+ import { deferConfig, DeferredConfig } from './defer.js';
13
15
 
14
16
  const DEFAULT_CONFIG_DIR = Path.join( process.cwd(), 'config');
15
17
  const SEEN_ERRORS = {};
@@ -61,7 +63,7 @@ const DEFAULT_OPTIONS = {
61
63
  nodeEnv: ['development'],
62
64
  hostName: OS.hostname(),
63
65
  gitCrypt: true,
64
- parser: require("../parser.js")
66
+ parser: defaultParser
65
67
  };
66
68
 
67
69
  /**
@@ -454,8 +456,6 @@ class Util {
454
456
  static async resolveAsyncConfigs(config) {
455
457
  const promises = [];
456
458
 
457
- await resolveAsyncConfigs(config);
458
-
459
459
  function _iterate (prop) {
460
460
  if (prop == null || prop.constructor === String) {
461
461
  return;
@@ -713,7 +713,7 @@ class Util {
713
713
  * @method extendDeep
714
714
  * @param mergeInto {Object} The object to merge into
715
715
  * @param mergeFrom... {Object} - Any number of objects to merge from
716
- * @param [depth] {number} An optional depth to prevent recursion. Default: 20.
716
+ * @param {number} [depth=20] - An optional depth to prevent recursion. Default: 20.
717
717
  * @return {Object} The altered mergeInto object is returned
718
718
  */
719
719
  static extendDeep(mergeInto, ...vargs) {
@@ -1357,7 +1357,6 @@ class Load {
1357
1357
  * This function exists in part to reduce the circular dependency of variable initializations
1358
1358
  * in the config.js file
1359
1359
  * @param {string} environments the NODE_CONFIG_ENVs you want to load
1360
- * @private
1361
1360
  * @returns {Load}
1362
1361
  */
1363
1362
  static fromEnvironment(environments) {
@@ -1396,7 +1395,6 @@ class Load {
1396
1395
  // Remove any . appendages, and default to null if not set
1397
1396
  try {
1398
1397
  if (!hostName) {
1399
- const OS = require('os');
1400
1398
  hostName = OS.hostname();
1401
1399
  }
1402
1400
  } catch (e) {
@@ -1454,15 +1452,17 @@ function _toAbsolutePath (configDir) {
1454
1452
  return configDir;
1455
1453
  }
1456
1454
 
1457
- function _loadParser(name, dir) {
1455
+ function _loadParser(name, dir = process.cwd()) {
1458
1456
  if (name === undefined) {
1459
- return require("../parser.js");
1457
+ return defaultParser;
1460
1458
  }
1461
1459
 
1460
+ const require = createRequire(_toAbsolutePath(dir));
1461
+
1462
1462
  try {
1463
- const parserModule = Path.isAbsolute(name) ? name : Path.join(dir, name);
1463
+ const required = require(Path.resolve(dir, name));
1464
1464
 
1465
- return require(parserModule);
1465
+ return required.default ?? required;
1466
1466
  }
1467
1467
  catch (e) {
1468
1468
  console.warn(`Failed to load config parser from ${name}`);
@@ -1470,4 +1470,4 @@ function _loadParser(name, dir) {
1470
1470
  }
1471
1471
  }
1472
1472
 
1473
- module.exports = { Util, Load, RawConfig };
1473
+ export { Util, Load, RawConfig };
package/package.json CHANGED
@@ -1,34 +1,17 @@
1
1
  {
2
2
  "name": "config",
3
- "version": "4.4.0",
3
+ "version": "5.0.0-alpha.0",
4
4
  "main": "./lib/config.js",
5
+ "module": "./lib/config.mjs",
5
6
  "types": "types/lib/config.d.ts",
6
7
  "typesVersions": {
7
8
  "*": {
8
- "async": [
9
- "types/async.d.ts"
10
- ],
11
- "async.js": [
12
- "types/async.d.ts"
13
- ],
14
- "defer": [
15
- "types/defer.d.ts"
16
- ],
17
- "defer.js": [
18
- "types/defer.d.ts"
19
- ],
20
9
  "parser": [
21
10
  "types/parser.d.ts"
22
11
  ],
23
12
  "parser.js": [
24
13
  "types/parser.d.ts"
25
14
  ],
26
- "raw": [
27
- "types/raw.d.ts"
28
- ],
29
- "raw.js": [
30
- "types/raw.d.ts"
31
- ],
32
15
  "lib/defer": [
33
16
  "types/lib/defer.d.ts"
34
17
  ],
@@ -87,7 +70,7 @@
87
70
  "url": "http://github.com/node-config/node-config.git"
88
71
  },
89
72
  "engines": {
90
- "node": ">= 20.0.0"
73
+ "node": ">= 20.11.0"
91
74
  },
92
75
  "c8": {
93
76
  "include": [
package/parser.js CHANGED
@@ -1,16 +1,12 @@
1
1
  // External libraries are lazy-loaded only if these file types exist.
2
+ import Path from 'path';
3
+ import { createRequire } from 'node:module';
4
+ import JSON5 from 'json5';
2
5
 
3
- // webpack can't solve dynamic module
4
- // @see https://github.com/node-config/node-config/issues/755
5
- // @see https://webpack.js.org/guides/dependency-management/#require-with-expression
6
- const JSON5Module = require('json5');
6
+ const moduleRequire = createRequire(Path.join(process.cwd(), 'package.json'));
7
+ const require = createRequire(process.cwd());
7
8
 
8
- // webpack resolves json5 with module field out of the box which lead to this usage
9
- // @see https://github.com/node-config/node-config/issues/755
10
- // @see https://github.com/json5/json5/issues/240
11
- const JSON5 = JSON5Module.default || JSON5Module;
12
-
13
- var Yaml = null,
9
+ let Yaml = null,
14
10
  JSYaml = null,
15
11
  Coffee = null,
16
12
  Iced = null,
@@ -18,10 +14,11 @@ var Yaml = null,
18
14
  PPARSER = null,
19
15
  TOML = null,
20
16
  HJSON = null,
21
- XML = null;
17
+ XML = null,
18
+ TS = null;
22
19
 
23
20
  // Define soft dependencies so transpilers don't include everything
24
- var COFFEE_2_DEP = 'coffeescript',
21
+ let COFFEE_2_DEP = 'coffeescript',
25
22
  COFFEE_DEP = 'coffee-script',
26
23
  ICED_DEP = 'iced-coffee-script',
27
24
  JS_YAML_DEP = 'js-yaml',
@@ -38,7 +35,7 @@ var COFFEE_2_DEP = 'coffeescript',
38
35
  * @template [T=any]
39
36
  * @typedef {(filename: string, content: string) => T | undefined} ParserFn<T>
40
37
  */
41
- var Parser = module.exports;
38
+ let Parser = {};
42
39
 
43
40
  /**
44
41
  * @param {string} filename
@@ -60,7 +57,7 @@ Parser.parse = function(filename, content) {
60
57
  */
61
58
  Parser.xmlParser = function(filename, content) {
62
59
  if (!XML) {
63
- XML = require(XML_DEP);
60
+ XML = moduleRequire(XML_DEP);
64
61
  }
65
62
  var x2js = new XML();
66
63
  var configObject = x2js.xml2js(content);
@@ -91,15 +88,18 @@ Parser.jsParser = function(filename, content) {
91
88
  * @returns {object}
92
89
  */
93
90
  Parser.tsParser = function(filename, content) {
94
- if (!require.extensions['.ts']) {
95
- require(TS_DEP).register({
96
- lazy: true,
97
- ignore: ['(?:^|/)node_modules/', '.*(?<!\.ts)$'],
98
- transpileOnly: true,
99
- compilerOptions: {
100
- allowJs: true,
101
- }
102
- });
91
+ if (require?.extensions?.['.ts'] === undefined) {
92
+ if (TS === null) {
93
+ TS = moduleRequire(TS_DEP);
94
+ TS.register({
95
+ lazy: true,
96
+ ignore: ['(?:^|/)node_modules/', '.*(?<!\.ts)$'],
97
+ transpileOnly: true,
98
+ compilerOptions: {
99
+ allowJs: true,
100
+ }
101
+ });
102
+ }
103
103
  }
104
104
 
105
105
  // Imports config if it is exported via module.exports = ...
@@ -126,21 +126,13 @@ Parser.coffeeParser = function(filename, content) {
126
126
  if (!Coffee) {
127
127
  Coffee = {};
128
128
 
129
- // The following enables iced-coffee-script on .coffee files, if iced-coffee-script is available.
130
- // This is commented as per a decision on a pull request.
131
- //try {
132
- // Coffee = require('iced-coffee-script');
133
- //}
134
- //catch (e) {
135
- // Coffee = require('coffee-script');
136
- //}
137
129
  try {
138
130
  // Try to load coffeescript
139
- Coffee = require(COFFEE_2_DEP);
131
+ Coffee = moduleRequire(COFFEE_2_DEP);
140
132
  }
141
133
  catch (e) {
142
134
  // If it doesn't exist, try to load it using the deprecated module name
143
- Coffee = require(COFFEE_DEP);
135
+ Coffee = moduleRequire(COFFEE_DEP);
144
136
  }
145
137
  // coffee-script >= 1.7.0 requires explicit registration for require() to work
146
138
  if (Coffee.register) {
@@ -157,7 +149,7 @@ Parser.coffeeParser = function(filename, content) {
157
149
  * @returns {object | undefined}
158
150
  */
159
151
  Parser.icedParser = function(filename, content) {
160
- Iced = require(ICED_DEP);
152
+ Iced = moduleRequire(ICED_DEP);
161
153
 
162
154
  // coffee-script >= 1.7.0 requires explicit registration for require() to work
163
155
  if (Iced.register) {
@@ -174,10 +166,10 @@ Parser.yamlParser = function(filename, content) {
174
166
  if (!Yaml && !JSYaml) {
175
167
  // Lazy loading
176
168
  try {
177
- Yaml = require(YAML_DEP);
169
+ Yaml = moduleRequire(YAML_DEP);
178
170
  } catch (e) {
179
171
  try {
180
- JSYaml = require(JS_YAML_DEP);
172
+ JSYaml = moduleRequire(JS_YAML_DEP);
181
173
  } catch (e) {}
182
174
  }
183
175
  }
@@ -221,7 +213,7 @@ Parser.json5Parser = function(filename, content) {
221
213
  */
222
214
  Parser.hjsonParser = function(filename, content) {
223
215
  if (!HJSON) {
224
- HJSON = require(HJSON_DEP);
216
+ HJSON = moduleRequire(HJSON_DEP);
225
217
  }
226
218
  return HJSON.parse(content);
227
219
  };
@@ -233,7 +225,7 @@ Parser.hjsonParser = function(filename, content) {
233
225
  */
234
226
  Parser.tomlParser = function(filename, content) {
235
227
  if(!TOML) {
236
- TOML = require(TOML_DEP);
228
+ TOML = moduleRequire(TOML_DEP);
237
229
  }
238
230
  return TOML.parse(content);
239
231
  };
@@ -245,7 +237,7 @@ Parser.tomlParser = function(filename, content) {
245
237
  */
246
238
  Parser.csonParser = function(filename, content) {
247
239
  if (!CSON) {
248
- CSON = require(CSON_DEP);
240
+ CSON = moduleRequire(CSON_DEP);
249
241
  }
250
242
  // Allow comments in CSON files
251
243
  if (typeof CSON.parseSync === 'function') {
@@ -261,7 +253,7 @@ Parser.csonParser = function(filename, content) {
261
253
  */
262
254
  Parser.propertiesParser = function(filename, content) {
263
255
  if (!PPARSER) {
264
- PPARSER = require(PPARSER_DEP);
256
+ PPARSER = moduleRequire(PPARSER_DEP);
265
257
  }
266
258
  return PPARSER.parse(content, { namespaces: true, variables: true, sections: true });
267
259
  };
@@ -382,3 +374,5 @@ Parser.setFilesOrder = function(name, newIndex) {
382
374
  function isObject(arg) {
383
375
  return (arg !== null) && (typeof arg === 'object');
384
376
  }
377
+
378
+ export default Parser;
@@ -0,0 +1,365 @@
1
+ declare const _default: ConfigClass;
2
+ export default _default;
3
+ export type Util = import("./util.js").Util;
4
+ export type Load = import("./util.js").Load;
5
+ export type LoadOptions = import("./util.js").LoadOptions;
6
+ export type Parser = typeof import("./../parser.js");
7
+ /**
8
+ * The exported configuration instance type.
9
+ * This is here because the Config class is not a named export and this is how we get
10
+ * the exported configuration instance type.
11
+ */
12
+ export type Config = ConfigClass;
13
+ /**
14
+ * <p>Application Configurations</p>
15
+ * @class
16
+ */
17
+ declare class ConfigClass {
18
+ /**
19
+ * <p>Get the configuration object.</p>
20
+ *
21
+ * <p>
22
+ * The configuration object is a shared singleton object within the application,
23
+ * attained by calling require('config').
24
+ * </p>
25
+ *
26
+ * <p>
27
+ * Usually you'll specify a CONFIG variable at the top of your .js file
28
+ * for file/module scope. If you want the root of the object, you can do this:
29
+ * </p>
30
+ * <pre>
31
+ * const CONFIG = require('config');
32
+ * </pre>
33
+ *
34
+ * <p>
35
+ * Sometimes you only care about a specific sub-object within the CONFIG
36
+ * object. In that case you could do this at the top of your file:
37
+ * </p>
38
+ * <pre>
39
+ * const CONFIG = require('config').customer;
40
+ * or
41
+ * const CUSTOMER_CONFIG = require('config').customer;
42
+ * </pre>
43
+ *
44
+ * <script type="text/javascript">
45
+ * document.getElementById("showProtected").style.display = "block";
46
+ * </script>
47
+ *
48
+ * @method constructor
49
+ */
50
+ constructor(load: any);
51
+ /**
52
+ * Non-enumerable field for util functions
53
+ *
54
+ * @type {ConfigUtils}
55
+ */
56
+ util: ConfigUtils;
57
+ /**
58
+ * <p>Get a configuration value</p>
59
+ *
60
+ * <p>
61
+ * This will return the specified property value, throwing an exception if the
62
+ * configuration isn't defined. It is used to assure configurations are defined
63
+ * before being used, and to prevent typos.
64
+ * </p>
65
+ *
66
+ * @template T
67
+ * @param {string} property - The configuration property to get. Can include '.' sub-properties.
68
+ * @returns {T} The property value
69
+ */
70
+ get<T>(property: string): T;
71
+ /**
72
+ * Test that a configuration parameter exists
73
+ *
74
+ * <pre>
75
+ * const config = require('config');
76
+ * if (config.has('customer.dbName')) {
77
+ * console.log('Customer database name: ' + config.customer.dbName);
78
+ * }
79
+ * </pre>
80
+ *
81
+ * @method has
82
+ * @param {string} property - The configuration property to test. Can include '.' sub-properties.
83
+ * @return {boolean} - True if the property is defined, false if not defined.
84
+ */
85
+ has(property: string): boolean;
86
+ [LOAD_SYMBOL]: any;
87
+ }
88
+ /**
89
+ * The exported configuration instance type.
90
+ * This is here because the Config class is not a named export and this is how we get
91
+ * the exported configuration instance type.
92
+ * @typedef {ConfigClass} Config
93
+ */
94
+ /**
95
+ * Source of config.util utility functions.
96
+ *
97
+ * In general, lib/util.js is what you are looking for.
98
+ *
99
+ * @class ConfigUtils
100
+ */
101
+ declare class ConfigUtils {
102
+ /**
103
+ * @param {Config} config
104
+ */
105
+ constructor(config: Config);
106
+ /**
107
+ * <p>
108
+ * Set default configurations for a node.js module.
109
+ * </p>
110
+ *
111
+ * <p>
112
+ * This allows module developers to attach their configurations onto the
113
+ * default configuration object so they can be configured by the consumers
114
+ * of the module.
115
+ * </p>
116
+ *
117
+ * <p>Using the function within your module:</p>
118
+ * <pre>
119
+ * const CONFIG = require("config");
120
+ * CONFIG.util.setModuleDefaults("MyModule", {
121
+ * &nbsp;&nbsp;templateName: "t-50",
122
+ * &nbsp;&nbsp;colorScheme: "green"
123
+ * });
124
+ * <br>
125
+ * // Template name may be overridden by application config files
126
+ * console.log("Template: " + CONFIG.MyModule.templateName);
127
+ * </pre>
128
+ *
129
+ * <p>
130
+ * The above example results in a "MyModule" element of the configuration
131
+ * object, containing an object with the specified default values.
132
+ * </p>
133
+ *
134
+ * @method setModuleDefaults
135
+ * @param {string} moduleName - Name of your module.
136
+ * @param {any} defaultProperties - The default module configuration.
137
+ * @return {any} moduleConfig - The module level configuration object.
138
+ * @see Load.scan() for loading more robust defaults
139
+ */
140
+ setModuleDefaults(moduleName: string, defaultProperties: any): any;
141
+ /**
142
+ * Set default configurations for a node.js module.
143
+ *
144
+ * This variant is provided to support handling loading of multiple versions
145
+ * of a library. This is meant for module developers to create a config snapshot
146
+ * for an old version of the code, particularly during a staged upgrade.
147
+ * Instead of adding the values to the configuration, it creates a new Config
148
+ * instance that contains the provided defaults.
149
+ *
150
+ * Note: This feature is primarily useful for adding, removing, or renaming
151
+ * properties. It will struggle to deal with changing the semantics of
152
+ * existing fields if you need to override those fields in your top level
153
+ * config/ directory. It is always best when versioning an API to change the
154
+ * names of fields when you change the meaning of the field.
155
+ *
156
+ * <p>Using the function within your module:</p>
157
+ * <pre>
158
+ * const configModule = require("config");
159
+ * const config = configModule.withModuleDefaults("MyModule", {
160
+ * &nbsp;&nbsp;templateName: "t-50",
161
+ * &nbsp;&nbsp;colorScheme: "green"
162
+ * });
163
+ * <br>
164
+ * // Template name may be overridden by application config files
165
+ * console.log("Template: " + config.MyModule.templateName);
166
+ * </pre>
167
+ *
168
+ * <p>
169
+ * The above example results in a "MyModule" element of the configuration
170
+ * object, containing an object with the specified default values.
171
+ * </p>
172
+ *
173
+ * @method withModuleDefaults
174
+ * @param moduleName {string} - Name of your module.
175
+ * @param defaultProperties {Object} - The default module configuration.
176
+ * @returns {Config}
177
+ * @see Load.scan() for loading more robust defaults
178
+ */
179
+ withModuleDefaults(moduleName: string, defaultProperties: any): Config;
180
+ /**
181
+ * <p>Make a javascript object property immutable (assuring it cannot be changed
182
+ * from the current value).</p>
183
+ * <p>
184
+ * If the specified property is an object, all attributes of that object are
185
+ * made immutable, including properties of contained objects, recursively.
186
+ * If a property name isn't supplied, the object and all of its properties
187
+ * are made immutable.
188
+ * </p>
189
+ * <p>
190
+ * This operation cannot be undone.
191
+ * </p>
192
+ *
193
+ * <p>Example:</p>
194
+ * <pre>
195
+ * const config = require('config');
196
+ * const myObject = {hello:'world'};
197
+ * config.util.makeImmutable(myObject);
198
+ * </pre>
199
+ *
200
+ * @method makeImmutable
201
+ * @deprecated see Util.makeImmutable()
202
+ * @param {any} object - The object to specify immutable properties for
203
+ * @param {string | string[]=} property - The name of the property (or array of names) to make immutable.
204
+ * If not provided, the entire object is marked immutable.
205
+ * @param {any=} value - Property value (or array of values) to set
206
+ * the property to before making immutable. Only used when setting a single
207
+ * property. Retained for backward compatibility.
208
+ * @return {any} - The original object is returned - for chaining.
209
+ */
210
+ makeImmutable(object: any, property?: (string | string[]) | undefined, value?: any | undefined): any;
211
+ /**
212
+ * <p>Make a javascript object property immutable (assuring it cannot be changed
213
+ * from the current value).</p>
214
+ * <p>
215
+ * If the specified property is an object, all attributes of that object are
216
+ * made immutable, including properties of contained objects, recursively.
217
+ * If a property name isn't supplied, the object and all of its properties
218
+ * are made immutable.
219
+ * </p>
220
+ * <p>
221
+ * This operation cannot be undone.
222
+ * </p>
223
+ *
224
+ * <p>Example:</p>
225
+ * <pre>
226
+ * const config = require('config');
227
+ * const myObject = {hello:'world'};
228
+ * config.util.makeImmutable(myObject);
229
+ * </pre>
230
+ *
231
+ * @method makeImmutable
232
+ * @protected
233
+ * @deprecated - partial immutability will no longer be supported by this project
234
+ * @param object {Object} - The object to specify immutable properties for
235
+ * @param property {string | [string]} - The name of the property (or array of names) to make immutable.
236
+ * If not provided, the entire object is marked immutable.
237
+ * @param [value] {* | [*]} - Property value (or array of values) to set
238
+ * the property to before making immutable. Only used when setting a single
239
+ * property. Retained for backward compatibility.
240
+ * @return object {Object} - The original object is returned - for chaining.
241
+ */
242
+ protected makeImmutablePartial(object: any, property: string | [string], value?: any | [any]): any;
243
+ /**
244
+ * Return the sources for the configurations
245
+ *
246
+ * <p>
247
+ * All sources for configurations are stored in an array of objects containing
248
+ * the source name (usually the filename), the original source (as a string),
249
+ * and the parsed source as an object.
250
+ * </p>
251
+ *
252
+ * @method getConfigSources
253
+ * @return {import('./util.js').ConfigSource[]} configSources - An array of objects containing
254
+ * name, original, and parsed elements
255
+ */
256
+ getConfigSources(): import("./util.js").ConfigSource[];
257
+ /**
258
+ * Load the individual file configurations.
259
+ *
260
+ * <p>
261
+ * This method builds a map of filename to the configuration object defined
262
+ * by the file. The search order is:
263
+ * </p>
264
+ *
265
+ * <pre>
266
+ * default.EXT
267
+ * (deployment).EXT
268
+ * (hostname).EXT
269
+ * (hostname)-(deployment).EXT
270
+ * local.EXT
271
+ * local-(deployment).EXT
272
+ * </pre>
273
+ *
274
+ * <p>
275
+ * EXT can be yml, yaml, coffee, iced, json, jsonc, cson or js signifying the file type.
276
+ * yaml (and yml) is in YAML format, coffee is a coffee-script, iced is iced-coffee-script,
277
+ * json is in JSON format, jsonc is in JSONC format, cson is in CSON format, properties is
278
+ * in .properties format (http://en.wikipedia.org/wiki/.properties), and js is a javascript
279
+ * executable file that is require()'d with module.exports being the config object.
280
+ * </p>
281
+ *
282
+ * <p>
283
+ * hostname is the $HOST environment variable (or --HOST command line parameter)
284
+ * if set, otherwise the $HOSTNAME environment variable (or --HOSTNAME command
285
+ * line parameter) if set, otherwise the hostname found from
286
+ * require('os').hostname().
287
+ * </p>
288
+ *
289
+ * <p>
290
+ * Once a hostname is found, everything from the first period ('.') onwards
291
+ * is removed. For example, abc.example.com becomes abc
292
+ * </p>
293
+ *
294
+ * <p>
295
+ * (deployment) is the deployment type, found in the $NODE_ENV environment
296
+ * variable (which can be overridden by using $NODE_CONFIG_ENV
297
+ * environment variable). Defaults to 'development'.
298
+ * </p>
299
+ *
300
+ * <p>
301
+ * If the $NODE_APP_INSTANCE environment variable (or --NODE_APP_INSTANCE
302
+ * command line parameter) is set, then files with this appendage will be loaded.
303
+ * See the Multiple Application Instances section of the main documentation page
304
+ * for more information.
305
+ * </p>
306
+ *
307
+ * @see Util.loadFileConfigs for discrete execution of most of this functionality
308
+ * @method loadFileConfigs
309
+ * @param {string=} configDir the path to the directory containing the configurations to load
310
+ * @param {LoadOptions=} options parsing options
311
+ * @return {Record<string, any>} The configuration object
312
+ */
313
+ loadFileConfigs(configDir?: string | undefined, options?: LoadOptions | undefined): Record<string, any>;
314
+ /**
315
+ * Attach the Config class prototype to all config objects recursively.
316
+ *
317
+ * <p>
318
+ * This allows you to do anything with CONFIG sub-objects as you can do with
319
+ * the top-level CONFIG object. It's so you can do this:
320
+ * </p>
321
+ *
322
+ * <pre>
323
+ * const CUST_CONFIG = require('config').Customer;
324
+ * CUST_CONFIG.get(...)
325
+ * </pre>
326
+ *
327
+ * @method attachProtoDeep
328
+ * @param {object} toObject
329
+ * @param {number} [depth=20]
330
+ * @return {object}
331
+ */
332
+ attachProtoDeep(toObject: object, depth?: number): object;
333
+ /**
334
+ * <p>Get a Config Environment Variable Value</p>
335
+ *
336
+ * <p>
337
+ * This method returns the value of the specified config environment variable,
338
+ * including any defaults or overrides.
339
+ * </p>
340
+ *
341
+ * @method getEnv
342
+ * @param varName {String} The environment variable name
343
+ * @return {String} The value of the environment variable
344
+ */
345
+ getEnv(varName: string): string;
346
+ /**
347
+ * Returns a new deep copy of the current config object, or any part of the config if provided.
348
+ *
349
+ * @param {object} [config] The part of the config to copy and serialize. Omit this argument to return the entire config.
350
+ * @returns {object} The cloned config or part of the config
351
+ */
352
+ toObject(config?: object): object;
353
+ /**
354
+ * Run strictness checks on NODE_ENV and NODE_APP_INSTANCE and throw an error if there's a problem.
355
+ * @param {Config} [config]
356
+ */
357
+ runStrictnessChecks(config?: Config): void;
358
+ /**
359
+ * @deprecated please use Parser.stripYamlComments
360
+ * @param {string} fileStr The string to strip comments from
361
+ */
362
+ stripYamlComments(fileStr: string): any;
363
+ #private;
364
+ }
365
+ declare const LOAD_SYMBOL: unique symbol;