Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

hexdump.js

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

hexdump.js - npm Package Compare versions

Comparing version 1.0.4 to 1.0.5

12

bin/cli.js

@@ -8,5 +8,6 @@ #!/usr/bin/env node

var fs = require('fs');
var opts = {};
if (!fsname || '--help' === fs || '-h' === fs) {
console.error('Usage: hexdump.js <filepath>');
if (!fsname || '--help' === fsname || '-h' === fsname) {
console.error('Usage: hexdump.js -C <filepath>');
process.exit(2);

@@ -16,2 +17,7 @@ return;

if ('-C' === fsname) {
opts.C = true;
fsname = process.argv[3];
}
try {

@@ -26,5 +32,5 @@ fs.statSync(fsname);

var nb = fs.readFileSync(fsname);
var str = hexdump(nb.buffer, nb.byteOffset, nb.byteLength);
var str = hexdump(nb.buffer, nb.byteOffset, nb.byteLength, opts);
console.log(str);
}());
(function (exports) {
'use strict';
exports.hexdump = function hexdump(ab, offset, len) {
exports.hexdump = function hexdump(ab, offset, len, opts) {
if (!opts) { opts = {}; }
var ui8 = new Uint8Array(ab.buffer || ab, offset || ab.byteOffset, len || ab.byteLength);

@@ -23,3 +24,17 @@ var bytecount = 0;

return lead + ' ' + str;
while (str.length < 48) {
str += ' ';
}
if (opts.C) {
return lead + ' ' + str + ' |' + str.replace(/ /g, '').match(/.{1,2}/g).map(function (ch) {
var c = String.fromCharCode(parseInt(ch, 16));
if (!/[ -~]/.test(c)) {
c = '.';
}
return c;
}).join('') + '|';
} else {
return lead + ' ' + str;
}
}).join('\n');

@@ -26,0 +41,0 @@

{
"name": "hexdump.js",
"version": "1.0.4",
"version": "1.0.5",
"description": "Like hexdump on *nix, but in JavaScript.",

@@ -14,3 +14,3 @@ "main": "hexdump.js",

"type": "git",
"url": "git@git.daplie.com:Daplie/hexdump.js.git"
"url": "https://git.coolaj86.com/coolaj86/hexdump.js.git"
},

@@ -17,0 +17,0 @@ "keywords": [

@@ -48,6 +48,6 @@ hexdump.js

# As a library
npm install --save 'git+https://git.daplie.com/Daplie/hexdump.js.git'
npm install --save 'git+https://git.coolaj86.com/coolaj86/hexdump.js.git'
# As a global CLI (useful on windows)
npm install --global 'git+https://git.daplie.com/Daplie/hexdump.js.git'
npm install --global 'git+https://git.coolaj86.com/coolaj86/hexdump.js.git'
```

@@ -64,1 +64,8 @@

```
API
---
```
hexdump(arrayBuffer, byteOffset, byteLength);
```
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc