src, test: support reading contents from buffers #116
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR adds support for reading contents from array buffers, typed arrays, and Node buffers (since they are Uint8Arrays).
This currently prints the content like this:
I have changed the non-detail view of these objects to show the names of each field, so it's now
<ArrayBufferView: backingStore=0x0000000104007200, byteOffset=1296, byteLength=6>
instead of<ArrayBufferView 0x0000000104007200+1296:6>
.The detailed view currently just prints the content byte by byte separated by commas in one line. At the moment it does not handle endianness, nor does it "merges" the bytes for typed arrays with types other than Uint8, but that can be worked on later.
Also currently it just prints the bytes in decimals like what you get when doing
util.inspect
on typed arrays in Node.js, I don't have an opinion on what format it's supposed to be, so feel free to give suggestions (e.g. print hexidemals or print it line by line like whatmemory read
in lldb does)Fixes: #89
cc: @bnoordhuis
Tested on Mac OS 10.12.4 with Node v6.11.1, v4.8.4 and v8.1.4