A Promise polyfill adapted from V8