Skip to content
This repository has been archived by the owner on Feb 1, 2025. It is now read-only.

Commit

Permalink
Code golf and stylistic tweaks for #264.
Browse files Browse the repository at this point in the history
  • Loading branch information
benjamn committed Dec 7, 2016
1 parent 21b9a25 commit c455b1d
Showing 1 changed file with 19 additions and 15 deletions.
34 changes: 19 additions & 15 deletions packages/regenerator-runtime/runtime.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
!(function(global) {
"use strict";

var hasOwn = Object.prototype.hasOwnProperty;
var Op = Object.prototype;
var hasOwn = Op.hasOwnProperty;
var undefined; // More compressible than void 0.
var $Symbol = typeof Symbol === "function" ? Symbol : {};
var iteratorSymbol = $Symbol.iterator || "@@iterator";
Expand Down Expand Up @@ -83,26 +84,29 @@
function GeneratorFunction() {}
function GeneratorFunctionPrototype() {}

// this is a polyfill for %IteratorPrototype% for environments that don't
// natively support it.
// This is a polyfill for %IteratorPrototype% for environments that
// don't natively support it.
var IteratorPrototype = {};
IteratorPrototype[iteratorSymbol] = function() {return this;};
IteratorPrototype[iteratorSymbol] = function () {
return this;
};

var getProto = Object.getPrototypeOf;
if (getProto) {
var NativeIteratorPrototype = getProto(getProto(values([])));
if (NativeIteratorPrototype &&
NativeIteratorPrototype !== Object.prototype &&
NativeIteratorPrototype.hasOwnProperty(iteratorSymbol)) {
// this environment has a native %IteratorPrototype%; use it instead of
// a polyfill.
IteratorPrototype = NativeIteratorPrototype;
}
var NativeIteratorPrototype = getProto && getProto(getProto(values([])));
if (NativeIteratorPrototype &&
NativeIteratorPrototype !== Op &&
hasOwn.call(NativeIteratorPrototype, iteratorSymbol)) {

This comment has been minimized.

Copy link
@aickin

aickin Dec 7, 2016

Contributor

Oh, thanks. I didn't see hasOwn up above; I haven't really read through the whole codebase.

// This environment has a native %IteratorPrototype%; use it instead
// of the polyfill.
IteratorPrototype = NativeIteratorPrototype;
}

var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype);
var Gp = GeneratorFunctionPrototype.prototype =
Generator.prototype = Object.create(IteratorPrototype);
GeneratorFunction.prototype = Gp.constructor = GeneratorFunctionPrototype;
GeneratorFunctionPrototype.constructor = GeneratorFunction;
GeneratorFunctionPrototype[toStringTagSymbol] = GeneratorFunction.displayName = "GeneratorFunction";
GeneratorFunctionPrototype[toStringTagSymbol] =
GeneratorFunction.displayName = "GeneratorFunction";

// Helper for defining the .next, .throw, and .return methods of the
// Iterator interface in terms of a single ._invoke method.
Expand Down

0 comments on commit c455b1d

Please sign in to comment.