diff --git a/README.md b/README.md index 2616402..6a801c8 100644 --- a/README.md +++ b/README.md @@ -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 + +``` + +```html + +``` ```javascript console.log(window.hexdump(new Uint8Array([0, 1, 2, 127, 254, 255]))); ``` -### CLI +## CLI ```bash hexdump.js ``` -## 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); diff --git a/bin/cli.js b/bin/cli.js index 2de716e..0225aef 100755 --- a/bin/cli.js +++ b/bin/cli.js @@ -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 '); - 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'); diff --git a/package-lock.json b/package-lock.json new file mode 100644 index 0000000..301c115 --- /dev/null +++ b/package-lock.json @@ -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==" + } + } +} diff --git a/package.json b/package.json index 6520ef9..bf797cf 100644 --- a/package.json +++ b/package.json @@ -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 (https://coolaj86.com)", - "license": "MPL-2.0" + "license": "MPL-2.0", + "dependencies": { + "@root/hexdump": "^1.1.0" + } }