ses
Version:
Hardened JavaScript for Fearless Cooperation
30 lines (28 loc) • 707 B
JavaScript
import {
defineProperty,
iteratorPrototype,
iteratorSymbol,
objectHasOwnProperty,
} from './commons.js';
export const tameRegeneratorRuntime = () => {
const iter = iteratorPrototype[iteratorSymbol];
defineProperty(iteratorPrototype, iteratorSymbol, {
configurable: true,
get() {
return iter;
},
set(value) {
// ignore the assignment on IteratorPrototype
if (this === iteratorPrototype) return;
if (objectHasOwnProperty(this, iteratorSymbol)) {
this[iteratorSymbol] = value;
}
defineProperty(this, iteratorSymbol, {
value,
writable: true,
enumerable: true,
configurable: true,
});
},
});
};