Created
June 29, 2022 13:32
-
-
Save PaulRosset/0d4e3a9b9af20f9997b41d15f70c8808 to your computer and use it in GitHub Desktop.
Weakmap
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
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