Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 | 29x 6197x 6197x 6197x 2x 2x 6197x 3947x 3947x 6197x 1699x 1699x 6197x 549x 549x 6197x 6197x 6197x 6197x 29x 29x 29x 29x 29x 29x 29x 29x 29x 29x 29x 29x 29x 29x 29x 29x 29x 29x 696x 696x 696x 6840x 6197x 6197x 643x 643x 643x 6840x 6840x 696x 696x 29x 29x 29x 29x | const parseUIntLE = function(buffer, offset, size) { var result; switch(size) { case 1: result = buffer.readUInt8(offset); break; case 2: result = buffer.readUInt16LE(offset); break; case 4: result = buffer.readUInt32LE(offset); break; case 8: result = Number(buffer.readBigUInt64LE(offset)); break; default: throw new Error('Unsupported UInt LE size!'); } return result; } /** * Parses sequential unsigned little endian numbers from the head of the passed buffer according to * the specified format passed. If the buffer is not large enough to satisfy the full format, * null values will be assigned to the remaining keys. * @param {*} buffer The buffer to sequentially extract numbers from. * @param {*} format Expected format to follow when extrcting values from the buffer. A list of list entries * with the following structure: * [ * [ * <key>, // Name of the key to assign the extracted number to. * <size> // The size in bytes of the number to extract. possible values are 1, 2, 4, 8. * ], * ... * ] * @returns An object with keys set to their associated extracted values. */ const parse = function(buffer, format) { var result = {} var offset = 0; for(const [key, size] of format) { if(buffer.length >= offset + size) { result[key] = parseUIntLE(buffer, offset, size); } else { result[key] = null; } offset += size; } return result; } module.exports = { parse } |