Compare commits

...

1 Commits
master ... old

Author SHA1 Message Date
AJ ONeal 71aa9815e8 v1.1.0: update urls 2019-10-19 23:06:51 -06:00
4 changed files with 37 additions and 41 deletions

View File

@ -1,4 +1,4 @@
# @root/hexdump
# [hexdump.js](https://git.rootprojects.org/root/hexdump.js)
| Built by [Root](https://rootprojects.org)
@ -12,45 +12,51 @@ For example, the text of "Hello, World!\n" looks something like this:
000000e
```
## Usage
# Usage
So far it just does one thing: print an ArrayBuffer in hex, with a header:
### JavaScript
## Node.js (and WebPack)
```bash
var hexdump = require('@root/hexdump').hexdump;
var hexdump = require('hexdump.js').hexdump;
var str = hexdump(new Uint8Array([ 0, 1, 2, 127, 254, 255 ]));
console.log(str);
```
### Browser
## 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>
```
```javascript
console.log(window.hexdump(new Uint8Array([0, 1, 2, 127, 254, 255])));
```
### CLI
## CLI
```bash
hexdump.js <filepath>
```
## Install
Centralized:
# Install
```bash
# As a library
npm install --save @root/hexdump
npm install --save @hexdump.js
# As a global CLI (useful on windows)
npm install --global @root/hexdump
npm install --global @hexdump.js
```
## API
# API
```js
hexdump(arrayBuffer, byteOffset, byteLength);

View File

@ -1,30 +1,4 @@
#!/usr/bin/env node
'use strict';
var hexdump = require('../');
var fsname = process.argv[2];
var fs = require('fs');
var opts = {};
if (!fsname || '--help' === fsname || '-h' === fsname) {
console.error('Usage: hexdump.js -C <filepath>');
process.exit(2);
return;
}
if ('-C' === fsname) {
opts.C = true;
fsname = process.argv[3];
}
try {
fs.statSync(fsname);
} catch (e) {
console.error(e.message);
process.exit(3);
return;
}
var nb = fs.readFileSync(fsname);
var str = hexdump(nb.buffer, nb.byteOffset, nb.byteLength, opts);
console.info(str);
require('@root/hexdump/bin/cli.js');

13
package-lock.json generated Normal file
View File

@ -0,0 +1,13 @@
{
"name": "hexdump.js",
"version": "1.1.0",
"lockfileVersion": 1,
"requires": true,
"dependencies": {
"@root/hexdump": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/@root/hexdump/-/hexdump-1.1.0.tgz",
"integrity": "sha512-D0KpG8OkJUEP2GixkIjjLoB9P6t2KruAirnmKL5utT1Ma16S26vwG4ibLVBqG6rySaUDaCx7YMRH+5zzZS5jQw=="
}
}
}

View File

@ -1,5 +1,5 @@
{
"name": "@root/hexdump",
"name": "hexdump.js",
"version": "1.1.0",
"description": "Like hexdump on *nix, but in JavaScript.",
"main": "hexdump.js",
@ -21,5 +21,8 @@
"js"
],
"author": "AJ ONeal <coolaj86@gmail.com> (https://coolaj86.com)",
"license": "MPL-2.0"
"license": "MPL-2.0",
"dependencies": {
"@root/hexdump": "^1.1.0"
}
}