Here is my flow...
[{"id":"8e9492af.b9b2f","type":"subflow","name":"FIFO","info":"# FIFO\n## First in First Out subflow\nThis flow receives a series of msg.payloads and builds a queue using FIFO (First in First out) method. The LIFO size is configurabe through subflow enviroment variables.\n\n### Input\n`msg.topic == put`\nWill add the `msg.payload` to the end of the array. Everytime a new item is received the second output sends the complete queue.\n\n`msg.topic == get`\nWill remove the first item of the stack and will send it in the first output\n\n`msg.topic == list`\nSends the complete list on the second output.\n\n### Output 1\nThe first item on the top of the stack. It is sent only when `msg.topic == get`.\n\n### Output 2\nThe complete queue in Array format. It is sent everytime a new item is added, removed or when `msg.topic == list`\n\n### Status\nAlways show the queue size.\n\n### Enviroment Variables\n`Buffer_Size` defines the size of the queue. If a new item arrives and the queue is full, the oldest item will be removed.","category":"","in":[{"x":140,"y":120,"wires":[{"id":"cb121310.2edaa"}]}],"out":[{"x":720,"y":60,"wires":[{"id":"e9e46f98.25b71","port":0}]},{"x":900,"y":100,"wires":[{"id":"90e47b30.5284b8","port":0}]}],"env":[{"name":"Buffer_Size","type":"num","value":"6"}],"color":"#DDAA99","icon":"font-awesome/fa-ellipsis-v","status":{"x":1040,"y":140,"wires":[{"id":"1756dadd.968eb5","port":0}]}},{"id":"cb121310.2edaa","type":"switch","z":"8e9492af.b9b2f","name":"Topic","property":"topic","propertyType":"msg","rules":[{"t":"eq","v":"get","vt":"str"},{"t":"eq","v":"put","vt":"str"},{"t":"eq","v":"list","vt":"str"}],"checkall":"true","repair":false,"outputs":3,"x":270,"y":120,"wires":[["e9e46f98.25b71"],["eef1a399.8dc"],["90e47b30.5284b8"]]},{"id":"eef1a399.8dc","type":"function","z":"8e9492af.b9b2f","name":"put","func":"var queue = flow.get(\"queue\")\n\n\nif (!Array.isArray(queue)){\n queue = [];\n}else if ( queue.length >= env.get(\"Buffer_Size\") ){\n queue.pop(1);\n}\n\nqueue.unshift(msg.payload);\n\nflow.set(\"queue\", queue);\nmsg.payload = queue;\n\nreturn msg;","outputs":1,"noerr":0,"x":550,"y":100,"wires":[[]]},{"id":"e9e46f98.25b71","type":"function","z":"8e9492af.b9b2f","name":"get","func":"var queue = flow.get(\"queue\")\nvar item;\n\nif (!Array.isArray(queue)){\n queue = [];\n}else{\n item = queue.pop(1);\n}\n\n\nflow.set(\"queue\", queue)\nmsg.payload = item;\n\nreturn msg;","outputs":1,"noerr":0,"x":550,"y":60,"wires":[[]]},{"id":"90e47b30.5284b8","type":"change","z":"8e9492af.b9b2f","name":"list","rules":[{"t":"set","p":"payload","pt":"msg","to":"queue","tot":"flow"}],"action":"","property":"","from":"","to":"","reg":false,"x":750,"y":140,"wires":[["1756dadd.968eb5"]]},{"id":"1756dadd.968eb5","type":"change","z":"8e9492af.b9b2f","name":"Count","rules":[{"t":"set","p":"payload","pt":"msg","to":"$count(msg.payload)\t","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":930,"y":140,"wires":[[]]},{"id":"1701644b.039a1c","type":"inject","z":"40696538.c8266c","name":"","topic":"","payload":"","payloadType":"date","repeat":"5","crontab":"","once":false,"onceDelay":0.1,"x":110,"y":100,"wires":[["1f0ffc91.b09ca3"]]},{"id":"1f0ffc91.b09ca3","type":"random","z":"40696538.c8266c","name":"","low":"1","high":"10","inte":"true","property":"payload","x":260,"y":100,"wires":[["f208ff83.d1a04"]]},{"id":"2ce6ce4a.a3be52","type":"subflow:8e9492af.b9b2f","z":"40696538.c8266c","name":"","env":[{"name":"Buffer_Size","value":"100","type":"num"}],"x":570,"y":100,"wires":[["4abf6729.57b3e8"],["5df798d7.465e38","88693d37.c9889","4e3654f8.e7785c"]]},{"id":"f208ff83.d1a04","type":"function","z":"40696538.c8266c","name":"Log_msg","func":"var res=msg.payload;\nmsg={\n \"topic\":\"put\",\n \"payload\":res\n}\nreturn msg;","outputs":1,"noerr":0,"x":420,"y":100,"wires":[["2ce6ce4a.a3be52"]]},{"id":"4abf6729.57b3e8","type":"debug","z":"40696538.c8266c","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":730,"y":80,"wires":[]},{"id":"7893fd80.cfdec4","type":"inject","z":"40696538.c8266c","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":280,"y":320,"wires":[["4e3654f8.e7785c"]]},{"id":"4e3654f8.e7785c","type":"function","z":"40696538.c8266c","name":"Reset_Buffer","func":"var arr=msg.payload;\nfor(let i=0;i<arr.length;i++)\n{\n msg={\n \"topic\":\"get\"\n }\n node.send(msg);\n}\nreturn;\n ","outputs":1,"noerr":0,"x":570,"y":280,"wires":[["2ce6ce4a.a3be52"]]},{"id":"5df798d7.465e38","type":"debug","z":"40696538.c8266c","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":730,"y":140,"wires":[]},{"id":"88693d37.c9889","type":"function","z":"40696538.c8266c","name":"Calculation","func":"var arr=msg.payload;\n//var arr = [3, 6, 2, 56, 32, 5, 89, 32];\nvar largest1 = arr[0];\n\nfor (let i = 0; i < arr.length; i++) {\n if (largest1 < arr[i] ) {\n largest1 = arr[i];\n }\n}\n\nmsg.payload=\n{\n \"Topic\": \"Max_Temp\",\n \"Temp\": largest1\n}\nreturn msg;","outputs":1,"noerr":0,"x":750,"y":220,"wires":[["114b798a.9a2186"]]},{"id":"114b798a.9a2186","type":"debug","z":"40696538.c8266c","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":710,"y":340,"wires":[]},{"id":"545a639b.9c7cfc","type":"inject","z":"40696538.c8266c","name":"","topic":"list","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":250,"y":200,"wires":[["2ce6ce4a.a3be52"]]}]```