better temple output

This commit is contained in:
AJ ONeal 2018-11-22 22:53:10 -07:00
parent abce2cc95b
commit 70ba729899

View file

@ -163,23 +163,27 @@ ASN1.tpl = function (asn1) {
var val; var val;
if ('number' !== typeof k) { if ('number' !== typeof k) {
// ignore // ignore
} else if (k) {
str += ', ';
} else { } else {
str += ' '; str += ', ';
} }
if (0x02 === asn1.type) { if (0x02 === asn1.type) {
str += "ASN1.UInt("; str += "ASN1.UInt(";
} else if (0x03 === asn1.type) { } else if (0x03 === asn1.type) {
str += "ASN1.BitStr("; str += "ASN1.BitStr(";
} else { } else {
str += "ASN1('" + Enc.numToHex(asn1.type) + "', "; str += "ASN1('" + Enc.numToHex(asn1.type) + "'";
} }
if (!asn1.children) { if (!asn1.children) {
val = Buffer.from(asn1.value || ''); if (0x05 !== asn1.type) {
vars.push("// 0x" + Enc.numToHex(val.byteLength) + " (" + val.byteLength + " bytes)\nvar tpl" + i + " = '" val = Buffer.from(asn1.value || '');
vars.push("// 0x" + Enc.numToHex(val.byteLength) + " (" + val.byteLength + " bytes)\nvar tpl" + i + " = '"
+ Enc.bufToHex(val) + "';"); + Enc.bufToHex(val) + "';");
str += "tpl" + i + ")"; if (0x02 !== asn1.type && 0x03 !== asn1.type) {
str += ", ";
}
str += "tpl" + i;
}
str += ")";
return ; return ;
} }
asn1.children.forEach(function (a, j) { asn1.children.forEach(function (a, j) {