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%)
537 of 548 relevant lines covered (97.99%)
1549.31 hits per line
|
import {toType} from './util'; |
30✔ |
2 |
|
|
3 |
export default (value) => { |
|
|
const type = toType(value); |
355✔ |
|
let string_value; |
355✔ |
|
switch (type) {
|
355✔ |
7 |
case 'undefined': { |
|
|
string_value = 'undefined';
|
14✔ |
|
break;
|
14✔ |
10 |
} |
|
11 |
case 'nan': { |
|
|
string_value = 'NaN';
|
14✔ |
|
break;
|
14✔ |
14 |
} |
|
15 |
case 'string': |
|
|
string_value = value; |
115✔ |
|
break;
|
115✔ |
18 |
case 'date': |
|
|
string_value = value.toString(); |
14✔ |
|
break;
|
14✔ |
21 |
case 'function': { |
|
|
string_value = value.toString(); |
28✔ |
|
break;
|
28✔ |
24 |
} |
|
25 |
default: {
|
|
|
try {
|
170✔ |
|
string_value = JSON.stringify(value, null, ' '); |
170✔ |
28 |
} catch (e) {
|
|
|
string_value = '';
|
× |
30 |
} |
|
31 |
} |
|
32 |
} |
|
33 |
|
|
|
return string_value;
|
355✔ |
35 |
} |