From a1eab2758ff0d58b309ddacdfad43e81b3e39088 Mon Sep 17 00:00:00 2001 From: Volker Schukai <volker.schukai@schukai.com> Date: Sat, 7 Jan 2023 18:58:30 +0100 Subject: [PATCH] feat: hide implementation in symbol --- application/source/types/uniquequeue.mjs | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/application/source/types/uniquequeue.mjs b/application/source/types/uniquequeue.mjs index 23ce29631..4d43b3913 100644 --- a/application/source/types/uniquequeue.mjs +++ b/application/source/types/uniquequeue.mjs @@ -6,12 +6,13 @@ */ import {Queue} from "./queue.mjs"; +import {internalSymbol} from "../constants.mjs"; import {validateObject} from "./validate.mjs"; export {UniqueQueue} /** - * A UniqueQueue is a queue that contains items only once. + * An UniqueQueue is a queue that contains items only once. * * @license AGPLv3 * @since 1.4.0 @@ -26,7 +27,9 @@ export {UniqueQueue} */ constructor() { super(); - this.unique = new WeakSet(); + this[internalSymbol]={ + unique : new WeakSet() + }; } /** @@ -40,8 +43,8 @@ export {UniqueQueue} validateObject(value); - if (!this.unique.has(value)) { - this.unique.add(value); + if (!this[internalSymbol].unique.has(value)) { + this[internalSymbol].unique.add(value); super.add(value); } @@ -55,7 +58,7 @@ export {UniqueQueue} */ clear() { super.clear(); - this.unique = new WeakSet; + this[internalSymbol].unique = new WeakSet; return this; } @@ -71,7 +74,7 @@ export {UniqueQueue} return undefined; } let value = this.data.shift(); - this.unique.delete(value); + this[internalSymbol].unique.delete(value); return value; } -- GitLab