Could you write the code for the promisify() function that transforms callback-based functions into Promise-based ones in JavaScript?

Free for the first 3 answer contributors

Interview question asked to Frontend Engineers interviewing at Stripe, Tencent Games, Tencent and others: Could you write the code for the promisify() function that transforms callback-based functions into Promise-based ones in JavaScript?.