What is the best Way to create a workflow which can be used to add/deploy other workflows

I am currently having a similar requirement where I need to create a workflow that can be used to deploy other workflows, if anyone has an idea or worked on it please do inform me (I am supposed to use mainly JavaScript as an inline or external task )