Skip to content

Instantly share code, notes, and snippets.

@killshot13
Forked from solenoid/gist:1372386
Last active January 12, 2022 06:35
Show Gist options
  • Save killshot13/e66db8a8b03ae53fc347c4117597e036 to your computer and use it in GitHub Desktop.
Save killshot13/e66db8a8b03ae53fc347c4117597e036 to your computer and use it in GitHub Desktop.
MongoDB ObjectId generator script
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