inspect-js / object-inspect

string representations of objects in node and the browser
MIT License
142 stars 36 forks source link

Support large TypedArrays #44

Open jmacmahon opened 8 months ago

jmacmahon commented 8 months ago

Hi and thanks for the great project,

I'm writing a browser app that uses the Web Audio APIs and my state includes several large (~40MB) Float32Arrays of decoded audio data. Trying to dump the state using objectInspect causes the tab to freeze, presumably because it tries to stringify every value of the array. Would it be possible to output Float32Array [ 42, 42, 42, ... ] for these kinds of values, like the example in the README that includes a ... for deeply nested DOM elements?

ljharb commented 8 months ago

We could certainly add an option like util.inspect's maxArrayLength - altho our default would be Infinity, and i'd prefer a better name (it's called "array" but controls all collection types).

jmacmahon commented 8 months ago

Oh yes, maxArrayLength seems like a good solution