Skip to content

Commit

Permalink
Remove redundant GeneratorFunctionPrototype
Browse files Browse the repository at this point in the history
  • Loading branch information
nikolaybotev committed Sep 13, 2024
1 parent 232e545 commit a896fde
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 9 deletions.
16 changes: 7 additions & 9 deletions packages/runtime/runtime.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,6 @@ var runtime = (function (exports) {
// minifier not to mangle the names of these two functions.
function Generator() {}
function GeneratorFunction() {}
function GeneratorFunctionPrototype() {}

// This is a polyfill for %IteratorPrototype% for environments that
// don't natively support it.
Expand All @@ -109,17 +108,16 @@ var runtime = (function (exports) {
IteratorPrototype = NativeIteratorPrototype;
}

var Gp = GeneratorFunctionPrototype.prototype =
Generator.prototype = Object.create(IteratorPrototype);
GeneratorFunction.prototype = GeneratorFunctionPrototype;
defineProperty(Gp, "constructor", { value: GeneratorFunctionPrototype, configurable: true });
var Gp = Generator.prototype = Object.create(IteratorPrototype);
GeneratorFunction.prototype = Generator;
defineProperty(Gp, "constructor", { value: Generator, configurable: true });
defineProperty(
GeneratorFunctionPrototype,
Generator,
"constructor",
{ value: GeneratorFunction, configurable: true }
);
GeneratorFunction.displayName = define(
GeneratorFunctionPrototype,
Generator,
toStringTagSymbol,
"GeneratorFunction"
);
Expand All @@ -146,9 +144,9 @@ var runtime = (function (exports) {

exports.mark = function(genFun) {
if (Object.setPrototypeOf) {
Object.setPrototypeOf(genFun, GeneratorFunctionPrototype);
Object.setPrototypeOf(genFun, Generator);
} else {
genFun.__proto__ = GeneratorFunctionPrototype;
genFun.__proto__ = Generator;
define(genFun, toStringTagSymbol, "GeneratorFunction");
}
genFun.prototype = Object.create(Gp);
Expand Down
1 change: 1 addition & 0 deletions test/tests.es6.js
Original file line number Diff line number Diff line change
Expand Up @@ -2642,6 +2642,7 @@ describe("generator function prototype", function() {
assert.notStrictEqual(IteratorPrototype, Object);
assert.throws(() => Iterator.call({}));
assert.throws(() => new Iterator());
assert.strictEqual(f() instanceof f, true);

if (typeof process === "undefined" ||
process.version.slice(1, 3) === "0.") {
Expand Down

0 comments on commit a896fde

Please sign in to comment.