3 const parameters
= new Map();
5 * De-duplicating factory of minimal-objects to track the named-parameter parts of path definitions.
7 * @property {String} parameter
9 class PathParameter
extends null {
10 static #parameters
= parameters
;
12 constructor(parameter
) {
13 if (!parameter
|| typeof(parameter
) !== 'string') {
14 throw new RangeError('parameter must be string');
17 if (PathParameter
.#parameters
.has(parameter
)) {
18 return PathParameter
.#parameters
.get(parameter
); // NOSONAR
21 const pathParameter
= Object
.create(PathParameter
.prototype);
22 pathParameter
.parameter
= parameter
;
23 Object
.freeze(pathParameter
);
24 PathParameter
.#parameters
.set(parameter
, pathParameter
);
25 return pathParameter
; // NOSONAR
32 return this.parameter
;
39 return this.parameter
;
43 * Clear the de-duplication table, for tests.
46 PathParameter
.#parameters
.clear();
50 module
.exports
= PathParameter
;