You don't need JS code to do that. You can create a solution, export the flow, delete it (will cancel them) and then reimport the flow.