Skip to content

Instantly share code, notes, and snippets.

View abdalicode's full-sized avatar
🟢

Hakan.Ab abdalicode

🟢
  • TR
View GitHub Profile
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);
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];