refactor: make LimitedCollection an implementation detail (#3872)

This commit is contained in:
SpaceEEC
2020-03-01 15:10:55 +01:00
committed by GitHub
parent c7f4485cec
commit 544bb78c8b
4 changed files with 7 additions and 8 deletions

View File

@@ -8,6 +8,7 @@ const Collection = require('./Collection.js');
* @extends {Collection}
* @param {number} [maxSize=0] The maximum size of the Collection
* @param {Iterable} [iterable=null] Optional entries passed to the Map constructor.
* @private
*/
class LimitedCollection extends Collection {
constructor(maxSize = 0, iterable = null) {
@@ -24,6 +25,10 @@ class LimitedCollection extends Collection {
if (this.size >= this.maxSize && !this.has(key)) this.delete(this.firstKey());
return super.set(key, value);
}
static get [Symbol.species]() {
return Collection;
}
}
module.exports = LimitedCollection;