mirror of
https://github.com/softprops/action-gh-release
synced 2026-01-29 06:49:07 +08:00
node_modules
This commit is contained in:
28
node_modules/bottleneck/src/Queues.coffee
generated
vendored
Normal file
28
node_modules/bottleneck/src/Queues.coffee
generated
vendored
Normal file
@@ -0,0 +1,28 @@
|
||||
DLList = require "./DLList"
|
||||
Events = require "./Events"
|
||||
|
||||
class Queues
|
||||
|
||||
constructor: (num_priorities) ->
|
||||
@Events = new Events @
|
||||
@_length = 0
|
||||
@_lists = for i in [1..num_priorities] then new DLList (=> @incr()), (=> @decr())
|
||||
|
||||
incr: -> if @_length++ == 0 then @Events.trigger "leftzero"
|
||||
|
||||
decr: -> if --@_length == 0 then @Events.trigger "zero"
|
||||
|
||||
push: (job) -> @_lists[job.options.priority].push job
|
||||
|
||||
queued: (priority) -> if priority? then @_lists[priority].length else @_length
|
||||
|
||||
shiftAll: (fn) -> @_lists.forEach (list) -> list.forEachShift fn
|
||||
|
||||
getFirst: (arr=@_lists) ->
|
||||
for list in arr
|
||||
return list if list.length > 0
|
||||
[]
|
||||
|
||||
shiftLastFrom: (priority) -> @getFirst(@_lists[priority..].reverse()).shift()
|
||||
|
||||
module.exports = Queues
|
||||
Reference in New Issue
Block a user