mirror of
https://github.com/atom/atom.git
synced 2026-04-28 03:01:47 -04:00
Decaffeinate src/item-registry.coffee
This commit is contained in:
@@ -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
21
src/item-registry.js
Normal 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)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user