Skip to content
This repository has been archived by the owner on Jan 25, 2022. It is now read-only.

Is the polyfill available? Can you help us please? #64

Closed
micbuffa opened this issue Mar 7, 2019 · 7 comments
Closed

Is the polyfill available? Can you help us please? #64

micbuffa opened this issue Mar 7, 2019 · 7 comments

Comments

@micbuffa
Copy link

micbuffa commented Mar 7, 2019

Hi, we're ou our way trying to port the old Firefox WebAudio devtools for debugging WebAudio applications. We're going to rely on the WeakRefs API for tracking WebAudio nodes that will be Created or Garbage Collected.

We read about a polyfill that is being written... is it available? We'll be glad to beta test it...

Thanks in advance

@Jamesernator
Copy link

I'm not sure a browser polyfill is really possible unless there's an existing API that can somehow be abused to expose a Weak Reference created by another spec.

A polyfill for Node is definitely possible though as Node exposes weak references in the C++ NAPI, in fact if you want a Node polyfill here you go (currently missing .cleanupSome and the key argument).

@daurnimator
Copy link

Yes I doubt a polyfill is possible. This is really adding a totally new features to browsers.

The only thing would be if someone created a polyfill that simply never calls the executor (simulating a system that never runs a garbage collection)

@ljharb
Copy link
Member

ljharb commented Mar 11, 2019

That’d be a sham, instead of a shim :-) Weakness of keys (WeakSet, WeakMap) isn’t something that’s polyfillable unless the engine provides it; neither would be weakness of values, unfortunately.

@micbuffa
Copy link
Author

micbuffa commented Mar 11, 2019 via email

@codehag
Copy link
Contributor

codehag commented Mar 14, 2019

Yes, this is polyfillable. We are currently working on a polyfill for this.

@codehag
Copy link
Contributor

codehag commented Mar 14, 2019

I will close this for now as there will be a polyfill at a future date. Michel Buffa and I have synced in a separate channel.

@codehag codehag closed this as completed Mar 14, 2019
@mhofman
Copy link
Member

mhofman commented Apr 17, 2019

I've implemented my own shim which should be spec compliant:
https://github.com/mhofman/tc39-weakrefs-shim

It has an implementation for node, and an experimental PoC for SpiderMonkey shell.
I'd be curious to learn from @codehag if and how a proper shim is possible for Firefox :)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants