Skip to content

Commit

Permalink
fixup! lib: make safe primordials safe to iterate
Browse files Browse the repository at this point in the history
  • Loading branch information
aduh95 committed Dec 7, 2020
1 parent 6a4e2ab commit cf53748
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions lib/internal/per_context/primordials.js
Expand Up @@ -84,9 +84,7 @@ const createSafeIterator = (factory, next) => {
Object.setPrototypeOf(SafeIterator.prototype, null);
Object.freeze(SafeIterator.prototype);
Object.freeze(SafeIterator);
return function() {
return new SafeIterator(this);
};
return SafeIterator;
};

function makeSafe(unsafe, safe) {
Expand All @@ -95,7 +93,10 @@ function makeSafe(unsafe, safe) {
if (Symbol.iterator in unsafe.prototype) {
const createIterator = uncurryThis(unsafe.prototype[Symbol.iterator]);
const next = uncurryThis(createIterator(new unsafe()).next);
safe.prototype[Symbol.iterator] = createSafeIterator(createIterator, next);
const SafeIterator = createSafeIterator(createIterator, next);
safe.prototype[Symbol.iterator] = function() {
return new SafeIterator(this);
};
}
Object.setPrototypeOf(safe.prototype, null);
Object.freeze(safe.prototype);
Expand Down

0 comments on commit cf53748

Please sign in to comment.