Skip to content

Instantly share code, notes, and snippets.

View ENvironmentSet's full-sized avatar
🎯
Focusing on development of hyogwa

Jaewon Seo ENvironmentSet

🎯
Focusing on development of hyogwa
View GitHub Profile
@ENvironmentSet
ENvironmentSet / Future.js
Last active May 5, 2018 16:18
10분이면 여러분도 Future Monad를 만들 수 있습니다.
module.exports = ( () => {
const STATE = { PENDING: 0, DONE: 1, FAIL: 2};
class Future {
constructor(worker) {
this.state = STATE.PENDING;
this.value = undefined;
this.handlers = [];
try{
worker(Future.resolver(this), Future.rejector(this));
} catch (error) {