* Parses a key-value frame into an array of values. * * @param {string} frame - The key-value data from the data source * @returns {array} Array of values mapped according to keyToIndexMap
(frame)
| 42 | * @returns {array} Array of values mapped according to keyToIndexMap |
| 43 | */ |
| 44 | function parse(frame) { |
| 45 | const regex = /([\w]+)=([\d.]+)/g; |
| 46 | let match; |
| 47 | |
| 48 | while ((match = regex.exec(frame)) !== null) { |
| 49 | const key = match[1]; |
| 50 | const value = parseFloat(match[2]); |
| 51 | |
| 52 | if (keyToIndexMap.hasOwnProperty(key)) |
| 53 | parsedValues[keyToIndexMap[key]] = value; |
| 54 | } |
| 55 | |
| 56 | return parsedValues; |
| 57 | } |