mirror of
https://github.com/softprops/action-gh-release.git
synced 2025-05-14 20:24:20 +00:00
node_modules
This commit is contained in:
parent
0e414c630a
commit
78c309ef59
555 changed files with 103819 additions and 1 deletions
39
node_modules/bottleneck/src/Batcher.coffee
generated
vendored
Normal file
39
node_modules/bottleneck/src/Batcher.coffee
generated
vendored
Normal file
|
@ -0,0 +1,39 @@
|
|||
parser = require "./parser"
|
||||
Events = require "./Events"
|
||||
|
||||
class Batcher
|
||||
defaults:
|
||||
maxTime: null
|
||||
maxSize: null
|
||||
Promise: Promise
|
||||
|
||||
constructor: (@options={}) ->
|
||||
parser.load @options, @defaults, @
|
||||
@Events = new Events @
|
||||
@_arr = []
|
||||
@_resetPromise()
|
||||
@_lastFlush = Date.now()
|
||||
|
||||
_resetPromise: ->
|
||||
@_promise = new @Promise (res, rej) => @_resolve = res
|
||||
|
||||
_flush: ->
|
||||
clearTimeout @_timeout
|
||||
@_lastFlush = Date.now()
|
||||
@_resolve()
|
||||
@Events.trigger "batch", @_arr
|
||||
@_arr = []
|
||||
@_resetPromise()
|
||||
|
||||
add: (data) ->
|
||||
@_arr.push data
|
||||
ret = @_promise
|
||||
if @_arr.length == @maxSize
|
||||
@_flush()
|
||||
else if @maxTime? and @_arr.length == 1
|
||||
@_timeout = setTimeout =>
|
||||
@_flush()
|
||||
, @maxTime
|
||||
ret
|
||||
|
||||
module.exports = Batcher
|
Loading…
Add table
Add a link
Reference in a new issue