MCPcopy Create free account
hub / github.com/Serial-Studio/Serial-Studio / parse

Function parse

app/rcc/scripts/parser/js/messagepack.js:206–226  ·  view source on GitHub ↗

* 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)

Source from the content-addressed store, hash-verified

204 * @returns {array} Array of decoded values
205 */
206function 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}

Callers

nothing calls this directly

Calls 2

decodeMessagePackFunction · 0.85
fillMethod · 0.45

Tested by

no test coverage detected