1.0.0 • Published 9 months ago
async_fn v1.0.0
AsyncFn
Description
This is one-method library, which main purpose is ability to run provided to this method asynchronous functions in a queue one by one. Please notice, that all provided functions should return a promise and they should be asynchronous. Support for simple functions is not yet implemented, but planned.
Example
Here's just a spec example.
it 'calls callbacks in a queue one by one', (done) ->
asyncFn1 = sinon.spy(=>
dfd = new $.Deferred()
setTimeout ->
dfd.resolve()
, 700
dfd.promise()
)
asyncFn2 = sinon.spy(=>
dfd = new $.Deferred()
setTimeout ->
dfd.resolve()
, 300
dfd.promise()
)
asyncFn3 = sinon.spy(=>
dfd = new $.Deferred()
setTimeout ->
dfd.resolve()
, 100
dfd.promise()
)
AsyncFn.addToCallQueue asyncFn1
AsyncFn.addToCallQueue asyncFn2
AsyncFn.addToCallQueue asyncFn3
expect(asyncFn2).to.be.not.called
expect(asyncFn3).to.be.not.called
setTimeout ->
expect(asyncFn1).to.be.calledOnce
expect(asyncFn2).to.be.calledOnce
expect(asyncFn3).to.be.calledOnce
expect(asyncFn1).to.be.calledBefore asyncFn2
expect(asyncFn2).to.be.calledBefore asyncFn3
done()
, 1500
1.0.0
9 months ago
1.0.0-rc7
9 months ago
1.0.0-rc8
9 months ago
1.0.0-rc5
10 months ago
1.0.0-rc6
10 months ago
1.0.0-rc1
10 months ago
1.0.0-rc2
10 months ago
1.0.0-rc3
10 months ago
1.0.0-rc
10 months ago
0.2.4
7 years ago
0.2.3
8 years ago
0.1.7
8 years ago
0.2.2
9 years ago
0.2.1
9 years ago
0.2.0
9 years ago
0.1.6
9 years ago