push
191 of 225 branches covered (84.89%)
Branch coverage included in aggregate %.
37 of 37 new or added lines in 4 files covered. (100.0%)
536 of 548 relevant lines covered (97.81%)
1509.27 hits per line
|
import {toType} from './util'; |
28✔ |
2 |
|
|
3 |
export default (value) => { |
|
|
const type = toType(value); |
327✔ |
|
let string_value; |
327✔ |
|
switch (type) {
|
327✔ |
7 |
case 'undefined': { |
|
|
string_value = 'undefined';
|
13✔ |
|
break;
|
13✔ |
10 |
} |
|
11 |
case 'nan': { |
|
|
string_value = 'NaN';
|
13✔ |
|
break;
|
13✔ |
14 |
} |
|
15 |
case 'string': |
|
|
string_value = value; |
104✔ |
|
break;
|
104✔ |
18 |
case 'date': |
|
|
string_value = value.toString(); |
13✔ |
|
break;
|
13✔ |
21 |
case 'function': { |
|
|
string_value = value.toString(); |
26✔ |
|
break;
|
26✔ |
24 |
} |
|
25 |
default: {
|
|
|
try {
|
158✔ |
|
string_value = JSON.stringify(value, null, ' '); |
158✔ |
28 |
} catch (e) {
|
|
|
string_value = '';
|
× |
30 |
} |
|
31 |
} |
|
32 |
} |
|
33 |
|
|
|
return string_value;
|
327✔ |
35 |
} |