Completed
Push — master ( dce25d...9db7be )
by Dimas
09:29 queued 12s
created

libs/src/observatory/ts/constants.ts   A

Complexity

Total Complexity 4
Complexity/F 0

Size

Lines of Code 50
Function Count 0

Duplication

Duplicated Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 38
dl 0
loc 50
rs 10
c 0
b 0
f 0
wmc 4
mnd 4
bc 4
fnc 0
bpm 0
cpm 0
noi 0
1
"use strict";
2
import chalk from "chalk";
3
4
var states = {
5
  active: "active",
6
  done: "done",
7
  fail: "fail",
8
};
9
10
var loader = function () {
11
  (function () {
12
    var P = ["\\", "|", "/", "-"];
13
    var x = 0;
14
    return setInterval(function () {
15
      process.stdout.write("\r" + P[x++]);
16
      x &= 3;
17
    }, 250);
18
  })();
19
};
20
21
var defaultSettings = {
22
  width: 55,
23
  prefix: ">>> ",
24
  write: process.stdout.write.bind(process.stdout),
25
  formatStatus: function (statusLabel, state) {
26
    if (!statusLabel) {
27
      return "";
28
    }
29
30
    if (state === states.active) {
31
      return chalk.yellow(statusLabel);
32
    }
33
34
    if (state === states.done) {
35
      return chalk.green(statusLabel);
36
    }
37
38
    if (state === states.fail) {
39
      return chalk.red(statusLabel);
40
    }
41
42
    return statusLabel;
43
  },
44
};
45
46
export = {
47
  state: states,
48
  defaultSettings: defaultSettings,
49
};
50