1 | function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 |
|
13 |
|
14 |
|
15 | export default function inspect(value) {
|
16 | switch (_typeof(value)) {
|
17 | case 'string':
|
18 | return JSON.stringify(value);
|
19 |
|
20 | case 'function':
|
21 | return value.name ? "[function ".concat(value.name, "]") : '[function]';
|
22 |
|
23 | case 'object':
|
24 | if (value) {
|
25 | if (typeof value.inspect === 'function') {
|
26 | return value.inspect();
|
27 | } else if (Array.isArray(value)) {
|
28 | return '[' + value.map(inspect).join(', ') + ']';
|
29 | }
|
30 |
|
31 | var properties = Object.keys(value).map(function (k) {
|
32 | return "".concat(k, ": ").concat(inspect(value[k]));
|
33 | }).join(', ');
|
34 | return properties ? '{ ' + properties + ' }' : '{}';
|
35 | }
|
36 |
|
37 | return String(value);
|
38 |
|
39 | default:
|
40 | return String(value);
|
41 | }
|
42 | } |
\ | No newline at end of file |