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/README.md +22 -16
- package/async.js +22 -5
- package/defer.js +2 -0
- package/lib/config.js +606 -530
- package/lib/defer.js +31 -3
- package/lib/util.js +266 -83
- package/package.json +51 -6
- package/parser.js +90 -5
- package/raw.js +9 -8
- package/tsconfig.json +15 -0
- package/types/async.d.ts +23 -0
- package/types/defer.d.ts +3 -0
- package/types/lib/config.d.ts +368 -0
- package/types/lib/defer.d.ts +33 -0
- package/types/lib/util.d.ts +649 -0
- package/types/parser.d.ts +132 -0
- package/types/raw.d.ts +9 -0
package/lib/defer.js
CHANGED
|
@@ -1,12 +1,40 @@
|
|
|
1
1
|
const { isAsyncFunction } = require('node:util/types');
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
/** @typedef {import('./config').Config} Config */
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Deferred config placeholder.
|
|
7
|
+
* @constructor
|
|
8
|
+
*/
|
|
4
9
|
function DeferredConfig() {}
|
|
5
|
-
|
|
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
|
-
|
|
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;
|