Giter Site home page Giter Site logo

Handle circular references better about loupe HOT 2 OPEN

fregante avatar fregante commented on June 12, 2024
Handle circular references better

from loupe.

Comments (2)

koddsson avatar koddsson commented on June 12, 2024 1

Oh wow, let me take a look at this. Ping me if I forget. I can at least reproduce it so that's something:

  1) assert
       lengthOf doesn't crash:
     RangeError: Maximum call stack size exceeded
      at inspectObject (file:///Users/cr91ew/src/koddsson/chai/node_modules/loupe/lib/object.js:2:23)
      at inspectClass (file:///Users/cr91ew/src/koddsson/chai/node_modules/loupe/lib/class.js:13:20)
      at Object.inspect (file:///Users/cr91ew/src/koddsson/chai/node_modules/loupe/lib/index.js:118:14)
      at inspectProperty (file:///Users/cr91ew/src/koddsson/chai/node_modules/loupe/lib/helpers.js:144:19)
      at inspectList (file:///Users/cr91ew/src/koddsson/chai/node_modules/loupe/lib/helpers.js:108:28)
      at inspectObject (file:///Users/cr91ew/src/koddsson/chai/node_modules/loupe/lib/object.js:14:28)
      at inspectClass (file:///Users/cr91ew/src/koddsson/chai/node_modules/loupe/lib/class.js:13:20)
      at Object.inspect (file:///Users/cr91ew/src/koddsson/chai/node_modules/loupe/lib/index.js:118:14)
      at inspectProperty (file:///Users/cr91ew/src/koddsson/chai/node_modules/loupe/lib/helpers.js:144:19)

from loupe.

fregante avatar fregante commented on June 12, 2024 1

When generating the preview, would it make sense to automatically limit the size?

For example it's useful to see the message Expected [0, 2, 8] to have length 4, but it becomes unreadable when the array is huge or when it contains large objects.

An example limit for this specific case could look like arr.length * Object.keys(arr[0]).length < 20, although I know it might be difficult to translate it into real code. This might also be a choice of the caller rather than loupe's itself.

I know that Node's inspect won't try to go too deep into objects, so such a limit alone should solve circular references permanently.

from loupe.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.