2019-10-20 05:13:19 +00:00
|
|
|
# [@root/hexdump](https://git.rootprojects.org/root/hexdump.js)
|
2019-10-20 04:55:00 +00:00
|
|
|
|
|
|
|
| Built by [Root](https://rootprojects.org)
|
2017-09-25 18:36:19 +00:00
|
|
|
|
2017-09-25 20:28:30 +00:00
|
|
|
Given an `ArrayBuffer`, will create string output similar to the unix `hexdump` command.
|
|
|
|
|
|
|
|
For example, the text of "Hello, World!\n" looks something like this:
|
2017-09-25 18:36:19 +00:00
|
|
|
|
2019-10-20 04:55:00 +00:00
|
|
|
```txt
|
2017-09-25 18:36:19 +00:00
|
|
|
0 1 2 3 4 5 6 7 8 9 A B C D E F
|
|
|
|
0000000 48 65 6c 6c 6f 2c 20 57 6f 72 6c 64 21 0a
|
|
|
|
000000e
|
|
|
|
```
|
|
|
|
|
2019-10-20 05:13:19 +00:00
|
|
|
# Usage
|
2017-09-25 18:36:19 +00:00
|
|
|
|
|
|
|
So far it just does one thing: print an ArrayBuffer in hex, with a header:
|
|
|
|
|
2019-10-20 05:13:19 +00:00
|
|
|
## Node.js (and WebPack)
|
2017-09-25 18:36:19 +00:00
|
|
|
|
|
|
|
```bash
|
2019-10-20 05:13:19 +00:00
|
|
|
var hexdump = require('hexdump.js').hexdump;
|
2017-09-25 18:36:19 +00:00
|
|
|
|
|
|
|
var str = hexdump(new Uint8Array([ 0, 1, 2, 127, 254, 255 ]));
|
|
|
|
|
|
|
|
console.log(str);
|
|
|
|
```
|
|
|
|
|
2019-10-20 05:13:19 +00:00
|
|
|
## Vanilla JS (Browser)
|
|
|
|
|
|
|
|
```html
|
|
|
|
<script src="https://unpkg.com/@root/hexdump/dist/hexdump.js"></script>
|
|
|
|
```
|
|
|
|
|
|
|
|
```html
|
|
|
|
<script src="https://unpkg.com/@root/hexdump/dist/hexdump.min.js"></script>
|
|
|
|
```
|
2017-09-25 18:39:09 +00:00
|
|
|
|
|
|
|
```javascript
|
2019-10-20 04:55:00 +00:00
|
|
|
console.log(window.hexdump(new Uint8Array([0, 1, 2, 127, 254, 255])));
|
2017-09-25 18:39:09 +00:00
|
|
|
```
|
|
|
|
|
2017-09-25 18:36:19 +00:00
|
|
|
### CLI
|
|
|
|
|
|
|
|
```bash
|
|
|
|
hexdump.js <filepath>
|
|
|
|
```
|
|
|
|
|
2019-10-20 04:55:00 +00:00
|
|
|
## Install
|
2017-09-25 18:36:19 +00:00
|
|
|
|
|
|
|
Centralized:
|
|
|
|
|
|
|
|
```bash
|
|
|
|
# As a library
|
2019-10-20 04:55:00 +00:00
|
|
|
npm install --save @root/hexdump
|
2017-09-25 18:36:19 +00:00
|
|
|
|
|
|
|
# As a global CLI (useful on windows)
|
2019-10-20 04:55:00 +00:00
|
|
|
npm install --global @root/hexdump
|
2017-09-25 18:36:19 +00:00
|
|
|
```
|
2017-09-25 20:31:00 +00:00
|
|
|
|
2019-10-20 04:55:00 +00:00
|
|
|
## API
|
2017-09-25 20:31:00 +00:00
|
|
|
|
2019-10-20 04:55:00 +00:00
|
|
|
```js
|
2017-09-25 20:31:00 +00:00
|
|
|
hexdump(arrayBuffer, byteOffset, byteLength);
|
2017-10-25 23:53:08 +00:00
|
|
|
```
|