Skip to main content

One post tagged with "concurrency"

View All Tags

· One min read
class MyPromise {
constructor(executor) {
this.executor = executor;
this.resolve = this.resolve.bind(this);
this.executor(this.resolve);

process.nextTick(() => {
this.callback(this.result);
});
}

then(callback) {
this.callback = callback;
}

resolve(result) {
this.result = result;
}
}

function foo() {
new MyPromise((resolve) => resolve("done")).then((res) =>
console.log(`Returned ${res}`)
);
}

foo();