mirror of
https://github.com/bcomnes/deploy-to-neocities.git
synced 2026-01-21 08:51:54 +00:00
0.0.1
This commit is contained in:
34
node_modules/async-neocities/lib/timer.js
generated
vendored
Normal file
34
node_modules/async-neocities/lib/timer.js
generated
vendored
Normal file
@@ -0,0 +1,34 @@
|
||||
/**
|
||||
* Simple timer lets you record start and stop times, with an elapsed time getter.
|
||||
*/
|
||||
class SimpleTimer {
|
||||
constructor (startTime) {
|
||||
this.start = startTime || Date.now()
|
||||
this.end = null
|
||||
this.stopped = false
|
||||
}
|
||||
|
||||
get elapsed () {
|
||||
if (this.stopped) {
|
||||
return this.end - this.start
|
||||
} else {
|
||||
return Date.now() - this.start
|
||||
}
|
||||
}
|
||||
|
||||
stop () {
|
||||
if (this.stopped) return
|
||||
this.stopped = true
|
||||
this.end = Date.now()
|
||||
}
|
||||
|
||||
toString () {
|
||||
return this.elapsed
|
||||
}
|
||||
|
||||
toJSON () {
|
||||
return this.elapsed
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = SimpleTimer
|
||||
Reference in New Issue
Block a user