Created
September 14, 2016 13:15
-
-
Save vkurchatkin/9769f70b35181e8244b7a9e480b9bc6b to your computer and use it in GitHub Desktop.
This file contains 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
class WeakMap { | |
constructor() { | |
this.s = Symbol(); | |
} | |
set(key, val) { | |
key[this.s] = val; | |
} | |
get(key) { | |
return key[this.s]; | |
} | |
has(key) { | |
return key.hasOwnProperty(this.s); | |
} | |
delete(key) { | |
delete key[this.s]; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment