@valjoux/eta
Advanced tools
Comparing version 0.1.8 to 0.1.9
@@ -5,28 +5,45 @@ 'use strict'; | ||
var formatTime = require('@valjoux/format-time'); | ||
var presets = require('@palett/presets'); | ||
var timestamp = require('@valjoux/timestamp'); | ||
var timestampPretty = require('@valjoux/timestamp-pretty'); | ||
class Eta { | ||
constructor() { | ||
constructor({ | ||
formatter | ||
} = {}) { | ||
this.c = new Date(); | ||
this.p = 0; | ||
this.ft = formatter !== null && formatter !== void 0 ? formatter : timestamp.time; | ||
} | ||
tick() { | ||
return this.p = this.c, this.c = new Date(), this.c - this.p; | ||
return this.p = this.c, this.c = new Date(); | ||
} | ||
ini(msg = '') { | ||
return `[${formatTime.formatTime(this.c)}] [Ini 0ms] ${msg}`; | ||
return this.tick(), `${this.ft(this.c)} [ini 0ms] ${msg}`; | ||
} | ||
lap(msg = '') { | ||
return `[${formatTime.formatTime(this.c)}] [Lap ${this.tick()}ms] ${msg}`; | ||
return this.tick(), `${this.ft(this.c)} [lap ${this.c - this.p}ms] ${msg}`; | ||
} | ||
end(msg = '') { | ||
return `[${formatTime.formatTime(this.c)}] [End ${this.tick()}ms] ${msg}`; | ||
return this.tick(), `${this.ft(this.c)} [end ${this.c - this.p}ms] ${msg}`; | ||
} | ||
static build() { | ||
return new Eta(); | ||
} | ||
static buildPretty(timePreset = presets.SUBTLE, milliPreset = presets.SUBTLE) { | ||
const timestamp = timestampPretty.Timestamp.build(undefined, timePreset, milliPreset); | ||
const formatter = timestamp.time.bind(timestamp); | ||
return new Eta({ | ||
formatter | ||
}); | ||
} | ||
} | ||
exports.Eta = Eta; |
@@ -1,27 +0,44 @@ | ||
import { formatTime } from '@valjoux/format-time'; | ||
import { SUBTLE } from '@palett/presets'; | ||
import { time } from '@valjoux/timestamp'; | ||
import { Timestamp } from '@valjoux/timestamp-pretty'; | ||
class Eta { | ||
constructor() { | ||
constructor({ | ||
formatter | ||
} = {}) { | ||
this.c = new Date(); | ||
this.p = 0; | ||
this.ft = formatter !== null && formatter !== void 0 ? formatter : time; | ||
} | ||
tick() { | ||
return this.p = this.c, this.c = new Date(), this.c - this.p; | ||
return this.p = this.c, this.c = new Date(); | ||
} | ||
ini(msg = '') { | ||
return `[${formatTime(this.c)}] [Ini 0ms] ${msg}`; | ||
return this.tick(), `${this.ft(this.c)} [ini 0ms] ${msg}`; | ||
} | ||
lap(msg = '') { | ||
return `[${formatTime(this.c)}] [Lap ${this.tick()}ms] ${msg}`; | ||
return this.tick(), `${this.ft(this.c)} [lap ${this.c - this.p}ms] ${msg}`; | ||
} | ||
end(msg = '') { | ||
return `[${formatTime(this.c)}] [End ${this.tick()}ms] ${msg}`; | ||
return this.tick(), `${this.ft(this.c)} [end ${this.c - this.p}ms] ${msg}`; | ||
} | ||
static build() { | ||
return new Eta(); | ||
} | ||
static buildPretty(timePreset = SUBTLE, milliPreset = SUBTLE) { | ||
const timestamp = Timestamp.build(undefined, timePreset, milliPreset); | ||
const formatter = timestamp.time.bind(timestamp); | ||
return new Eta({ | ||
formatter | ||
}); | ||
} | ||
} | ||
export { Eta }; |
{ | ||
"name": "@valjoux/eta", | ||
"version": "0.1.8", | ||
"version": "0.1.9", | ||
"description": "timer", | ||
@@ -18,3 +18,5 @@ "main": "dist/index.cjs.js", | ||
"dependencies": { | ||
"@valjoux/format-time": "^0.1.8" | ||
"@palett/presets": "^0.3.5", | ||
"@valjoux/timestamp": "^0.1.9", | ||
"@valjoux/timestamp-pretty": "^0.1.9" | ||
}, | ||
@@ -37,3 +39,3 @@ "repository": { | ||
"homepage": "https://github.com/hoyeungw/valjoux#readme", | ||
"gitHead": "a4749a2ca653eb31ee67137b1046c5eb5abf069d" | ||
"gitHead": "18c8e2185b9200169821e113a80add92e9f18fe0" | ||
} |
5501
72
3
+ Added@palett/presets@^0.3.5
+ Added@valjoux/timestamp@^0.1.9
+ Added@aryth/bound-vector@0.2.14(transitive)
+ Added@aryth/comparer@0.2.14(transitive)
+ Added@aryth/math@0.2.14(transitive)
+ Added@aryth/rand@0.2.14(transitive)
+ Added@aryth/util-bound@0.2.14(transitive)
+ Added@ject/oneself@0.0.6(transitive)
+ Added@palett/cards@0.3.70.4.6(transitive)
+ Added@palett/convert@0.3.70.4.6(transitive)
+ Added@palett/dye@0.4.6(transitive)
+ Added@palett/presets@0.3.70.4.6(transitive)
+ Added@palett/projector@0.4.6(transitive)
+ Added@palett/toner-hsl@0.3.70.4.6(transitive)
+ Added@palett/util-ansi@0.4.6(transitive)
+ Added@palett/util-fluo@0.4.6(transitive)
+ Added@spare/enum-chars@0.8.16(transitive)
+ Added@spare/regex-charset@0.13.16(transitive)
+ Added@spare/string-value@0.8.16(transitive)
+ Added@typen/enum-check-levels@0.1.19(transitive)
+ Added@typen/enum-data-types@0.1.19(transitive)
+ Added@typen/literal@0.1.19(transitive)
+ Added@typen/nullish@0.1.19(transitive)
+ Added@typen/num-loose@0.1.19(transitive)
+ Added@typen/num-strict@0.1.19(transitive)
+ Added@typen/typ@0.1.19(transitive)
+ Added@valjoux/convert@0.1.11(transitive)
+ Added@valjoux/format-date@0.1.11(transitive)
+ Added@valjoux/format-date-time@0.1.11(transitive)
+ Added@valjoux/timestamp@0.1.11(transitive)
+ Added@valjoux/timestamp-pretty@0.1.11(transitive)
+ Added@valjoux/util-bitwise@0.1.11(transitive)
+ Added@vect/swap@0.2.13(transitive)
+ Added@vect/vector-mapper@0.2.13(transitive)
+ Added@vect/vector-zipper@0.2.13(transitive)
+ Addedpalett@0.1.1(transitive)
+ Addedpalett-presets@0.1.1(transitive)
+ Addedtypen@0.2.3(transitive)
- Removed@valjoux/format-time@^0.1.8