Created
April 25, 2018 15:30
-
-
Save gpalsingh/218aa7477589ccc362543ff896ea184f to your computer and use it in GitHub Desktop.
weakset.js
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 requests = new WeakSet(); | |
class Request { | |
constructor() { | |
requests.add(this); | |
} | |
makeRequest() { | |
if(!requests.has(this)) { | |
throw new Error("Invalid access"); | |
} | |
// Do work... | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment