JSFiddle - React, Tailwind, and code Playground

JavaScript

function add1(n, callback) {
    setTimeout(function() {
        callback(null, n + 1);
    }, 10);
}

function mul3(n, callback) {
    setTimeout(function() {
        callback(null, n * 3);
    }, 10);
}

function waitFor(fn) {
    return function(val) {
        return new Promise(function(res, rej) {
            fn(val, function(err, data) {
                if (err) rej(err);
                else res(data);
            })
        });
    }
}

Promise.resolve(4)
	.then(waitFor(add1))
	.then(waitFor(mul3))
	.then(function(result) {
    	console.log(result); // 15
	}
);