Have a play with this. You don’t need the function but just one change node:
[{"id":"2652ecbf.ebc88c","type":"inject","z":"20693e98.c7fb2a","name":"","topic":"","payload":"{\"pulse_2\":{\"value\":0}}","payloadType":"json","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":260,"y":820,"wires":[["b9a390ee.5e7d98"]]},{"id":"5f063935.ddf168","type":"inject","z":"20693e98.c7fb2a","name":"","topic":"","payload":"{\"pulse_2\":{\"value\":1}}","payloadType":"json","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":260,"y":900,"wires":[["b9a390ee.5e7d98"]]},{"id":"b9a390ee.5e7d98","type":"change","z":"20693e98.c7fb2a","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"payload.pulse_2.value","tot":"msg"},{"t":"change","p":"payload","pt":"msg","from":"0","fromt":"num","to":"false","tot":"bool"},{"t":"change","p":"payload","pt":"msg","from":"1","fromt":"num","to":"true","tot":"bool"}],"action":"","property":"","from":"","to":"","reg":false,"x":480,"y":860,"wires":[["c912584d.a2b9f"]]},{"id":"c912584d.a2b9f","type":"debug","z":"20693e98.c7fb2a","name":"true/false?","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","x":670,"y":860,"wires":[]}]
if you would want to do it in a function it would only be the function instead of the change node:
msg.payload = (msg.payload.pulse_2.value === 0) ? false : true;
return msg;
and no change node at all.