diff --git a/src/structure.js b/src/structure.js index 4b02783..dcf7ab1 100644 --- a/src/structure.js +++ b/src/structure.js @@ -8,7 +8,13 @@ var fieldSize = require('./fieldsize'), * @returns {Object} view */ module.exports = function structure(data, meta) { - + if(meta){ + // + meta.forEach(x => { + if (x.type == 'D') x.size = 8 + if (x.type == 'L') x.size = 1 + }); + } var field_meta = meta || fields.multi(data), fieldDescLength = (32 * field_meta.length) + 1, bytesPerRecord = fields.bytesPer(field_meta), // deleted flag @@ -52,7 +58,7 @@ module.exports = function structure(data, meta) { view.setInt8(32 + i * 32 + 11, f.type.charCodeAt(0)); // field length view.setInt8(32 + i * 32 + 16, f.size); - if (f.type == 'N') view.setInt8(32 + i * 32 + 17, 3); + if (f.type == 'N') view.setInt8(32 + i * 32 + 17, f.decs || 0); // include decimals }); offset = fieldDescLength + 32; @@ -68,7 +74,7 @@ module.exports = function structure(data, meta) { switch (f.type) { // boolean case 'L': - view.setUint8(offset, val ? 84 : 70); + view.setUint8(offset, val == 't' ? 84 : 70); offset++; // it only evaluates that val is not empty, it could be if it is true if val=='t', otherwise all false offset++; break;