(x)
| 1 | import { inspect } from 'util/util'; |
| 2 | |
| 3 | export function format(x) { |
| 4 | // we're trying to mimic console.log, so we avoid wrapping strings in quotes: |
| 5 | if (typeof x === 'string') return x; |
| 6 | else if (x instanceof Set) { |
| 7 | return `Set(${x.size}) {${Array.from(x).join(', ')}}`; |
| 8 | } else if (x instanceof Map) { |
| 9 | return `Map(${x.size}) {${Array.from( |
| 10 | x.entries(), |
| 11 | ([k, v]) => `${k} => ${v}` |
| 12 | ).join(', ')}})`; |
| 13 | } else if (typeof x === 'bigint') { |
| 14 | return x.toString() + 'n'; |
| 15 | } else if (typeof x === 'symbol') { |
| 16 | return x.toString(); |
| 17 | } |
| 18 | return inspect(x); |
| 19 | } |
no outgoing calls
no test coverage detected