push
github
2339 of 2460 branches covered (95.08%)
8396 of 8538 relevant lines covered (98.34%)
55.31 hits per line
1 |
'use strict';
|
|
2 |
|
1✔ |
3 |
const strip = require('strip-ansi');
|
1✔ |
4 |
|
1✔ |
5 |
exports.stringLength = str => { |
|
6 |
str = strip(str); |
108✔ |
7 |
|
108✔ |
8 |
const len = str.length; |
108✔ |
9 |
let result = len; |
108✔ |
10 |
|
108✔ |
11 |
// Detect double-byte characters
|
108✔ |
12 |
for (let i = 0; i < len; i++) { |
|
13 |
if (str.charCodeAt(i) > 255) { |
|
14 |
result++; |
× |
15 |
} |
× |
16 |
} |
456✔ |
17 |
|
108✔ |
18 |
return result;
|
108✔ |
19 |
}; |
1✔ |