UNPKG

@onereach/orest-input-cli

Version:

The tool for creating, serving, and publishing OREST Inputs

23 lines (18 loc) 550 B
const itemSizeBytes = 4; function unpackFromBuffer(buffer) { const hashedList = buffer instanceof Buffer ? buffer : Buffer.from(buffer, 'base64'); const resultList = []; let offset = 0; while (offset < hashedList.length) { const itemLength = hashedList.readUInt32BE(offset); const item = hashedList.slice( offset + itemSizeBytes, offset + itemSizeBytes + itemLength ); resultList.push(item); offset += itemSizeBytes + itemLength; } return resultList; } exports.unpackFromBuffer = unpackFromBuffer;