cloudflare / chrome-devtools-rs

Rust library for the Chrome Devtools Protocol
MIT License
62 stars 4 forks source link

Adds colored display feature #31

Closed EverlastingBugstopper closed 4 years ago

EverlastingBugstopper commented 4 years ago

I tried to make the output of the formatted display as close to node's as possible. Even though they're different protocols and the display won't exactly match, 90% of ergonomics is familiarity.

https://github.com/nodejs/node/blob/f4a4a1a63c7ceba77a0178b4af6068abcadba41f/doc/api/util.md#customizing-utilinspect-colors

Here's some sample code I've run

  const fun = () => {
    return true
  }

  let obj = {
    hello: 'world',
    one: 'two',
    fun,
    o: {
      somethindg: {
        nest: 'again',
      },
      arr: ['hello', 'world'],
    },
  }
  let map = new Map()
  map.set("hello", "world")
  map.set(obj, obj)
  let url = "https://google.com"
  console.log(fun)
  console.log(["hello", "world", {"hi": "there"}, 4])
  console.log({"woah": 2, [url]: "fine"})
  console.log(3.13)
  console.log(5)
  console.log(true)
  console.log(1000n)
  console.log(null)
  console.log(undefined)
  console.log("hello", "world")
  console.log(obj, null, undefined, true, obj, "hello world")
  console.log(new RegExp("hello"))
  console.log(new Date())
  console.error(null)
  console.log('hello, world! i have edited a file again again')
  console.error('this is not a console.error')
  console.assert(true)
  console.log(map)

Here's the output from this PR

image