I just published this module. Initially I was looking for existing solution in npm but all the available ones either didn't work for me or they were just too complicated for the most common use cases. I decided to write my own which I used in one of our projects and I realized that it might be useful for more people so I created a module out of it.
You can find the code here
Feedback is always welcome :)