-
-
Save killshot13/e66db8a8b03ae53fc347c4117597e036 to your computer and use it in GitHub Desktop.
MongoDB ObjectId generator script
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 mongoObjectId = () => { | |
const timestamp = ((new Date().getTime() / 1000) | 0).toString(16) | |
return ( | |
timestamp + | |
'xxxxxxxxxxxxxxxx' | |
.replace(/[x]/g, () => ((Math.random() * 16) | 0).toString(16)) | |
.toLowerCase() | |
) | |
} | |
let callbackHasRun = false | |
const resourceObserver = new PerformanceObserver((entries, observer, options) => { | |
entries.getEntries().forEach((entry) => { | |
// Do something with [entry] | |
entries.map | |
}) | |
if (!callbackHasRun && options.droppedEntriesCount) { | |
console.error( | |
`Callback has thrown an error; there were ${options.droppedEntriesCount} dropped entries.`, | |
) | |
} | |
callbackHasRun = true | |
}) | |
// Set buffered flag to true to load events from the past | |
// Only works with a single observed type, don't use arraysassert.deepPropertyNotVal(object, property, value, "[message]"); | |
resourceObserver.observe({ type: 'resource', buffered: true }) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment