1
0
mirror of https://github.com/node-red/node-red.git synced 2023-10-10 13:36:53 +02:00
node-red/packages/node_modules/@node-red/nodes/examples/sequence/join/03 - Reduce sequence mode.json

1 line
7.2 KiB
JSON
Raw Permalink Normal View History

2020-06-18 03:41:36 +02:00
[{"id":"9279b993.ba7ed8","type":"comment","z":"8b096c24.cc6d7","name":"Example: Reduce Mode","info":"Join node can be used to reduce message sequence to single value. In reduce mode, reduce operation for a sequence can be described using JSONata expression with following special variables:\n- `$A`: the accumulated value,\n- `$I`: index of the message in the sequence,\n- `$N`: number of messages in the sequence.\n","x":150,"y":40,"wires":[]},{"id":"e415861b.d82e38","type":"inject","z":"8b096c24.cc6d7","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":200,"y":160,"wires":[["7c8a4816.500ed8"]]},{"id":"7c8a4816.500ed8","type":"template","z":"8b096c24.cc6d7","name":"data","field":"payload","fieldType":"msg","format":"json","syntax":"plain","template":"[\n 1,\n 2,\n 3,\n 4,\n 5,\n 6,\n 7,\n 8,\n 9,\n 10\n]","output":"json","x":350,"y":160,"wires":[["7f64da1f.611014"]]},{"id":"5fde318f.23897","type":"join","z":"8b096c24.cc6d7","name":"","mode":"reduce","build":"string","property":"payload","propertyType":"msg","key":"topic","joiner":",","joinerType":"str","accumulate":false,"timeout":"","count":"2","reduceRight":false,"reduceExp":"$A+payload","reduceInit":"0","reduceInitType":"num","reduceFixup":"$A/$N","x":630,"y":160,"wires":[["50977eaf.0490b"]]},{"id":"50977eaf.0490b","type":"debug","z":"8b096c24.cc6d7","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":790,"y":160,"wires":[]},{"id":"57bce4bf.38d02c","type":"comment","z":"8b096c24.cc6d7","name":"Calculate average of message sequence","info":"","x":240,"y":100,"wires":[]},{"id":"d33e73a8.5896","type":"comment","z":"8b096c24.cc6d7","name":"↑ split input array data into messages","info":"","x":590,"y":200,"wires":[]},{"id":"34482f62.61abd","type":"comment","z":"8b096c24.cc6d7","name":"↓ reduce sequence to average value","info":"","x":720,"y":120,"wires":[]},{"id":"7f64da1f.611014","type":"split","z":"8b096c24.cc6d7","name":"","splt":"\\n","spltType":"str","arraySplt":1,"arraySpltType":"len","stream":false,"addname":"","x":490,"y":160,"wires":[["5fde318f.23897"]]},{"id":"e051fd76.1af1e","type":"inject","z":"8b096c24.cc6d7","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":200,"y":320,"wires":[["14318520.397a9b"]]},{"id":"14318520.397a9b","type":"template","z":"8b096c24.cc6d7","name":"data","field":"payload","fieldType":"msg","format":"text","syntax":"plain","template":"Apple\nOrange\nBanana\nKiwi","output":"str","x":350,"y":320,"wires":[["41d85177.9b6f1"]]},{"id":"8fac92f8.0974c","type":"join","z":"8b096c24.cc6d7","name":"","mode":"reduce","build":"string","property":"payload","propertyType":"msg","key":"topic","joiner":",","joinerType":"str","accumulate":false,"timeout":"","count":"2","reduceRight":false,"reduceExp":"$append($A,[payload])","reduceInit":"[]","reduceInitType":"json","reduceFixup":"","x":630,"y":320,"wires":[["5bf98f81.6db17"]]},{"id":"5bf98f81.6db17","type":"debug","z":"8b096c24.cc6d7","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":790,"y":320,"wires":[]},{"id":"7dc61153.a9062","type":"comment","z":"8b096c24.cc6d7","name":"Convert message sequence to array","info":"","x":220,"y":260,"wires":[]},{"id":"7f14c8b2.d775f8","type":"comment","z":"8b096c24.cc6d7","name":"↑ split input text data into messages","info":"","x":580,"y":360,"wires":[]},{"id":"85a2470f.5b9ce8","type":"comment","z":"8b096c24.cc6d7","name":"↓ reduce sequence to arrray of payloads","info":"","x":740,"y":280,"wires":[]},{"id":"41d85177.9b6f1","type":"split","z":"8b096c24.cc6d7","name":"","splt":"\\n","spltType":"str","arraySplt":1,"arraySpltType":"len","stream":false,"addname":"","x":490,"y":320,"wires":[["8fac92f8.0974c"]]},{"id":"ec455af2.e31cb8","type":"inject","z":"8b096c24.cc6d7","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":200,"y":480,"wires":[["693a0274.e62d6c"]]},{"i