Mark S. Miller
erights at google.com
Wed Aug 21 19:39:02 PDT 2013
First, yes, relying of ES5 + WeakMap is fine, since we have a reliable and
secure (though painful and leaky) WeakMap polyfill for ES5. However, even
with that, how do you construct a function which can distinguish whether it
is called with "new" or not?
On Wed, Aug 21, 2013 at 7:15 PM, Tab Atkins Jr. <jackalmage at gmail.com>wrote:
> On Wed, Aug 21, 2013 at 7:13 PM, Domenic Denicola
> <domenic at domenicdenicola.com> wrote:
> > From: Tab Atkins Jr. [mailto:jackalmage at gmail.com]
> >> Unless you wanted promise-likes to return fresh objects too?
> > Yes, that is largely the use case for `Q`/`Promise.as`/whatever. Handing
> it untrusted input, possible a non-promise, possibly a promise-like,
> possibly a promise, and getting back a trusted promise.
> Okay, that makes sense.
> >> The only way to have a completely reliable type test is to use a
> WeakSet to keep track of instances
> > I believe this is what Mark's makeQ.js does.
> >> Do you consider WeakMaps sufficient for polyfillability?
> > I believe makeQ.js uses a WeakMap polyfill, so yes.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the es-discuss