Skip to content

Instantly share code, notes, and snippets.

@phillmac
phillmac / iterable_weak_map.js
Last active June 24, 2020 04:20 — forked from seanlinsley/iterable_weak_set.js
Iterable WeakSet in JavaScript
// spec: https://github.com/tc39/proposal-weakrefs
// the spec contains an [iterable WeakMap implementation](https://github.com/tc39/proposal-weakrefs#iterable-weakmaps)
// NOTE: this WeakSet implementation is incomplete, only does what I needed
// In Firefox Nightly, visit about:config and enable javascript.options.experimental.weakrefs
class IterableWeakMap extends Map {
set(k, v) {
super.set(new WeakRef(k), v)
}
forEach(fn) {