UNPKG

node-red-contrib-time-converter

Version:

A Node-RED node that converts seconds to mm:ss format and outputs it.

29 lines (24 loc) 962 B
module.exports = function(RED) { function HexToDecNode(config) { RED.nodes.createNode(this, config); const node = this; node.on("input", function(msg, send, done) { try { let hexStr = String(msg.payload); while (hexStr.length < 64) { // 2*32 hexStr += '0'; } const g = hexStr.match(/.{2}/g) || []; msg.payload = g.map(hex => parseInt(hex, 16)); // Debug info msg.topic = `while(msg.payload.length<2*32){msg.payload+='0'}; let g=msg.payload.match(/.{2}/g); msg.payload=g.map(hex=>parseInt(hex,16))`; send(msg); if (done) done(); } catch (err) { if (done) done(err); else node.error(err, msg); } }); } RED.nodes.registerType("hex-to-dec", HexToDecNode); }