• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

wavedrom / wavedrom / 6739999361

03 Nov 2023 01:00AM UTC coverage: 64.638%. Remained the same
6739999361

push

github

drom
eslint fixes. same line else-if chains

214 of 408 branches covered (0.0%)

Branch coverage included in aggregate %.

3 of 4 new or added lines in 2 files covered. (75.0%)

2 existing lines in 1 file now uncovered.

455 of 627 relevant lines covered (72.57%)

86.2 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

61.0
/lib/render-marks.js
1
'use strict';
2

3
const tspan = require('tspan');
5✔
4

5
function captext (cxt, anchor, y) {
6
    if (cxt[anchor] && cxt[anchor].text) {
50✔
7
        return [
10✔
8
            ['text', {
9
                x: cxt.xmax * cxt.xs / 2,
10
                y: y,
11
                fill: '#000',
12
                'text-anchor': 'middle',
13
                'xml:space': 'preserve'
14
            }].concat(tspan.parse(cxt[anchor].text))
15
        ];
16
    }
17
    return [];
40✔
18
}
19

20
function ticktock (cxt, ref1, ref2, x, dx, y, len) {
21
    let offset;
22
    let L = [];
100✔
23

24
    if (cxt[ref1] === undefined || cxt[ref1][ref2] === undefined) {
100✔
25
        return [];
90✔
26
    }
27

28
    let val = cxt[ref1][ref2];
10✔
29

30
    if (typeof val === 'string') {
10!
31
        val = val.trim().split(/\s+/);
×
32
    } else if (typeof val === 'number' || typeof val === 'boolean') {
10!
33
        offset = Number(val);
10✔
34
        val = [];
10✔
35
        for (let i = 0; i < len; i += 1) {
10✔
36
            val.push(i + offset);
55✔
37
        }
38
    }
39
    if (Array.isArray(val)) {
10!
40
        if (val.length === 0) {
10!
41
            return [];
×
42
        } else if (val.length === 1) {
10!
UNCOV
43
            offset = Number(val[0]);
×
44
            if (isNaN(offset)) {
×
45
                L = val;
×
46
            } else {
47
                for (let i = 0; i < len; i += 1) {
×
48
                    L[i] = i + offset;
×
49
                }
50
            }
51
        } else if (val.length === 2) {
10!
UNCOV
52
            offset = Number(val[0]);
×
53
            const step = Number(val[1]);
×
54
            const tmp = val[1].split('.');
×
55
            let dp = 0;
×
56
            if (tmp.length === 2) {
×
57
                dp = tmp[1].length;
×
58
            }
59
            if (isNaN(offset) || isNaN(step)) {
×
60
                L = val;
×
61
            } else {
62
                offset = step * offset;
×
63
                for (let i = 0; i < len; i += 1) {
×
64
                    L[i] = (step * i + offset).toFixed(dp);
×
65
                }
66
            }
67
        } else {
68
            L = val;
10✔
69
        }
70
    } else {
71
        return [];
×
72
    }
73

74
    const res = ['g', {
10✔
75
        class: 'muted',
76
        'text-anchor': 'middle',
77
        'xml:space': 'preserve'
78
    }];
79

80
    for (let i = 0; i < len; i += 1) {
10✔
81
        if (cxt[ref1] && cxt[ref1].every && (i + offset) % cxt[ref1].every != 0) {
55!
82
            continue;
×
83
        }
84
        res.push(['text', {x: i * dx + x, y: y}].concat(tspan.parse(L[i])));
55✔
85
    }
86
    return [res];
10✔
87
} /* eslint complexity: [1, 30] */
88

89
function renderMarks (content, index, lane, source) {
90
    const mstep  = 2 * (lane.hscale);
25✔
91
    const mmstep = mstep * lane.xs;
25✔
92
    const marks  = lane.xmax / mstep;
25✔
93
    const gy     = content.length * lane.yo;
25✔
94

95
    const res = ['g', {id: ('gmarks_' + index)}];
25✔
96
    const gmarkLines = ['g', {style: 'stroke:#888;stroke-width:0.5;stroke-dasharray:1,3'}];
25✔
97
    if (!(source && source.config && source.config.marks === false)) {
25!
98
        for (let i = 0; i < (marks + 1); i += 1) {
25✔
99
            gmarkLines.push(['line', {
255✔
100
                id: 'gmark_' + i + '_' + index,
101
                x1: i * mmstep, y1: 0,
102
                x2: i * mmstep, y2: gy
103
            }]);
104
        }
105
        res.push(gmarkLines);
25✔
106
    }
107
    return res.concat(
25✔
108
        captext(lane, 'head', (lane.yh0 ? -33 : -13)),
25✔
109
        captext(lane, 'foot', gy + (lane.yf0 ? 45 : 25)),
25✔
110
        ticktock(lane, 'head', 'tick',          0, mmstep,      -5, marks + 1),
111
        ticktock(lane, 'head', 'tock', mmstep / 2, mmstep,      -5, marks),
112
        ticktock(lane, 'foot', 'tick',          0, mmstep, gy + 15, marks + 1),
113
        ticktock(lane, 'foot', 'tock', mmstep / 2, mmstep, gy + 15, marks)
114
    );
115
}
116

117
module.exports = renderMarks;
5✔
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc