NPM Dependencies UPDATE

This commit is contained in:
Luis Fernando Molina committed 2018-05-02 10:22:14 +02:00
1 parent d3bc5e34f6
commit 5bfb4ff32a
732 files changed
+13367 -62155

No files matched your search

+38 -33
View File
@@ -1,38 +1,43 @@
assert = require "assert"
chai = require "chai"
chai.use(require "chai-increasing")
{assert,expect} = chai
Bluebird = require "bluebird"
now = require "../"
getUptime = -> process.uptime() * 1e3
delay = (ms, fn) -> setTimeout fn, ms
now = undefined
describe "now", ->
it "initially gives a near zero (< 20 ms) time ", ->
now = require "../"
assert now() < 20
it "gives a positive time", ->
assert now() > 0
it "reported time differs at most 1ms from a freshly reported uptime", ->
assert.isAtMost Math.abs(now()-getUptime()), 1
it "two subsequent calls return an increasing number", ->
a = now()
b = now()
assert now() < now()
it "has less than 10 microseconds overhead", ->
Math.abs(now() - now()) < 0.010
it "can do 1,000,000 calls really quickly", ->
now() for i in [0...1000000]
it "shows that at least 990 ms has passed after a timeout of 1 second", (done) ->
a = now()
delay 1000, ->
b = now()
diff = b - a
return done new Error "Diff (#{diff}) lower than 990." if diff < 990
return done null
assert.isBelow now(), now()
it "shows that not more than 1020 ms has passed after a timeout of 1 second", (done) ->
a = now()
delay 1000, ->
b = now()
diff = b - a
return done new Error "Diff (#{diff}) higher than 1020." if diff > 1020
return done null
it "has less than 10 microseconds overhead", ->
assert.isBelow Math.abs(now() - now()), 0.010
it "can be called 1 million times in under 1 second (averaging under 1 microsecond per call)", ->
@timeout 1000
now() for [0...1e6]
undefined
it "for 10,000 numbers, number n is never bigger than number n-1", ->
stamps = (now() for [1...10000])
expect(stamps).to.be.increasing
it "shows that at least 0.2 ms has passed after a timeout of 1 ms", ->
earlier = now()
Bluebird.resolve().delay(1).then -> assert.isAbove (now()-earlier), 0.2
it "shows that at most 3 ms has passed after a timeout of 1 ms", ->
earlier = now()
Bluebird.resolve().delay(1).then -> assert.isBelow (now()-earlier), 3
it "shows that at least 190ms ms has passed after a timeout of 200ms", ->
earlier = now()
Bluebird.resolve().delay(200).then -> assert.isAbove (now()-earlier), 190
it "shows that at most 220 ms has passed after a timeout of 200ms", ->
earlier = now()
Bluebird.resolve().delay(200).then -> assert.isBelow (now()-earlier), 220