Loading homepage
Implement promisify(fn) to adapt an error-first, callback-last function into one that returns a Promise. The callback has the shape callback(error, value).
This lets callback-based operations work naturally with async/await while preserving the arguments and call-time context of the original operation.
Input: const add = (a, b, callback) => callback(null, a + b); const addAsync = promisify(add); await addAsync(2, 5); Output: 7
Input: const fail = (callback) => callback(new Error("Unavailable")); await promisify(fail)(); Output: Rejects with Error("Unavailable").
Input: const task = (callback) => callback(null); await promisify(task)(); Output: undefined
Use the same documented API in both language variants.