MCPcopy Create free account
hub / github.com/codetheweb/tuyapi / parseRecursive

Method parseRecursive

lib/message-parser.js:279–291  ·  view source on GitHub ↗

* Recursive function to parse * a series of packets. Perfer using * the parse() wrapper over using this * directly. * @private * @param {Buffer} buffer to parse * @param {Array} packets that have been parsed * @returns {Array. } array of parsed packets

(buffer, packets)

Source from the content-addressed store, hash-verified

277 * @returns {Array.<Packet>} array of parsed packets
278 */
279 parseRecursive(buffer, packets) {
280 const result = this.parsePacket(buffer);
281
282 result.payload = this.getPayload(result.payload);
283
284 packets.push(result);
285
286 if (result.leftover) {
287 return this.parseRecursive(result.leftover, packets);
288 }
289
290 return packets;
291 }
292
293 /**
294 * Given a buffer potentially containing

Callers 1

parseMethod · 0.95

Calls 2

parsePacketMethod · 0.95
getPayloadMethod · 0.95

Tested by

no test coverage detected