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