bottleneck
Version:
Distributed task scheduler and rate limiter
33 lines (31 loc) • 749 B
text/coffeescript
class DLList
constructor: () ->
= null
= null
= 0
push: (value) ->
++
?.incr()
node = {value, next:null}
if ?
.next = node
= node
else = = node
undefined
shift: () ->
if not ? then return undefined
else
--
?.decr()
value = .value
= .next ? ( = null)
value
first: () -> if ? then .value
getArray: () ->
node =
while node? then (ref = node; node = node.next; ref.value)
forEachShift: (cb) ->
node =
while node? then (cb node; node = )
undefined
module.exports = DLList