Created
April 29, 2024 15:07
-
-
Save senyai/cec45d4e4886f86cefa283d24486ba5f 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
// based on https://stackoverflow.com/questions/1997661/unique-object-identifier-in-javascript | |
const getID = (function() { // FOR DEBUG ONLY. DO NOT COMMIT! | |
var id = 0; | |
return function(o: any): number { | |
if ( typeof o.__uniqueid != "undefined" ) { | |
return o.__uniqueid; | |
} | |
Object.defineProperty(o, "__uniqueid", { | |
value: ++id, | |
enumerable: false, | |
// This could go either way, depending on your | |
// interpretation of what an "id" is | |
writable: false | |
}); | |
return o.__uniqueid; | |
}; | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment