You are on page 1of 4

[

{
"id": "52841fae.b3c03",
"type": "tab",
"label": "Flow 2",
"disabled": false
},
{
"id": "e933f893.961458",
"type": "tab",
"label": "Flow 158"
},
{
"id": "21166c4a.dc5bc4",
"type": "inject",
"z": "52841fae.b3c03",
"name": "pavan kuamr",
"topic": "HI Pavna",
"payload": "Hi Pavan Kumar pavan kumar",
"payloadType": "str",
"repeat": "",
"crontab": "",
"once": true,
"x": 257,
"y": 199,
"wires": [
[
"6b4f9182.a4357",
"7669b1c3.e8af"
]
]
},
{
"id": "6b4f9182.a4357",
"type": "debug",
"z": "52841fae.b3c03",
"name": "",
"active": true,
"console": "false",
"complete": "payload",
"x": 584,
"y": 166,
"wires": []
},
{
"id": "7669b1c3.e8af",
"type": "function",
"z": "52841fae.b3c03",
"name": "Pavan Function",
"func": "var outputMsgs = [];\nvar wordMap = {};\nvar sentence =
msg.payload.replace(/[.,-\\/#!$%\\^&\\*;:{}=\\-_`~()]/g,\"\");\nsentence =
sentence.replace(/\\s{2,}/g,\" \");\nvar words = sentence.split(\" \");\nfor (var i
= 0; i < words.length; i++) {\n var lowerCaseWord = words[i].toLowerCase();\n if
(!wordMap[lowerCaseWord]) {\n wordMap[lowerCaseWord] = 1;\n } else {\n
wordMap[lowerCaseWord] = wordMap[lowerCaseWord] + 1;\n }\n}\nfor (var prop in
wordMap) {\n if( wordMap.hasOwnProperty( prop ) ) {\n outputMsgs.push({payload:
{word:prop,count:wordMap[prop],name:sentence}});\n }\n}\nreturn [outputMsgs];",
"outputs": 1,
"noerr": 0,
"x": 420,
"y": 300,
"wires": [
[
"9bd4dd5d.7d05c"
]
]
},
{
"id": "9bd4dd5d.7d05c",
"type": "debug",
"z": "52841fae.b3c03",
"name": "",
"active": true,
"console": "false",
"complete": "false",
"x": 584,
"y": 234,
"wires": []
},
{
"id": "ebc56346.e18f9",
"type": "inject",
"z": "e933f893.961458",
"name": "Json",
"topic": "JSONNODE",
"payload": "{\"name\":\"Mathan\",\"age\":28}",
"payloadType": "json",
"repeat": "",
"crontab": "",
"once": true,
"x": 291,
"y": 220,
"wires": [
[
"2471878c.916f69"
]
]
},
{
"id": "2471878c.916f69",
"type": "debug",
"z": "e933f893.961458",
"name": "outJSON",
"active": true,
"console": "false",
"complete": "payload",
"x": 681,
"y": 225,
"wires": []
},
{
"type": "tab",
"label": "Flow 1",
"id": "1e1452ef.487ebd"
},
{
"crontab": "",
"type": "inject",
"wires": [
[
"2471878c.916f68"
]
],
"payloadType": "json",
"payload": "{\"name\":\"Mathan\",\"age\":28}",
"once": true,
"repeat": "",
"name": "Json",
"x": 291,
"topic": "JSONNODE",
"y": 220,
"z": "1e1452ef.487ebd",
"id": "ebc56346.e18f1"
},
{
"wires": [],
"console": "false",
"name": "outJSON",
"x": 681,
"active": true,
"y": 225,
"z": "1e1452ef.487ebd",
"id": "2471878c.916f68",
"type": "debug",
"complete": "payload"
},
{
"type": "tab",
"label": "Flow 159",
"id": "4a93f6be.005058"
},
{
"id": "ebc56346.e18f95",
"type": "inject",
"z": "4a93f6be.005058",
"name": "Json",
"topic": "JSONNODE",
"payload": "{\"name\":\"Mathan\",\"age\":28}",
"payloadType": "json",
"repeat": "",
"crontab": "",
"once": true,
"x": 291,
"y": 220,
"wires": [
[
"2471878c.916f69"
]
]
},
{
"id": "2471878c.916f695",
"type": "debug",
"z": "4a93f6be.005058",
"name": "outJSON",
"active": true,
"console": "false",
"complete": "payload",
"x": 681,
"y": 225,
"wires": []
}
]

You might also like