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/3 reduce sequence mode.json
Hiroyasu Nishiyama 62c723866a fix typos
2020-06-18 10:41:36 +09:00

1 line
7.2 KiB
JSON

[{"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"]]},{"id":"693a0274.e62d6c","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":480,"wires":[["d8374d2d.34863"]]},{"id":"805c900a.c6b7c","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":true,"reduceExp":"$append($A,[payload])","reduceInit":"[]","reduceInitType":"json","reduceFixup":"","x":630,"y":480,"wires":[["f8be3623.b8e358"]]},{"id":"f8be3623.b8e358","type":"debug","z":"8b096c24.cc6d7","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":790,"y":480,"wires":[]},{"id":"88fe5fe0.b08ca","type":"comment","z":"8b096c24.cc6d7","name":"Convert message sequence to array in reverse order","info":"","x":270,"y":420,"wires":[]},{"id":"f95fff12.45fda","type":"comment","z":"8b096c24.cc6d7","name":"↑ split input text data into messages","info":"","x":580,"y":520,"wires":[]},{"id":"b7eecb8c.e6b858","type":"comment","z":"8b096c24.cc6d7","name":"↓ reduce sequence to arrray of payloads in reverse order","info":"","x":790,"y":440,"wires":[]},{"id":"d8374d2d.34863","type":"split","z":"8b096c24.cc6d7","name":"","splt":"\\n","spltType":"str","arraySplt":1,"arraySpltType":"len","stream":false,"addname":"","x":490,"y":480,"wires":[["805c900a.c6b7c"]]},{"id":"fb404773.0eb728","type":"inject","z":"8b096c24.cc6d7","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":200,"y":640,"wires":[["8139dcd5.2300d"]]},{"id":"8139dcd5.2300d","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":640,"wires":[["c6ff515e.f95fd"]]},{"id":"fcff950d.0f67c8","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,[{\t \"name\": payload,\t \"index\": $I\t}])","reduceInit":"[]","reduceInitType":"json","reduceFixup":"","x":630,"y":640,"wires":[["6d082a22.2fb214"]]},{"id":"6d082a22.2fb214","type":"debug","z":"8b096c24.cc6d7","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":790,"y":640,"wires":[]},{"id":"19daaf11.40d701","type":"comment","z":"8b096c24.cc6d7","name":"Convert message sequence to array of objects with name and index","info":"","x":320,"y":580,"wires":[]},{"id":"b60f900.592e47","type":"comment","z":"8b096c24.cc6d7","name":"↑ split input text data into messages","info":"","x":580,"y":680,"wires":[]},{"id":"62ffb2e1.28d8ec","type":"comment","z":"8b096c24.cc6d7","name":"↓ reduce sequence to arrray of objects","info":"","x":730,"y":600,"wires":[]},{"id":"c6ff515e.f95fd","type":"split","z":"8b096c24.cc6d7","name":"","splt":"\\n","spltType":"str","arraySplt":1,"arraySpltType":"len","stream":false,"addname":"","x":490,"y":640,"wires":[["fcff950d.0f67c8"]]}]