Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Fetching contributors…

Cannot retrieve contributors at this time

28 lines (21 sloc) 0.632 kb
# This is used to maintain lists of userIds to socketIds and channelIds to socketIds
class exports.UniqueSet
constructor: ->
@data = {}
add: (key, value) ->
return false unless key? and value?
if set = @data[key]
set.push(value) unless set.indexOf(value) >= 0
else
@data[key] = [value]
remove: (key, value) ->
if (i = @data[key].indexOf(value)) >= 0
@data[key].splice(i, 1)
delete @data[key] if @data[key].length == 0
removeFromAll: (value) ->
@keys().forEach (key) =>
@remove(key, value)
keys: ->
Object.keys(@data)
members: (key) ->
@data[key] || []
Jump to Line
Something went wrong with that request. Please try again.