1 | ;
|
2 |
|
3 | const is = require('is-type-of');
|
4 |
|
5 | module.exports = function show(obj) {
|
6 | const type = {}.toString.call(obj).replace(/^\[object (.*)\]$/, '$1');
|
7 | if (is.buffer(obj)) obj = obj.toString();
|
8 | // escape \n to \\n for good view in terminal
|
9 | if (is.string(obj)) obj = obj.replace(/\n/g, '\\n');
|
10 | // stringify if object
|
11 | if (!is.regexp(obj) && is.object(obj)) obj = JSON.stringify(obj);
|
12 | return `${obj}(${type})`;
|
13 | };
|