update builder function
This commit is contained in:
parent
95ea9ffa34
commit
b6769f3734
1 changed files with 8 additions and 4 deletions
12
lib/asn1.js
12
lib/asn1.js
|
@ -153,7 +153,7 @@ ASN1._stringify = function(asn1) {
|
||||||
ASN1.tpl = function (asn1) {
|
ASN1.tpl = function (asn1) {
|
||||||
//console.log(JSON.stringify(asn1, null, 2));
|
//console.log(JSON.stringify(asn1, null, 2));
|
||||||
//console.log(asn1);
|
//console.log(asn1);
|
||||||
var ws = '';
|
var ws = '\t';
|
||||||
var i = 0;
|
var i = 0;
|
||||||
var vars = [];
|
var vars = [];
|
||||||
var str = ws;
|
var str = ws;
|
||||||
|
@ -177,12 +177,12 @@ ASN1.tpl = function (asn1) {
|
||||||
if (0x05 !== asn1.type) {
|
if (0x05 !== asn1.type) {
|
||||||
if (0x06 !== asn1.type) {
|
if (0x06 !== asn1.type) {
|
||||||
val = Buffer.from(asn1.value || '');
|
val = Buffer.from(asn1.value || '');
|
||||||
vars.push("// 0x" + Enc.numToHex(val.byteLength) + " (" + val.byteLength + " bytes)\nvar tpl" + i + " = '"
|
vars.push("// 0x" + Enc.numToHex(val.byteLength) + " (" + val.byteLength + " bytes)\nopts.tpl" + i + " = '"
|
||||||
+ Enc.bufToHex(val) + "';");
|
+ Enc.bufToHex(val) + "';");
|
||||||
if (0x02 !== asn1.type && 0x03 !== asn1.type) {
|
if (0x02 !== asn1.type && 0x03 !== asn1.type) {
|
||||||
str += ", ";
|
str += ", ";
|
||||||
}
|
}
|
||||||
str += "tpl" + i;
|
str += "opts.tpl" + i;
|
||||||
} else {
|
} else {
|
||||||
str += ", " + Enc.bufToHex(asn1.value);
|
str += ", " + Enc.bufToHex(asn1.value);
|
||||||
}
|
}
|
||||||
|
@ -200,8 +200,12 @@ ASN1.tpl = function (asn1) {
|
||||||
}
|
}
|
||||||
|
|
||||||
write(asn1);
|
write(asn1);
|
||||||
|
console.log('var opts = {};');
|
||||||
console.log(vars.join('\n') + '\n');
|
console.log(vars.join('\n') + '\n');
|
||||||
console.log(str + ';');
|
console.log();
|
||||||
|
console.log('function buildSchema(opts) {');
|
||||||
|
console.log('\treturn ' + str.slice(3) + ';');
|
||||||
|
console.log('}');
|
||||||
};
|
};
|
||||||
|
|
||||||
module.exports = ASN1;
|
module.exports = ASN1;
|
||||||
|
|
Loading…
Reference in a new issue