Closed
Description
Typing...
> x=new Float32Array(100000);
... leads to death and sorrow, as the interpreter decides to util.inspect(x)
.
There are, of course, workarounds, such as
> x=new Float32Array(100000); 0
... but I was wondering if we might be able to do better.
What if we told util.inspect to handle ArrayBuffers and their views a bit differently from other objects?
Now obviously we don't want to go changing the code for util.inspect any time some new-fangled object that comes on the scene. However, typed arrays are definitely here to stay and currently growing in popularity.
Two reasonable courses would be
> new Float32Array(36)
[Float32Array: length 36]
or
> new Float32Array(36)
{ BYTES_PER_ELEMENT: 4,
get: [Function: get],
set: [Function: set],
slice: [Function: slice],
subarray: [Function: subarray],
buffer: {slice: [Function: slice], byteLength:144}
length: 36,
byteOffset: 0,
byteLength: 4 }
What do you think. Am I crazy?