Skip to content

Instantly share code, notes, and snippets.

@PaulRosset
Created June 29, 2022 13:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save PaulRosset/0d4e3a9b9af20f9997b41d15f70c8808 to your computer and use it in GitHub Desktop.
Save PaulRosset/0d4e3a9b9af20f9997b41d15f70c8808 to your computer and use it in GitHub Desktop.
Weakmap
const videoSegments = new WeakMap()
let options = { id: "1234", timeStart: 1653831957378, size: 10000 }
const segment = { data: new Uint8Array(200) }
videoSegments.set(options, segment)
console.warn(videoSegments.get(options)) // { data: new Uint8Array(200) }
options = null
console.warn(videoSegments.has(options)) // false, the `options` key object is deleted from the WeakMap
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment