Comparing version 0.2.2 to 0.2.3
35
hexy.js
@@ -114,3 +114,2 @@ //= hexy.js -- utility to create hex dumps | ||
// me directly (tim@kuriositaet.de). | ||
var hexy = function (buffer, config) { | ||
@@ -204,3 +203,5 @@ config = config || {} | ||
str+=" " | ||
str+=raw.replace(/[\000-\040\177-\377]/g, ".") | ||
var ascii = raw.replace(/[\000-\040\177-\377]/g, ".") | ||
if (self.html) {str += escape(ascii)} | ||
else { str += ascii } | ||
} | ||
@@ -237,3 +238,7 @@ if (self.html) { | ||
for (var i=0; i!=buffer.length; ++i) { | ||
str += pad(buffer[i], 2) | ||
if (buffer.constructor == String) { | ||
str += pad(buffer.charCodeAt(i), 2) | ||
} else { | ||
str += pad(buffer[i], 2) | ||
} | ||
} | ||
@@ -255,8 +260,28 @@ return str | ||
var rpad = function(s, len) { | ||
while(s.length < len) { | ||
s += " " | ||
for (var n = len - s.length; n!=0; --n) { | ||
if (self.html) { | ||
s += " " | ||
} else { | ||
s += " " | ||
} | ||
} | ||
// while(s.length < len) { | ||
// if (self.html) { | ||
// s += " " | ||
// } else { | ||
// s += " " | ||
// } | ||
// } | ||
return s | ||
} | ||
var escape = function (str) { | ||
str = str.split("&").join("&") | ||
str = str.split("<").join("<") | ||
str = str.split(">").join(">") | ||
return str | ||
} | ||
} | ||
@@ -263,0 +288,0 @@ /* |
{ | ||
"name" : "hexy", | ||
"version" : "0.2.2", | ||
"version" : "0.2.3", | ||
"description" : "hexdump, binary pretty-printing", | ||
@@ -5,0 +5,0 @@ "author" : "Tim Becker <tim.becker@kuriositaet.de>", |
34
test.js
var hexy = require("./hexy.js") | ||
buf = new Buffer("0123456789abcdefghijklmnopqrstuvwxzy") | ||
str = "0123456789abcdefghijklmnopqrstuvwxzy" | ||
var results = [ | ||
@@ -59,3 +59,3 @@ "00000000: 3031 3233 3435 3637 3839 6162 6364 6566 0123456789abcdef\n"+ | ||
"<div class='00000010 odd'>00000010: 6768 696a 6b6c 6d6e 6f70 7172 7374 7576 ghijklmnopqrstuv</div>\n"+ | ||
"<div class='00000020 even'>00000020: 7778 7a79 wxzy</div>\n"+ | ||
"<div class='00000020 even'>00000020: 7778 7a79 wxzy</div>\n"+ | ||
"</div>\n", | ||
@@ -98,4 +98,34 @@ ] | ||
++total | ||
failed += check(results[i], hexy.hexy(str, format[i])) | ||
++total | ||
} | ||
_00 = String.fromCharCode(0) | ||
_0000 = _00 + _00 | ||
_08 = String.fromCharCode(8) | ||
_40 = "@" | ||
_53 = "S" | ||
_5100 = "Q"+_00 | ||
var str2 = _00 + _00 + _08 + _40 + _53 + _00 + _0000 + _5100 + _0000 + _5100 + _0000 | ||
var xxd2 = "00000000: 0000 0840 5300 0000 5100 0000 5100 0000 ...@S...Q...Q...\n" | ||
failed += check(xxd2, hexy.hexy(str2)) | ||
++total | ||
str3 = "#include<stdio.h>\n" | ||
xxd3 = "00000000: 2369 6e63 6c75 6465 3c73 7464 696f 2e68 #include<stdio.h\n"+ | ||
"00000010: 3e0a >.\n" | ||
failed += check(xxd3, hexy.hexy(str3)) | ||
++total | ||
xxd4 = "<div class='hexy'>\n"+ | ||
"<div class='00000000 even'>00000000: 2369 6e63 6c75 6465 3c73 7464 696f 2e68 #include<stdio.h</div>\n"+ | ||
"<div class='00000010 odd'>00000010: 3e0a >.</div>\n"+ | ||
"</div>\n" | ||
failed += check(xxd4, hexy.hexy(str3, {html:true})) | ||
++total | ||
p("failed: "+failed+" of "+total) |
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
21320
466
0