unexpected
Advanced tools
Comparing version 4.0.4 to 4.0.5
@@ -314,11 +314,14 @@ /*global Uint8Array, Uint16Array*/ | ||
function getHexDumpLinesForBufferLikeObject(obj, width, digitWidth) { | ||
function getHexDumpLinesForBufferLikeObject(obj, width, digitWidth, maxLength) { | ||
digitWidth = digitWidth || 2; | ||
var hexDumpLines = []; | ||
if (typeof maxLength === 'undefined') { | ||
maxLength = obj.length; | ||
} | ||
if (typeof width !== 'number') { | ||
width = 16; | ||
} else if (width === 0) { | ||
width = obj.length; | ||
width = maxLength; | ||
} | ||
for (var i = 0 ; i < obj.length ; i += width) { | ||
for (var i = 0 ; i < maxLength ; i += width) { | ||
var hexChars = '', | ||
@@ -328,3 +331,3 @@ asciiChars = ' |'; | ||
for (var j = 0 ; j < width ; j += 1) { | ||
if (i + j < obj.length) { | ||
if (i + j < maxLength) { | ||
var octet = obj[i + j]; | ||
@@ -348,11 +351,17 @@ hexChars += leftPad(octet.toString(16).toUpperCase(), digitWidth, '0') + ' '; | ||
function inspectBufferLikeObject(output, buffer, digitWidth) { | ||
var maxLength = 20; | ||
function inspectBufferLikeObject(output, buffer, digitWidth, maxLength) { | ||
if (typeof maxLength !== 'number') { | ||
maxLength = 20; | ||
} | ||
if (buffer.length > maxLength) { | ||
output.text(getHexDumpLinesForBufferLikeObject(buffer.slice(0, maxLength), 0, digitWidth)) | ||
output.text(getHexDumpLinesForBufferLikeObject(buffer, 0, digitWidth, maxLength)) | ||
.text(' (+').text(buffer.length - maxLength).text(')'); | ||
} else { | ||
forEach(getHexDumpLinesForBufferLikeObject(buffer, 0, digitWidth), function (line) { | ||
output.text(line).nl(); | ||
var hexDumpLines = getHexDumpLinesForBufferLikeObject(buffer, 0, digitWidth); | ||
forEach(hexDumpLines, function (line, i) { | ||
if (i > 0) { | ||
output.nl(); | ||
} | ||
output.text(line); | ||
}); | ||
@@ -383,5 +392,5 @@ } | ||
inspect: function (output, buffer) { | ||
return output.text('[Buffer ') | ||
.append(inspectBufferLikeObject(buffer)) | ||
.text(']'); | ||
output.text('[Buffer '); | ||
inspectBufferLikeObject(output, buffer); | ||
return output.text(']'); | ||
}, | ||
@@ -404,5 +413,5 @@ toJSON: function (buffer) { | ||
inspect: function (output, uint8Array) { | ||
return output.text('[Uint8Array ') | ||
.append(inspectBufferLikeObject(uint8Array)) | ||
.text(']'); | ||
output.text('[Uint8Array '); | ||
inspectBufferLikeObject(output, uint8Array); | ||
return output.text(']'); | ||
}, | ||
@@ -426,9 +435,9 @@ toJSON: function (uint8Array) { | ||
inspect: function (output, uint16Array) { | ||
return output.text('[Uint16Array ') | ||
.append(inspectBufferLikeObject(uint16Array, 8, 4, false)) | ||
.text(']'); | ||
output.text('[Uint16Array '); | ||
inspectBufferLikeObject(output, uint16Array, 4); | ||
return output.text(']'); | ||
}, | ||
toJSON: function (uint16Array) { | ||
return { | ||
$Uint16Array: getHexDumpLinesForBufferLikeObject(uint16Array, 8, 4, false) | ||
$Uint16Array: getHexDumpLinesForBufferLikeObject(uint16Array, 8, 4) | ||
}; | ||
@@ -435,0 +444,0 @@ } |
{ | ||
"name": "unexpected", | ||
"version": "4.0.4", | ||
"version": "4.0.5", | ||
"author": "Sune Sloth Simonsen <sune@we-knowhow.dk>", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
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
478252
11681