Comparing version 1.2.1 to 1.3.0
@@ -27,2 +27,3 @@ "use strict"; | ||
self.emptyHuman = self.options.emptyHuman || ''; | ||
self.nullHuman = self.options.nullHuman || ''; | ||
self.offsetWidth = self.options.offsetWidth || 8; | ||
@@ -49,4 +50,3 @@ self.gutter = Math.max(self.offsetWidth, self.gutter); | ||
self._finishLine(); | ||
var head = pad('0', self.totalOffset.toString(16), self.offsetWidth); | ||
self.line = self.prefix + pad(' ', head, self.gutter) + self.headSep; | ||
self._startLine(); | ||
} | ||
@@ -60,8 +60,16 @@ self._addByte(chunk[offset]); | ||
var self = this; | ||
if (self.line.length) { | ||
self._finishLine(); | ||
if (self.totalOffset === 0 && self.nullHuman) { | ||
self._startLine(); | ||
self.human += self.nullHuman; | ||
} | ||
self._finishLine(); | ||
done(null); | ||
}; | ||
HexTransform.prototype._startLine = function startLine() { | ||
var self = this; | ||
var head = pad('0', self.totalOffset.toString(16), self.offsetWidth); | ||
self.line = self.prefix + pad(' ', head, self.gutter) + self.headSep; | ||
}; | ||
HexTransform.prototype._finishLine = function finishLine() { | ||
@@ -71,3 +79,3 @@ var self = this; | ||
var rem = self.screenOffset % self.cols; | ||
if (rem !== 0) { | ||
if (rem !== 0 || self.nullHuman) { | ||
rem = self.cols - rem; | ||
@@ -93,12 +101,12 @@ for (var i=0; i<rem; i++) { | ||
var self = this; | ||
self._addPart(pad('0', b.toString(16), 2), self.renderHuman(b)); | ||
self._addPart(pad('0', b.toString(16), 2), self.renderHuman(b), b); | ||
}; | ||
HexTransform.prototype._addPart = function addByte(hexen, human) { | ||
HexTransform.prototype._addPart = function addByte(hexen, human, b) { | ||
var self = this; | ||
if (hexen.length) { | ||
hexen = self.decorateHexen(self.totalOffset, self.screenOffset, hexen); | ||
hexen = self.decorateHexen(self.totalOffset, self.screenOffset, hexen, b); | ||
} | ||
if (human.length) { | ||
human = self.decorateHuman(self.totalOffset, self.screenOffset, human); | ||
human = self.decorateHuman(self.totalOffset, self.screenOffset, human, b); | ||
} | ||
@@ -105,0 +113,0 @@ var isStartOfRow = self.screenOffset % self.cols === 0; |
{ | ||
"name": "hexer", | ||
"version": "1.2.1", | ||
"version": "1.3.0", | ||
"description": "Hex Dumper (streaming, sync, and cli)", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
@@ -8,2 +8,7 @@ var test = require('tape'); | ||
assert.equal(hex(buf), ''); | ||
assert.equal(hex(buf, { | ||
nullHuman: 'DNE' | ||
}), | ||
'00: DNE', | ||
'empty with null accordance'); | ||
assert.end(); | ||
@@ -10,0 +15,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
15664
310