Skip to content
Snippets Groups Projects
Verified Commit a1eab275 authored by Volker Schukai's avatar Volker Schukai :alien:
Browse files

feat: hide implementation in symbol

parent 7dd11be4
No related branches found
No related tags found
No related merge requests found
......@@ -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;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment