util: inspect ArrayBuffers TypedArray as well#25006
util: inspect ArrayBuffers TypedArray as well#25006BridgeAR wants to merge 2 commits intonodejs:masterfrom
Conversation
|
I find this very confusing. ArrayBuffers don't have an underlying Uint8Array, it's the opposite. |
|
@targos yes, I described it wrong. The point is, that inspecting two different ArrayBuffer directly can result in the same output while belonging to a very different TypedArray. This makes sure it's clear to the viewer. I am also happy with a different representation but this was the best I could come up with. |
|
An alternative representations I thought about was:
|
|
@nodejs/util PTAL |
|
Since |
|
@targos I am fine with using a hexadecimal representation but I am not sure how to name the "property" (description) in that case. I could keep it as About the current state: I think it's nice to see as much as possible right away but more important: it helps identifying different ArrayBuffers from each other right away. This also has impact on e.g. comparing two ArrayBuffers with |
|
@targos @addaleax what do you think of either of these representations (or any potential combination of some of these):
I personally think it's important to tell the user that it is represented as |
|
@BridgeAR I think 2, 3, 4, 5, 6 are misleading because they imply an associated ArrayBufferView in one way or another that does not actually exist. I think 6 and 7 are not useful, because base64 does not provide much visual information about the contents, only a way to reconstruct it. I’d prefer for visual clutter/“specialness” to be minimal, so maybe a pseudo-property like
I’m not sure I agree – we don’t do this for |
Sounds fine to me.
Coming from your suggestion, here's a new set of possibilities. I personally prefer 1 and 2 while not having a strong preference for either. I think 3 and 5 lack a description of the "value" (looking at it alone), otherwise I would also go for a pseudo property.
|
|
Alternatives: |
|
/cc @nodejs/util |
|
@BridgeAR I think my personal preferences would be 5, 3, 2, 1, but let’s see what others think :) Re: content vs contents, maybe it’s best to leave that to a native speaker? |
|
@addaleax the difference between @Trott @vsemozhetbyt would you two be so kind and have a look at this? :) Thinking about it: we could maybe use a team (e.g. @targos do you have a preference for the last suggestions? |
In this particular case, I think |
a5100e0 to
f58d87c
Compare
|
PTAL. I reworked the output as discussed. CI https://ci.nodejs.org/job/node-test-pull-request/19772/ ✔️ |
Inspecting an ArrayBuffer now also shows their binary contents.
f58d87c to
48bde7a
Compare
|
Rebased due to conflicts. PTAL, this needs a review. |
|
Landed in aa07dd6 |
Inspecting an ArrayBuffer now also shows their binary contents. PR-URL: #25006 Reviewed-By: Anna Henningsen <anna@addaleax.net>
|
@BridgeAR fyi, this would need a manual backport to |
Inspecting an ArrayBuffer now also shows their binary contents. PR-URL: nodejs#25006 Reviewed-By: Anna Henningsen <anna@addaleax.net>
Inspecting an ArrayBuffer now also shows their binary contents. PR-URL: #25006 Reviewed-By: Anna Henningsen <anna@addaleax.net>
Inspecting an ArrayBuffer now also shows their binary contents. PR-URL: #25006 Reviewed-By: Anna Henningsen <anna@addaleax.net>
Notable Changes
* compression / zlib:
* Added brotli support (Anna Henningsen and Zach Vacura)
nodejs#24938
* console:
* Added `inspectOptions` option (Ruben Bridgewater)
nodejs#24978
* crypto:
* Always accept private keys as public keys (Tobias Nießen)
nodejs#25217
* deps:
* Upgrade npm to v6.5.0 (Jordan Harband)
nodejs#25234
* fs:
* Use internalBinding('fs') internally instead of
process.binding('fs') (Masashi Hirano)
nodejs#22478
* http(s):
* Support overriding http\\s.globalAgent (Roy Sommer)
nodejs#25170
* util:
* Inspect ArrayBuffers contents closely (Ruben Bridgewater)
nodejs#25006
* worker:
* Expose workers by default and remove `--experimental-worker` flag
(Anna Henningsen) nodejs#25361
PR-URL: nodejs#25537
Notable Changes
* compression / zlib:
* Added brotli support (Anna Henningsen and Zach Vacura)
#24938
* console:
* Added `inspectOptions` option (Ruben Bridgewater)
#24978
* crypto:
* Always accept private keys as public keys (Tobias Nießen)
#25217
* deps:
* Upgrade npm to v6.5.0 (Jordan Harband)
#25234
* fs:
* Use internalBinding('fs') internally instead of
process.binding('fs') (Masashi Hirano)
#22478
* http(s):
* Support overriding http\\s.globalAgent (Roy Sommer)
#25170
* util:
* Inspect ArrayBuffers contents closely (Ruben Bridgewater)
#25006
* worker:
* Expose workers by default and remove `--experimental-worker` flag
(Anna Henningsen) #25361
PR-URL: #25537
Inspecting an ArrayBuffer alone now also shows the Uint8Array to which the ArrayBuffer belongs to.
I visualized it as special property even though it's not a property. I have no strong opinion about that but it seemed like the best representation.
Checklist
make -j4 test(UNIX), orvcbuild test(Windows) passes