I am trying to duplicate the join node in javascript as a learning exercise. I am trying to join a payload consisting of 2 buffers. I have a test env of:
My function node is:
var a= Buffer.from(msg.payload);
var b = Buffer.from(msg.payload);
var buf = Buffer.concat([a,b]);
msg = {payload: buf};
return msg;
I am getting the following results:
I suspect my function is only processing var a for each inject node and not waiting for both. I wonder if I need a loop function in order to pick up var b.
Here is the code for reference.
[{"id":"7853b54d4b445e37","type":"function","z":"4512ac95.5bc124","name":"","func":"var a= Buffer.from(msg.payload);\nvar b = Buffer.from(msg.payload);\nvar buf = Buffer.concat([a,b]);\nmsg = {payload: buf};\nreturn msg;\n\n","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":380,"y":820,"wires":[["270630966f5476f3"]]},{"id":"270630966f5476f3","type":"debug","z":"4512ac95.5bc124","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":590,"y":820,"wires":[]},{"id":"0a6178d1c6bfd378","type":"inject","z":"4512ac95.5bc124","name":"a","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"[82,49,124,48,124,109,101,116,101,114,32,49,46,115,114,99,61,67,79,68,45,35,49,46,110,117,109,61,49,35,49,46,110,97,109,61,77,73,67,80,69,65,75,35,49,46,108,111,119,61,45,49,53,48,46,48,35,49,46,104,105,61,50,48,46,48,35,49,46,100,101,115,99,61,83,105,103,110,97,108,32,115,116,114,101,110,103,116,104,32,111,102,32,77,73,67,32,111,117,116,112,117,116,32,105,110,32,67,79,68,69,67,35,49,46,117,110,105,116,61,100,66,70,83,35,49,46,102,112,115,61,52,48,35,50,46,115,114,99,61,67,79,68,45,35,50,46,110,117,109,61,50,35,50,46,110,97,109,61,77,73,67,35,50,46,108,111,119,61,45,49,53,48,46,48,35,50,46,104,105,61,50,48,46,48,35,50,46,100,101,115,99,61,65,118,101,114,97,103,101,32,83,105,103,110,97,108,32,115,116,114,101,110,103,116,104,32,111,102,32,77,73,67,32,111,117,112,117,116,32,105,110,32,67,79,68,69,67,35,50,46,117,110,105,116,61,100,66,70,83,35,50,46,102,112,115,61,50,48,35,51,46,115,114,99,61,84,88,45,35,51,46,110,117,109,61,53,35,51,46,110,97,109,61,72,87,65,76,67,35,51,46,108,111,119,61,45,49,53,48,46,48,35,51,46,104,105,61,50,48,46,48,35,51,46,100,101,115,99,61,86,111,108,116,97,103,101,32,112,114,101,115,101,110,116,32,97,116,32,116,104,101,32,72,97,114,100,119,97,114,101,32,65,76,67,32,82,67,65,32,80,108,117,103,35,51,46,117,110,105,116,61,100,66,70,83,35,51,46,102,112,115,61,50,48,35,52,46,115,114,99,61,82,65,68,35,52,46,110,117,109,61,51,51,52,35,52,46,110,97,109,61,43,49,51,46,56,65,35,52,46,108,111,119,61,49,48,46,53,35,52,46,104,105,61,49,53,46,48,35,52,46,100,101,115,99,61,77,97,105,110,32,114,97,100,105,111,32,105,110,112,117,116,32,118,111,108,116,97,103,101,32,97,116,32,80,65,35,52,46,117,110,105,116,61,86,111,108,116,115,35,52,46,102,112,115,61,48,35,53,46,115,114,99,61,82,65,68,35,53,46,110,117,109,61,48,35,53,46,110,97,109,61,43,49,51,46,56,66,35,53,46,108,111,119,61,49,48,46,53,35,53,46,104,105,61,49,53,46,48,35,53,46,100,101,115,99,61,77,97,105,110,32,114,97,100,105,111,32,105,110,112,117,116,32,118,111,108,116,97,103,101,32,97,116,32,67,80,85,32,40,99,111,110,116,105,110,117,111,117,115,41,35,53,46,117,110,105,116,61,86,111,108,116,115,35,53,46,102,112,115,61,48,35,54,46,115,114,99,61,82,65,68,35,54,46,110,117,109,61,51,35,54,46,110,97,109,61,77,65,73,78,70,65,78,35,54,46,108,111,119,61,48,46,48,35,54,46,104,105,61,56,49,57,50,46,48,35,54,46,100,101,115,99,61,77,97,105,110,32,114,97,100,105,111,32,102,97,110,32,82,80,77,35,54,46,117,110,105,116,61,82,80,77,35,54,46,102,112,115,61,48,35,55,46,115,114,99,61,84,88,45,35,55,46,110,117,109,61,49,35,55,46,110,97,109,61,70,87,68,80,87,82,35,55,46,108,111,119,61,48,46,48,35,55,46,104,105,61,53,51,46,48,35,55,46,100,101,115,99,61,82,70,32,80,111,119,101,114,32,70,111,114,119,97,114,100,35,55,46,117,110,105,116,61,100,66,109,35,55,46,102,112,115,61,50,48,35,56,46,115,114,99,61,84,88,45,35,56,46,110,117,109,61,50,35,56,46,110,97,109,61,82,69,70,80,87,82,35,56,46,108,111,119,61,48,46,48,35,56,46,104,105,61,53,51,46,48,35,56,46,100,101,115,99,61,82,70,32,80,111,119,101,114,32,82,101,102,108,101,99,116,101,100,35,56,46,117,110,105,116,61,100,66,109,35,56,46,102,112,115,61,50,48,35,57,46,115,114,99,61,84,88,45,35,57,46,110,117,109,61,51,35,57,46,110,97,109,61,83,87,82,35,57,46,108,111,119,61,49,46,48,35,57,46,104,105,61,57,57,57,46,48,35,57,46,100,101,115,99,61,82,70,32,83,87,82,35,57,46,117,110,105,116,61,83,87,82,35,57,46,102,112,115,61,50,48,35,49,48,46,115,114,99,61,84,88,45,35,49,48,46,110,117,109,61,52,35,49,48,46,110,97,109,61,80,65,84,69,77,80,35,49,48,46,108,111,119,61,48,46,48,35,49,48,46,104,105,61,49,48,48,46,48,35,49,48,46,100,101,115,99,61,80,65,32,84,101,109,112,101,114,97,116,117,114,101,35,49,48,46,117,110,105,116,61,100,101,103,67,35,49,48,46,102,112,115,61,48,35,49,49,46,115,114,99,61,83,76,67,35,49,49,46,110,117,109,61,48,35,49,49,46,110,97,109,61,50,52,107,72,122,35,49,49,46,108,111,119,61,45,49,52,48,46,48,35,49,49,46,104,105,61,50,48,46,48,35,49,49,46,100,101,115,99,61,50,52,107,72,122,32,98,114,111,97,100,98,97,110,100,32,115,108,105,99,101,32,114,101,99,101,105,118,101,114,32,115,105,103,110,97,108,32,108,101,118,101,108,35,49,49,46,117,110,105,116,61,100,66,70,83,35,49,49,46,102,112,115,61,49,48,35,49,50,46,115,114,99,61,83,76,67,35,49,50,46,110,117,109,61,48,35,49,50,46,110,97,109,61,79,83,67,35,49,50,46,108,111,119,61,45,49,52,48,46,48,35,49,50,46,104,105,61,50,48,46,48,35,49,50,46,100,101,115,99,61,83,105,103,110,97,108,32,83,116,114,101,110,103,116,104,32,97,102,116,101,114,32,79,83,67,35,49,50,46,117,110,105,116,61,100,66,70,83,35,49,50,46,102,112,115,61,49,48,35,49,51,46,115,114,99,61,83,76,67,35,49,51,46,110,117,109,61,48,35,49,51,46,110,97,109,61,76,69,86,69,76,35,49,51,46,108,111,119,61,45,49,53,48,46,48,35,49,51,46,104,105,61,50,48,46,48,35,49,51,46,100,101,115,99,61,83,105,103,110,97,108,32,115,116,114,101,110,103,116,104,32,111,102,32,115,105,103,110,97,108,115,32,105,110,32,116,104,101,32,102,105,108,116,101,114,32,112,97,115,115,98,97,110,100,35,49,51,46,117,110,105,116,61,100,66,109,35,49,51,46,102,112,115,61,49,48,35,49,52,46,115,114,99,61,83,76,67,35,49,52,46,110,117,109,61,48,35,49,52,46,110,97,109,61,78,82,47,65,78,70,35,49,52,46,108,111,119,61,45,49,53,48,46,48,35,49,52,46,104,105,61,50,48,46,48,35,49,52,46,100,101,115,99,61,83,105,103,110,97,108,32,115,116,114,101,110,103,116,104,32,97,102,116,101,114,32,78,82,47,65,78,70,35,49,52,46,117,110,105,116,61,100,66,109,35,49,52,46,102,112,115,61,49,48,35,49,53,46,115,114,99,61,83,76,67,35,49,53,46,110,117,109,61,48,35,49,53,46,110,97,109,61,65,71,67,43,35,49,53,46,108,111,119,61,45,49,53,48,46,48,35,49,53,46,104,105,61,48,46,48,35,49,53,46,100,101,115,99,61,83,105,103,110,97,108,32,115,116,114,101,110,103,116,104,32,97,102,116,101,114,32,65,71,67,35,49,53,46,117,110,105,116,61,100,66,70,83,35,49,53,46,102,112,115,61,49,48,35,49,54,46,115,114,99,61,84,88,45,35,49,54,46,110,117,109,61,56,35,49,54,46,110,97,109,61,67,79,68,69,67,35,49,54,46,108,111,119,61,45,49,53,48,46,48,35,49,54,46,104,105,61,50,48,46,48,35,49,54,46,100,101,115,99,61,83,105,103,110,97,108,32,115,116,114,101,110,103,116,104,32,111,102,32,67,79,68,69,67,32,111,117,116,112,117,116,35,49,54,46,117,110,105,116,61,100,66,70,83,35,49,54,46,102,112,115,61,49,48,35,49,55,46,115,114,99,61,84,88,45,35,49,55,46,110,117,109,61,56,35,49,55,46,110,97,109,61,83,67,95,77,73,67,35,49,55,46,108,111,119,61,45,49,53,48,46,48,35,49,55,46,104,105,61,50,48,46,48,35,49,55,46,100,101,115,99,61,83,105,103,110,97,108,32,115,116,114,101,110,103,116,104,32,111,102,32,77,73,67,32,111,117,116,112,117,116,35,49,55,46,117,110,105,116,61,100,66,70,83,35,49,55,46,102,112,115,61,49,48,35,49,56,46,115,114,99,61,84,88,45,35,49,56,46,110,117,109,61,56,35,49,56,46,110,97,109,61,67,79,77,80,80,69,65,75,35,49,56,46,108,111,119,61,45,49,53,48,46,48,35,49,56,46,104,105,61,50,48,46,48,35,49,56,46,100,101,115,99,61,83,105,103,110,97,108,32,115,116,114,101,110,103,116,104,32,111,102,32,115,105,103,110,97,108,115,32,97,102,116,101,114,32,116,104,101,32,67,76,73,80,80,69,82,32,40,67,111,109,112,114,101,115,115,105,111,110,41,35,49,56,46,117,110,105,116,61,100,66,70,83,35,49,56,46,102,112,115,61,50,48,35,49,57,46,115,114,99,61,84,88,45,35,49,57,46,110,117,109,61,56,35,49,57,46,110,97,109,61,83,67,95,70,73,76,84,95,49,35,49,57,46,108,111,119,61,45,49,53,48,46,48,35,49,57,46,104,105,61,50,48,46,48,35,49,57,46,100,101,115,99,61,83,105,103,110,97,108,32,115,116,114,101,110,103,116,104,32,97,102,116,101,114,32,70,105,108,116,101,114,32,49,35,49,57,46,117,110,105,116,61,100,66,70,83,35,49,57,46,102,112,115,61,49,48,35,50,48,46,115,114,99,61,84,88,45,35,50,48,46,110,117,109,61,56,35,50,48,46,110,97,109,61,65,76,67,35,50,48,46,108,111,119,61,45,49,53,48,46,48,35,50,48,46,104,105,61,50,48,46,48,35,50,48,46,100,101,115,99,61,83,105,103,110,97,108,32,115,116,114,101,110,103,116,104,32,111,102,32,115,105,103,110,97,108,115,32,97,102,116,101,114,32,83,87,32,65,76,67,32,40,83,83,66,32,80,101,97,107,41,35,50,48,46,117,110,105,116,61,100,66,70,83,35,50,48,46,102,112,115,61,49,48,35,50,49,46,115,114,99,61,84,88,45,35,50,49,46,110,117,109,61,56,35,50,49,46,110,97,109,61,80,82,69,95,87,65,86,69,95,65,71,67,35,50,49,46,108,111,119,61,45,49,53,48,46,48,35,50,49,46,104,105,61,50,48,46,48,35,50,49,46,100,101,115,99,61,83,105,103,110,97,108,32,115,116,114,101,110,103,116,104,32,98,101,102,111,114,101,32,87,97,118,101,102,111,114,109,32,65,71,67,35,50,49,46,117,110,105,116,61,100,66,70,83,35,50,49,46,102,112,115,61,49,48]","payloadType":"bin","x":210,"y":800,"wires":[["7853b54d4b445e37"]]},{"id":"e9720adfb13ce577","type":"inject","z":"4512ac95.5bc124","name":"b","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"[45,35,50,53,46,110,117,109,61,56,35,50,53,46,110,97,109,61,65,70,82,65,77,80,35,50,53,46,108,111,119,61,45,49,53,48,46,48,35,50,53,46,104,105,61,50,48,46,48,35,50,53,46,100,101,115,99,61,83,105,103,110,97,108,32,115,116,114,101,110,103,116,104,32,111,102,32,115,105,103,110,97,108,115,32,97,102,116,101,114,32,116,104,101,32,114,97,109,112,35,50,53,46,117,110,105,116,61,100,66,70,83,35,50,53,46,102,112,115,61,49,48,35,50,54,46,115,114,99,61,84,88,45,35,50,54,46,110,117,109,61,56,35,50,54,46,110,97,109,61,80,79,83,84,95,80,35,50,54,46,108,111,119,61,45,49,53,48,46,48,35,50,54,46,104,105,61,48,46,48,35,50,54,46,100,101,115,99,61,83,105,103,110,97,108,32,115,116,114,101,110,103,116,104,32,97,102,116,101,114,32,97,108,108,32,112,114,111,99,101,115,115,105,110,103,32,105,115,32,100,111,110,101,32,98,117,116,32,98,101,102,111,114,101,32,97,116,116,101,110,117,97,116,105,111,110,32,102,111,114,32,112,111,119,101,114,32,99,111,110,116,114,111,108,35,50,54,46,117,110,105,116,61,100,66,70,83,35,50,54,46,102,112,115,61,49,48,35,50,55,46,115,114,99,61,84,88,45,35,50,55,46,110,117,109,61,56,35,50,55,46,110,97,109,61,71,65,73,78,35,50,55,46,108,111,119,61,45,49,53,48,46,48,35,50,55,46,104,105,61,48,46,48,35,50,55,46,100,101,115,99,61,83,105,103,110,97,108,32,115,116,114,101,110,103,116,104,32,97,102,116,101,114,32,71,97,105,110,35,50,55,46,117,110,105,116,61,100,66,70,83,35,50,55,46,102,112,115,61,49,48,35,10,45,35,50,53,46,110,117,109,61,56,35,50,53,46,110,97,109,61,65,70,82,65,77,80,35,50,53,46,108,111,119,61,45,49,53,48,46,48,35,50,53,46,104,105,61,50,48,46,48,35,50,53,46,100,101,115,99,61,83,105,103,110,97,108,32,115,116,114,101,110,103,116,104,32,111,102,32,115,105,103,110,97,108,115,32,97,102,116,101,114,32,116,104,101,32,114,97,109,112,35,50,53,46,117,110,105,116,61,100,66,70,83,35,50,53,46,102,112,115,61,49,48,35,50,54,46,115,114,99,61,84,88,45,35,50,54,46,110,117,109,61,56,35,50,54,46,110,97,109,61,80,79,83,84,95,80,35,50,54,46,108,111,119,61,45,49,53,48,46,48,35,50,54,46,104,105,61,48,46,48,35,50,54,46,100,101,115,99,61,83,105,103,110,97,108,32,115,116,114,101,110,103,116,104,32,97,102,116,101,114,32,97,108,108,32,112,114,111,99,101,115,115,105,110,103,32,105,115,32,100,111,110,101,32,98,117,116,32,98,101,102,111,114,101,32,97,116,116,101,110,117,97,116,105,111,110,32,102,111,114,32,112,111,119,101,114,32,99,111,110,116,114,111,108,35,50,54,46,117,110,105,116,61,100,66,70,83,35,50,54,46,102,112,115,61,49,48,35,50,55,46,115,114,99,61,84,88,45,35,50,55,46,110,117,109,61,56,35,50,55,46,110,97,109,61,71,65,73,78,35,50,55,46,108,111,119,61,45,49,53,48,46,48,35,50,55,46,104,105,61,48,46,48,35,50,55,46,100,101,115,99,61,83,105,103,110,97,108,32,115,116,114,101,110,103,116,104,32,97,102,116,101,114,32,71,97,105,110,35,50,55,46,117,110,105,116,61,100,66,70,83,35,50,55,46,102,112,115,61,49,48,35,10]","payloadType":"bin","x":210,"y":860,"wires":[["7853b54d4b445e37"]]}]
Regards