Why Remove Proxy [[Enumerate]] and Reflect.enumerate?


BT: issue with proxy enumerate trap and for-in, where iimplementations are prevented from pre-populating the list of keys in the object, because the iterator causes observable affects. Which means the iterate must be pulled for every iteration. Last meeting we thought it would be ok if the enumerate trap exhausts the iterator, we thought that would solve the problem. The issue was, now their is an observable difference between an object and proxy of that object, mainly due to delete.

via 5.xix Proxy Enumerate - revisit decision to exhaust iterator


Moved ordinary [[Enumerate]] section to end of 13.7.5 for-in, renamed to EnumerateObjectProperties.
– https://github.com/tc39/ecma262/pull/367

Polyfill of EnumerateObjectProperties:

function* EnumerateObjectProperties(obj) {
  let visited = new Set;
  for (let key of Reflect.ownKeys(obj)) {
    if (typeof key === "string") {
      let desc = Reflect.getOwnPropertyDescriptor(obj, key);
      if (desc) {
        if (desc.enumerable) yield key;
  let proto = Reflect.getPrototypeOf(obj)
  if (proto === null) return;
  for (let protoName of EnumerateObjectProperties(proto)) {
    if (!visited.has(protoName)) yield protoName;

Edit: Add private thread capture on TC39.


blog comments powered by Disqus