UNPKG

node-red-contrib-time-converter

Version:

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

27 lines (22 loc) 872 B
module.exports = function(RED) { function AsciiToDecNode(config) { RED.nodes.createNode(this, config); const node = this; node.on("input", function(msg, send, done) { try { let str = String(msg.payload); while (str.length < 128) { // 4 * 32 str += '0'; } msg.payload = str.split('').map(c => c.charCodeAt(0)); msg.topic = `while(msg.payload.length<4*32){ msg.payload+='0' } msg.payload = msg.payload.split('').map(c => c.charCodeAt(0));`; send(msg); if (done) done(); } catch (err) { if (done) done(err); else node.error(err, msg); } }); } RED.nodes.registerType("ascii-to-dec", AsciiToDecNode); }