projects
/
squeep-api-dingus
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
lint cleanup
[squeep-api-dingus]
/
lib
/
router
/
path-parameter.js
diff --git
a/lib/router/path-parameter.js
b/lib/router/path-parameter.js
index 585aaec7500a3ccf3fd6c9529fdb288f817f14e8..81405948a2ea951b5b404aa4bc1bbe78153df117 100644
(file)
--- a/
lib/router/path-parameter.js
+++ b/
lib/router/path-parameter.js
@@
-1,6
+1,5
@@
'use strict';
'use strict';
-const kPathParameter = Symbol('kSqueepDingusRouterPathParameter');
const parameters = new Map();
/**
* De-duplicating factory of minimal-objects to track the named-parameter parts of path definitions.
const parameters = new Map();
/**
* De-duplicating factory of minimal-objects to track the named-parameter parts of path definitions.
@@
-8,42
+7,44
@@
const parameters = new Map();
* @property {String} parameter
*/
class PathParameter extends null {
* @property {String} parameter
*/
class PathParameter extends null {
+ static #parameters = parameters;
+
constructor(parameter) {
if (!parameter || typeof(parameter) !== 'string') {
throw new RangeError('parameter must be string');
}
constructor(parameter) {
if (!parameter || typeof(parameter) !== 'string') {
throw new RangeError('parameter must be string');
}
- if (parameters.has(parameter)) {
- return parameters.get(parameter);
+
+ if (PathParameter.#parameters.has(parameter)) {
+ return PathParameter.#parameters.get(parameter); // NOSONAR
}
}
+
const pathParameter = Object.create(PathParameter.prototype);
const pathParameter = Object.create(PathParameter.prototype);
- pathParameter[kPathParameter] = parameter; // eslint-disable-line security/detect-object-injection
- parameters.set(parameter, pathParameter);
+ pathParameter.parameter = parameter;
Object.freeze(pathParameter);
Object.freeze(pathParameter);
- return pathParameter;
+ PathParameter.#parameters.set(parameter, pathParameter);
+ return pathParameter; // NOSONAR
}
/**
}
/**
- *
Return the parameter name.
+ *
@returns {String}
*/
*/
-
get parameter
() {
- return this
[kPathParameter];// eslint-disable-line security/detect-object-injection
+
toString
() {
+ return this
.parameter;
}
/**
* @returns {String}
*/
}
/**
* @returns {String}
*/
- to
String
() {
- return
`{${this.constructor.name} ${this.parameter}}`; // eslint-disable-line security/detect-object-injection
+ to
JSON
() {
+ return
this.parameter;
}
/**
* Clear the de-duplication table, for tests.
*/
static _flush() {
}
/**
* Clear the de-duplication table, for tests.
*/
static _flush() {
-
this.
parameters.clear();
+
PathParameter.#
parameters.clear();
}
}
}
}
-PathParameter.kPathParameter = kPathParameter;
-PathParameter.parameters = parameters;
-module.exports = PathParameter;
\ No newline at end of file
+module.exports = PathParameter;