config 4.3.0 → 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/lib/defer.js CHANGED
@@ -1,12 +1,40 @@
1
1
  const { isAsyncFunction } = require('node:util/types');
2
2
 
3
- // Create a deferredConfig prototype so that we can check for it when reviewing the configs later.
3
+ /** @typedef {import('./config').Config} Config */
4
+
5
+ /**
6
+ * Deferred config placeholder.
7
+ * @constructor
8
+ */
4
9
  function DeferredConfig() {}
5
- DeferredConfig.prototype.prepare = function() {};
10
+
11
+ /**
12
+ * Prepare this deferred value for lazy resolution.
13
+ *
14
+ * @param {Config} config
15
+ * @param {any} prop
16
+ * @param {string | number} property
17
+ * @returns {DeferredConfig}
18
+ */
19
+ DeferredConfig.prototype.prepare = function(config, prop, property) {};
20
+
21
+ /**
22
+ * Resolve the deferred value.
23
+ *
24
+ * @returns {any}
25
+ */
6
26
  DeferredConfig.prototype.resolve = function() {};
7
27
 
8
- // Accept a function that we'll use to resolve this value later and return a 'deferred' configuration value to resolve it later.
28
+ /**
29
+ * Accept a function that we will execute later and return a deferred placeholder.
30
+ *
31
+ * @template TOriginal
32
+ * @template TResult
33
+ * @param {(this: Config, config: Config, original: TOriginal) => TResult | Promise<TResult>} func
34
+ * @returns {DeferredConfig}
35
+ */
9
36
  function deferConfig(func) {
37
+ /** @type {DeferredConfig} */
10
38
  const obj = Object.create(DeferredConfig.prototype);
11
39
  obj.prepare = function(config, prop, property) {
12
40
  const original = prop[property]._original;