mirror of
https://github.com/pulsar-edit/pulsar.git
synced 2024-11-10 10:17:11 +03:00
22 lines
389 B
JavaScript
22 lines
389 B
JavaScript
module.exports =
|
|
class ItemRegistry {
|
|
constructor () {
|
|
this.items = new WeakSet()
|
|
}
|
|
|
|
addItem (item) {
|
|
if (this.hasItem(item)) {
|
|
throw new Error(`The workspace can only contain one instance of item ${item}`)
|
|
}
|
|
return this.items.add(item)
|
|
}
|
|
|
|
removeItem (item) {
|
|
return this.items.delete(item)
|
|
}
|
|
|
|
hasItem (item) {
|
|
return this.items.has(item)
|
|
}
|
|
}
|