Comparing version 0.2.8 to 0.2.9
@@ -176,3 +176,3 @@ // # hexy.js -- utility to create hex dumps | ||
self.buffer = buffer // magic string conversion here? | ||
self.width = config.width || 16 | ||
self.width = parseInt(config.width) || 16 | ||
self.numbering = config.numbering == "none" ? "none" : "hex_bytes" | ||
@@ -260,3 +260,3 @@ | ||
case "fours": | ||
padlen = self.width*2 + self.width/2 | ||
padlen = self.width*2 + Math.floor(self.width/2) | ||
break | ||
@@ -329,3 +329,3 @@ case "twos": | ||
var rpad = function(s, len) { | ||
for (var n = len - s.length; n!=0; --n) { | ||
for (var n = len - s.length; n>0; --n) { | ||
if (self.html) { | ||
@@ -332,0 +332,0 @@ s += " " |
{ | ||
"name" : "hexy", | ||
"version" : "0.2.8", | ||
"version" : "0.2.9", | ||
"description" : "hexdump, binary pretty-printing", | ||
@@ -5,0 +5,0 @@ "author" : "Tim Becker <tim.becker@kuriositaet.de>", |
@@ -141,2 +141,3 @@ [![build status](https://secure.travis-ci.org/a2800276/hexy.js.png)](http://travis-ci.org/a2800276/hexy.js) | ||
* Michele Caini (https://github.com/skypjack) | ||
* Koen Houtman (https://github.com/automagisch) | ||
@@ -143,0 +144,0 @@ ## History |
22
test.js
@@ -104,2 +104,5 @@ var hexy = require("./hexy.js") | ||
console.log("failed:") | ||
console.log(hexy.hexy(should)) | ||
console.log(hexy.hexy(is)) | ||
console.log("==") | ||
console.log(should) | ||
@@ -169,2 +172,21 @@ console.log(is) | ||
// non numerical width | ||
failed += check(arr_e, hexy.hexy(arr, {width: "something"})) | ||
++total | ||
arr_e = `00000000: 0102 .. | ||
00000002: 030f .. | ||
` | ||
failed += check(arr_e, hexy.hexy(arr, {width: "2"})) | ||
++total | ||
arr_e = `00000000: 01 . | ||
00000001: 02 . | ||
00000002: 03 . | ||
00000003: 0f . | ||
` | ||
failed += check(arr_e, hexy.hexy(arr, {width: 1})) | ||
++total | ||
p("failed: "+failed+" of "+total) | ||
@@ -171,0 +193,0 @@ |
28233
580
157