This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const CustomPromiseState = { | |
PENDING: "PENDING", | |
RESOLVED: "RESOLVED", | |
REJECTED: "REJECTED", | |
}; | |
class CustomPromise { | |
constructor(fn) { | |
this.CustomPromiseState = CustomPromiseState.PENDING; | |
this.resolver = this.resolver.bind(this); | |
this.rejector = this.rejector.bind(this); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function memoization(func) { | |
let cache = new Map(); | |
const getData = () => { | |
if (cache[func]) { | |
console.log("cache"); | |
return cache[func]; | |
} else { | |
cache[func] = func(); | |
console.log("not cache"); | |
return cache[func]; |