Decaffeinate src/item-registry.coffee

This commit is contained in:
David Wilson
2018-01-22 16:14:25 -08:00
parent 4a151ac210
commit da22ea8f80
2 changed files with 21 additions and 15 deletions

View File

@@ -1,15 +0,0 @@
module.exports =
class ItemRegistry
constructor: ->
@items = new WeakSet
addItem: (item) ->
if @hasItem(item)
throw new Error("The workspace can only contain one instance of item #{item}")
@items.add(item)
removeItem: (item) ->
@items.delete(item)
hasItem: (item) ->
@items.has(item)

21
src/item-registry.js Normal file
View File

@@ -0,0 +1,21 @@
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)
}
}