I am not a rookie programmer I know how to console.log(myObject). What I want is to be able to print ANY object to a string with max depth, and not have empty properties in it. There are so many times when I need to print out an object to the console or to a log somewhere, and it prints the WHOLE object. That could take up so much space my terminal cant fit the whole object. The reason I am asking this here is so that someone can identify all of the edge cases that I am probably missing or places I am overthinking things.
Here is an example:
[
  {
    a: 'a',
    b: '',
    c: {
      d: 'd',
      e: {
        f: {
          g: 'g'
        }
      },
      h: [
        'i',
        'j',
        { k: 'k' }
      ],
      l: [],
    }
  }
]
printAny(myObject,5) should output:
[
  {
    a: 'a',
    c: {
      d: 'd',
      e: {
        f: '<objec>'
      },
      h: [
        'i',
        'j',
        '<object>'
      ],
    }
  }
]
I made a jsbin to some more examples: https://jsbin.com/buzugipole/edit?js,console
It should also handle cycles. I am not opposed to using npm libraries, that is what I am using right now, but it is a hodgepodge of 3 different libraries that are all trying to solve this.
 
    