* Parses a MessagePack frame into an array of values. * * How it works (array mode): * 1. Decodes the MessagePack data * 2. If it's an array, returns all elements * 3. If it's a single value, returns array with that value * * How it works (map mode): * 1. Decodes the MessagePack data (expect
(frame)
| 204 | * @returns {array} Array of decoded values |
| 205 | */ |
| 206 | function parse(frame) { |
| 207 | var result = decodeMessagePack(frame, 0); |
| 208 | var decoded = result.value; |
| 209 | |
| 210 | if (parseMode === "array") { |
| 211 | if (decoded instanceof Array) |
| 212 | return decoded; |
| 213 | return [decoded]; |
| 214 | } |
| 215 | |
| 216 | var parsedValues = new Array(numItems).fill(0); |
| 217 | |
| 218 | if (decoded && typeof decoded === "object" && !(decoded instanceof Array)) { |
| 219 | for (var key in decoded) { |
| 220 | if (decoded.hasOwnProperty(key) && keyToIndexMap.hasOwnProperty(key)) |
| 221 | parsedValues[keyToIndexMap[key]] = decoded[key]; |
| 222 | } |
| 223 | } |
| 224 | |
| 225 | return parsedValues; |
| 226 | } |
nothing calls this directly
no test coverage detected