Comparing version 1.3.5 to 1.4.0
"use strict"; | ||
var extendInto = require('xtend/mutable'); | ||
var util = require('util'); | ||
var Transform = require('stream').Transform; | ||
var render = require('./render'); | ||
@@ -12,2 +14,4 @@ function HexTransform(options) { | ||
if (!options) options = {}; | ||
// istanbul ignore if | ||
if (options.colored) extendInto(options, render.coloredOptions); | ||
Transform.call(this, options); | ||
@@ -22,3 +26,4 @@ var self = this; | ||
self.decorateHuman = self.options.decorateHuman || noopDecorate; | ||
self.renderHuman = self.options.renderHuman || byte2char; | ||
self.renderHexen = self.options.renderHexen || render.byte2hex; | ||
self.renderHuman = self.options.renderHuman || render.byte2char; | ||
// istanbul ignore next | ||
@@ -74,4 +79,4 @@ self.groupSeparator = self.options.groupSeparator === undefined ? ' ' : self.options.groupSeparator; | ||
var self = this; | ||
var head = pad('0', self.totalOffset.toString(16), self.offsetWidth); | ||
self.line = self.prefix + pad(' ', head, self.gutter) + self.headSep; | ||
var head = render.pad('0', self.totalOffset.toString(16), self.offsetWidth); | ||
self.line = self.prefix + render.pad(' ', head, self.gutter) + self.headSep; | ||
}; | ||
@@ -104,3 +109,5 @@ | ||
var self = this; | ||
self._addPart(pad('0', b.toString(16), 2), self.renderHuman(b), b); | ||
var hexen = self.renderHexen(b); | ||
var human = self.renderHuman(b); | ||
self._addPart(hexen, human, b); | ||
}; | ||
@@ -123,16 +130,2 @@ | ||
function pad(c, s, width) { | ||
while (s.length < width) s = c + s; | ||
return s; | ||
} | ||
function byte2char(c) { | ||
if (c > 0x1f && c < 0x7f) { | ||
return String.fromCharCode(c); | ||
} else { | ||
return '.'; | ||
} | ||
// TODO: could provide perhaps some unicode renderings for certain control chars | ||
} | ||
function noopDecorate(offset, screenOffset, s) { | ||
@@ -139,0 +132,0 @@ return s; |
{ | ||
"name": "hexer", | ||
"version": "1.3.5", | ||
"version": "1.4.0", | ||
"description": "Hex Dumper (streaming, sync, and cli)", | ||
@@ -27,2 +27,3 @@ "keywords": [ | ||
"dependencies": { | ||
"ansi-color": "^0.2.1", | ||
"minimist": "^1.1.0", | ||
@@ -29,0 +30,0 @@ "process": "^0.10.0" |
@@ -128,2 +128,7 @@ # CLI Usage | ||
- renderHexen(byte): | ||
a function that accepts a byte value and returns a hexen readable, two | ||
character representation of that byte. | ||
By default, the hexen representation is lower-case zero-padded hex. | ||
- renderHuman(byte): | ||
@@ -148,2 +153,4 @@ a function that accepts a byte value and returns a human readable, single | ||
- colored: if set true, enables ANSI coloring of output | ||
## License and Copyright | ||
@@ -150,0 +157,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
32153
19
743
159
3
+ Addedansi-color@^0.2.1
+ Addedansi-color@0.2.1(transitive)