Skip to content

Instantly share code, notes, and snippets.

@gpalsingh
Created April 25, 2018 15:30
Show Gist options
  • Save gpalsingh/218aa7477589ccc362543ff896ea184f to your computer and use it in GitHub Desktop.
Save gpalsingh/218aa7477589ccc362543ff896ea184f to your computer and use it in GitHub Desktop.
weakset.js
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