JSFiddle - React, Tailwind, and code Playground

HTML

<script src="https://cdn.jsdelivr.net/bluebird/latest/bluebird.min.js"></script>
<pre id="console"></pre>

JavaScript

////

var log = (function () {
	var c = document.getElementById('console');
  return function (msg) {
  	c.innerText += msg + '\n';
  };
})();

////

var H = function (c) {
	this.d_p = Promise.resolve();
  this.d_c = c;
};

H.prototype.q = function () {
	var s = this;
	return new Promise(function (resolve) {
  	s.d_p = s.d_p.then(function () {
    	s.d_c({
      	resolve: resolve
      });
    });
  });
};

////

var a,
    h = new H(function (args) { a = args; }),
    p;

Promise.resolve()
.then(function () {
	p = h.q();
})
.then(function () {
	a.resolve(42);
	return p;
})
.then(function (v) {
	log(v);
});