bajo 0.2.11 → 0.2.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/boot/lib/bora.js +9 -3
  2. package/package.json +1 -1
package/boot/lib/bora.js CHANGED
@@ -29,7 +29,7 @@ class Bora {
29
29
  }
30
30
 
31
31
  setText (text, ...args) {
32
- const { dayjs, secToHms } = this.scope.bajo.helper
32
+ const { dayjs } = this.scope.bajo.helper
33
33
  if (isString(text)) {
34
34
  const i18n = get(this, 'scope.bajoI18N.instance')
35
35
  if (i18n) {
@@ -38,16 +38,22 @@ class Bora {
38
38
  } else text = sprintf(text, ...args)
39
39
  let opts = last(args)
40
40
  if (!isPlainObject(opts)) opts = {}
41
- const elapsed = dayjs().diff(this.startTime, 'second')
42
41
  const texts = []
43
42
  if (this.opts.showDatetime || opts.showDatetime) texts.push('[' + dayjs().toISOString() + ']')
44
- if (this.opts.showCounter || opts.showCounter) texts.push('[' + secToHms(elapsed) + ']')
43
+ if (this.opts.showCounter || opts.showCounter) texts.push('[' + this.getElapsed() + ']')
45
44
  texts.push(text)
46
45
  this.ora.text = texts.join(' ')
47
46
  }
48
47
  return this
49
48
  }
50
49
 
50
+ getElapsed (unit = 'hms') {
51
+ const { dayjs, secToHms } = this.scope.bajo.helper
52
+ const u = unit === 'hms' ? 'second' : unit
53
+ const elapsed = dayjs().diff(this.startTime, u)
54
+ return unit === 'hms' ? secToHms(elapsed) : elapsed
55
+ }
56
+
51
57
  start (text, ...args) {
52
58
  this.setText(text, ...args)
53
59
  this.ora.start()
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bajo",
3
- "version": "0.2.11",
3
+ "version": "0.2.12",
4
4
  "description": "A framework to build a giant monstrous app rapidly",
5
5
  "main": "boot/index.js",
6
6
  "scripts": {