config 4.2.1 → 4.4.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/LICENSE CHANGED
@@ -1,4 +1,4 @@
1
- // Copyright 2010-2025, Loren West and other contributors
1
+ // Copyright 2010-2026, Loren West and other contributors
2
2
 
3
3
  // Permission is hereby granted, free of charge, to any person obtaining a copy
4
4
  // of this software and associated documentation files (the "Software"), to
package/README.md CHANGED
@@ -1,9 +1,11 @@
1
1
  Configure your Node.js Applications
2
2
  ===================================
3
3
 
4
- [![NPM](https://nodei.co/npm/config.svg?downloads=true&downloadRank=true)](https://nodei.co/npm/config/)  
5
- [![Build Status](https://secure.travis-ci.org/node-config/node-config.svg?branch=master)](https://travis-ci.org/lorenwest/node-config)  
6
- [release notes](https://github.com/node-config/node-config/blob/master/History.md)
4
+ [![npm package](https://img.shields.io/npm/v/config)](https://www.npmjs.com/package/config)
5
+ [![Downloads](https://img.shields.io/npm/dt/config)](https://www.npmjs.com/package/config)
6
+ [![Issues](https://img.shields.io/github/issues/node-config/node-config)](https://github.com/node-config/node-config/issues)
7
+
8
+ [Release Notes](https://github.com/node-config/node-config/releases)
7
9
 
8
10
  Introduction
9
11
  ------------
@@ -105,6 +107,11 @@ Running in this configuration, the `port` and `dbName` elements of `dbConfig`
105
107
  will come from the `default.json` file, and the `host` element will
106
108
  come from the `production.json` override file.
107
109
 
110
+ TypeScript
111
+ ----------
112
+
113
+ Type declarations are published under `types/` and resolved via `typesVersions`. Subpath typings are included for `config/async`, `config/defer`, `config/parser`, `config/raw`, and `config/lib/util` in addition to the main `config` entrypoint.
114
+
108
115
  Articles
109
116
  --------
110
117
 
@@ -135,35 +142,35 @@ If you still don't see what you are looking for, here are some more resources to
135
142
  Contributors
136
143
  ------------
137
144
  <table id="contributors"><tr><td><img src=https://avatars.githubusercontent.com/u/373538?v=4><a href="https://github.com/lorenwest">lorenwest</a></td>
138
- <td><img src=https://avatars.githubusercontent.com/u/25829?v=4><a href="https://github.com/markstos">markstos</a></td>
139
145
  <td><img src=https://avatars.githubusercontent.com/u/1656505?v=4><a href="https://github.com/jdmarshall">jdmarshall</a></td>
146
+ <td><img src=https://avatars.githubusercontent.com/u/25829?v=4><a href="https://github.com/markstos">markstos</a></td>
140
147
  <td><img src=https://avatars.githubusercontent.com/u/1083065?v=4><a href="https://github.com/iMoses">i&shy;Moses</a></td>
141
148
  <td><img src=https://avatars.githubusercontent.com/u/447151?v=4><a href="https://github.com/elliotttf">elliotttf</a></td>
142
- <td><img src=https://avatars.githubusercontent.com/u/8839447?v=4><a href="https://github.com/jfelege">jfelege</a></td>
143
- </tr><tr><td><img src=https://avatars.githubusercontent.com/u/66902?v=4><a href="https://github.com/leachiM2k">leachi&shy;M2k</a></td>
144
- <td><img src=https://avatars.githubusercontent.com/u/133277?v=4><a href="https://github.com/enyo">enyo</a></td>
149
+ <td><img src=https://avatars.githubusercontent.com/u/11448209?v=4><a href="https://github.com/mdkitzman">mdkitzman</a></td>
150
+ </tr><tr><td><img src=https://avatars.githubusercontent.com/u/8839447?v=4><a href="https://github.com/jfelege">jfelege</a></td>
151
+ <td><img src=https://avatars.githubusercontent.com/u/66902?v=4><a href="https://github.com/leachiM2k">leachi&shy;M2k</a></td>
145
152
  <td><img src=https://avatars.githubusercontent.com/u/791137?v=4><a href="https://github.com/josx">josx</a></td>
153
+ <td><img src=https://avatars.githubusercontent.com/u/133277?v=4><a href="https://github.com/enyo">enyo</a></td>
146
154
  <td><img src=https://avatars.githubusercontent.com/u/4307697?v=4><a href="https://github.com/leosuncin">leosuncin</a></td>
147
155
  <td><img src=https://avatars.githubusercontent.com/u/1077378?v=4><a href="https://github.com/arthanzel">arthanzel</a></td>
148
- <td><img src=https://avatars.githubusercontent.com/u/8650543?v=4><a href="https://github.com/leonardovillela">leonardovillela</a></td>
149
- </tr><tr><td><img src=https://avatars.githubusercontent.com/u/77355440?v=4><a href="https://github.com/jeremy-daley-kr">jeremy-daley-kr</a></td>
156
+ </tr><tr><td><img src=https://avatars.githubusercontent.com/u/8650543?v=4><a href="https://github.com/leonardovillela">leonardovillela</a></td>
157
+ <td><img src=https://avatars.githubusercontent.com/u/77355440?v=4><a href="https://github.com/jeremy-daley-kr">jeremy-daley-kr</a></td>
150
158
  <td><img src=https://avatars.githubusercontent.com/u/2529835?v=4><a href="https://github.com/simon-scherzinger">simon-scherzinger</a></td>
151
159
  <td><img src=https://avatars.githubusercontent.com/u/5138570?v=4><a href="https://github.com/BadgerBadgerBadgerBadger">Badger&shy;Badger&shy;Badger&shy;Badger</a></td>
152
160
  <td><img src=https://avatars.githubusercontent.com/u/842998?v=4><a href="https://github.com/nsabovic">nsabovic</a></td>
153
161
  <td><img src=https://avatars.githubusercontent.com/u/1751645?v=4><a href="https://github.com/cunneen">cunneen</a></td>
154
- <td><img src=https://avatars.githubusercontent.com/u/506460?v=4><a href="https://github.com/Osterjour">Osterjour</a></td>
155
- </tr><tr><td><img src=https://avatars.githubusercontent.com/u/138707?v=4><a href="https://github.com/th507">th507</a></td>
156
- <td><img src=https://avatars.githubusercontent.com/u/86159966?v=4><a href="https://github.com/DeutscherDude">Deutscher&shy;Dude</a></td>
162
+ </tr><tr><td><img src=https://avatars.githubusercontent.com/u/506460?v=4><a href="https://github.com/Osterjour">Osterjour</a></td>
163
+ <td><img src=https://avatars.githubusercontent.com/u/138707?v=4><a href="https://github.com/th507">th507</a></td>
164
+ <td><img src=https://avatars.githubusercontent.com/u/242058858?v=4><a href="https://github.com/tiny-rac00n">tiny-rac00n</a></td>
157
165
  <td><img src=https://avatars.githubusercontent.com/u/1656140?v=4><a href="https://github.com/eheikes">eheikes</a></td>
158
166
  <td><img src=https://avatars.githubusercontent.com/u/1872824?v=4><a href="https://github.com/fgheorghe">fgheorghe</a></td>
159
167
  <td><img src=https://avatars.githubusercontent.com/u/498929?v=4><a href="https://github.com/roncli">roncli</a></td>
160
- <td><img src=https://avatars.githubusercontent.com/u/1355559?v=4><a href="https://github.com/superoven">superoven</a></td>
161
- </tr><tr><td><img src=https://avatars.githubusercontent.com/u/631249?v=4><a href="https://github.com/airdrummingfool">airdrummingfool</a></td>
168
+ </tr><tr><td><img src=https://avatars.githubusercontent.com/u/1355559?v=4><a href="https://github.com/superoven">superoven</a></td>
169
+ <td><img src=https://avatars.githubusercontent.com/u/631249?v=4><a href="https://github.com/airdrummingfool">airdrummingfool</a></td>
162
170
  <td><img src=https://avatars.githubusercontent.com/u/54934?v=4><a href="https://github.com/wmertens">wmertens</a></td>
163
171
  <td><img src=https://avatars.githubusercontent.com/u/2842176?v=4><a href="https://github.com/XadillaX">Xadilla&shy;X</a></td>
164
172
  <td><img src=https://avatars.githubusercontent.com/u/107884?v=4><a href="https://github.com/inside">inside</a></td>
165
173
  <td><img src=https://avatars.githubusercontent.com/u/1320090?v=4><a href="https://github.com/dsbert">dsbert</a></td>
166
- <td><img src=https://avatars.githubusercontent.com/u/527814?v=4><a href="https://github.com/jacobemerick">jacobemerick</a></td>
167
174
  </tr></table>
168
175
 
169
176
  License
@@ -171,6 +178,5 @@ License
171
178
 
172
179
  May be freely distributed under the [MIT license](https://raw.githubusercontent.com/node-config/node-config/master/LICENSE).
173
180
 
174
- Copyright (c) 2010-2025 Loren West
181
+ Copyright (c) 2010-2026 Loren West
175
182
  [and other contributors](https://github.com/node-config/node-config/graphs/contributors)
176
-
package/async.js CHANGED
@@ -1,12 +1,33 @@
1
- var asyncSymbol = Symbol('asyncSymbol');
2
- var deferConfig = require('./defer').deferConfig;
1
+ const asyncSymbol = Symbol('asyncSymbol');
2
+ const { deferConfig } = require('./defer');
3
3
 
4
+ /** @typedef {import('./lib/config').Config} Config */
5
+ /** @typedef {import('./defer').DeferredConfig} DeferredConfig */
6
+
7
+ /**
8
+ * @template T
9
+ * @overload
10
+ * @param {Promise<T>} promiseOrFunc
11
+ * @returns {Promise<T>}
12
+ */
4
13
  /**
5
- * @param promiseOrFunc the promise will determine a property's value once resolved
14
+ * @template T
15
+ * @overload
16
+ * @param {(config: Config, original: any) => Promise<T>} promiseOrFunc
17
+ * @returns {DeferredConfig}
18
+ */
19
+ /**
20
+ * @template T
21
+ * @param {Promise<T> | ((config: Config, original: any) => Promise<T>)} promiseOrFunc
22
+ * the promise will determine a property's value once resolved
6
23
  * can also be a function to defer which resolves to a promise
7
- * @returns {Promise} a marked promise to be resolve later using `resolveAsyncConfigs`
24
+ * @returns {Promise<T> | DeferredConfig} a marked promise to be resolve later using `resolveAsyncConfigs`
25
+ * @deprecated please use async functions with defer
8
26
  */
9
27
  function asyncConfig(promiseOrFunc) {
28
+ const { Util } = require('./lib/util.js');
29
+ Util.errorOnce("ASYNC_CONFIG", 'config/async.js is deprecated. Please use async functions with the new defer functionality');
30
+
10
31
  if (typeof promiseOrFunc === 'function') { // also acts as deferConfig
11
32
  return deferConfig(function (config, original) {
12
33
  var release;
@@ -33,9 +54,10 @@ function asyncConfig(promiseOrFunc) {
33
54
  }
34
55
 
35
56
  /**
36
- * Do not use `config.get` before executing this method, it will freeze the config object
37
- * @param config the main config object, returned from require('config')
38
- * @returns {Promise<config>} once all promises are resolved, return the original config object
57
+ * Do not use `config.get` before executing this method, it will freeze the config object.
58
+ * @param {Config} config the main config object, returned from require('config')
59
+ * @returns {Promise<Config>} once all promises are resolved, return the original config object
60
+ * @deprecated please use async functions with defer and Util.resolveAsyncConfigs
39
61
  */
40
62
  function resolveAsyncConfigs(config) {
41
63
  var promises = [];
package/defer.js CHANGED
@@ -1,23 +1,19 @@
1
- // Create a deferredConfig prototype so that we can check for it when reviewing the configs later.
2
- function DeferredConfig() {}
3
- DeferredConfig.prototype.prepare = function() {};
4
- DeferredConfig.prototype.resolve = function() {};
1
+ const { deferConfig, DeferredConfig } = require('./lib/defer.js');
5
2
 
6
- // Accept a function that we'll use to resolve this value later and return a 'deferred' configuration value to resolve it later.
7
- function deferConfig(func) {
8
- var obj = Object.create(DeferredConfig.prototype);
9
- obj.prepare = function(config, prop, property) {
10
- var original = prop[property]._original;
11
- obj.resolve = function() {
12
- var value = func.call(config, config, original);
13
- Object.defineProperty(prop, property, {value: value});
14
- return value;
15
- };
16
- Object.defineProperty(prop, property, {get: function() { return obj.resolve(); }});
17
- return obj;
18
- };
19
- return obj;
3
+ /**
4
+ * @deprecated please use the new callback mechanism
5
+ * @see lib/defer.js
6
+ * @type {typeof import('./lib/defer').deferConfig}
7
+ */
8
+ module.exports.deferConfig = (...args) => {
9
+ const { Util } = require('./lib/util.js');
10
+
11
+ Util.errorOnce("DEFER_CONFIG", 'node-config now supports config file callbacks in place of deferConfig(), which is deprecated.');
12
+ return deferConfig(...args);
20
13
  }
21
14
 
22
- module.exports.deferConfig = deferConfig;
15
+ /**
16
+ * @deprecated please use the new callback mechanism
17
+ * @type {typeof import('./lib/defer').DeferredConfig}
18
+ */
23
19
  module.exports.DeferredConfig = DeferredConfig;