index.js (1076B)
1 /* This Source Code Form is subject to the terms of the Mozilla Public 2 * License, v. 2.0. If a copy of the MPL was not distributed with this 3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 4 5 "use strict"; 6 7 const frameModule = require("resource://devtools/client/netmonitor/src/components/messages/parsers/stomp/frame.js"); 8 const { 9 Parser, 10 } = require("resource://devtools/client/netmonitor/src/components/messages/parsers/stomp/parser.js"); 11 const { 12 parseJSON, 13 } = require("resource://devtools/client/netmonitor/src/utils/request-utils.js"); 14 15 const { Frame } = frameModule; 16 17 function parseStompJs(message) { 18 let output; 19 20 function onFrame(rawFrame) { 21 const frame = Frame.fromRawFrame(rawFrame); 22 const { error, json } = parseJSON(frame.body); 23 24 output = { 25 command: frame.command, 26 headers: frame.headers, 27 body: error ? frame.body : json, 28 }; 29 } 30 const onIncomingPing = () => {}; 31 const parser = new Parser(onFrame, onIncomingPing); 32 33 parser.parseChunk(message); 34 35 return output; 36 } 37 38 module.exports = { 39 parseStompJs, 40 };