You could use a trigger node and context storage for this
e.g.
[{"id":"06946e2ac3186460","type":"inject","z":"366a43adb328cf95","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":100,"y":640,"wires":[["8b8dbe0d1812b395"]]},{"id":"8b8dbe0d1812b395","type":"change","z":"366a43adb328cf95","name":"","rules":[{"t":"set","p":"count","pt":"flow","to":"1","tot":"num"}],"action":"","property":"","from":"","to":"","reg":false,"x":260,"y":640,"wires":[["bfdd439c7f41fc2a"]]},{"id":"bfdd439c7f41fc2a","type":"trigger","z":"366a43adb328cf95","name":"","op1":"count","op2":"count","op1type":"flow","op2type":"flow","duration":"1","extend":false,"overrideDelay":false,"units":"s","reset":"10","bytopic":"all","topic":"topic","outputs":2,"x":460,"y":640,"wires":[["ce7726e99ee0e4c0"],["78aeaa0f29ffe286"]]},{"id":"78aeaa0f29ffe286","type":"change","z":"366a43adb328cf95","name":"","rules":[{"t":"set","p":"count","pt":"flow","to":"$$.payload+1","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":480,"y":700,"wires":[["bfdd439c7f41fc2a"]]},{"id":"ce7726e99ee0e4c0","type":"debug","z":"366a43adb328cf95","name":"debug 92","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":680,"y":640,"wires":[]}]
To see flow example, Copy code, press ctrl i
in editor, paste code and import.
Set to count to 10, to change this set reset trigger if msg.payload = 100, in the trigger node.