@@ -16,6 +16,24 @@ var runtime = (function (exports) {
16
16
var asyncIteratorSymbol = $Symbol . asyncIterator || "@@asyncIterator" ;
17
17
var toStringTagSymbol = $Symbol . toStringTag || "@@toStringTag" ;
18
18
19
+ function define ( obj , key , value ) {
20
+ Object . defineProperty ( obj , key , {
21
+ value : value ,
22
+ enumerable : true ,
23
+ configurable : true ,
24
+ writable : true
25
+ } ) ;
26
+ return obj [ key ] ;
27
+ }
28
+ try {
29
+ // IE 8 has a broken Object.defineProperty that only works on DOM objects.
30
+ define ( { } , "" ) ;
31
+ } catch ( err ) {
32
+ define = function ( obj , key , value ) {
33
+ return obj [ key ] = value ;
34
+ } ;
35
+ }
36
+
19
37
function wrap ( innerFn , outerFn , self , tryLocsList ) {
20
38
// If outerFn provided and outerFn.prototype is a Generator, then outerFn.prototype instanceof Generator.
21
39
var protoGenerator = outerFn && outerFn . prototype instanceof Generator ? outerFn : Generator ;
@@ -82,29 +100,23 @@ var runtime = (function (exports) {
82
100
IteratorPrototype = NativeIteratorPrototype ;
83
101
}
84
102
85
- function ensureDefaultToStringTag ( object , defaultValue ) {
86
- // https://bugzilla.mozilla.org/show_bug.cgi?id=1644581#c6
87
- return toStringTagSymbol in object
88
- ? object [ toStringTagSymbol ]
89
- : object [ toStringTagSymbol ] = defaultValue ;
90
- }
91
-
92
103
var Gp = GeneratorFunctionPrototype . prototype =
93
104
Generator . prototype = Object . create ( IteratorPrototype ) ;
94
105
GeneratorFunction . prototype = Gp . constructor = GeneratorFunctionPrototype ;
95
106
GeneratorFunctionPrototype . constructor = GeneratorFunction ;
96
- GeneratorFunction . displayName = ensureDefaultToStringTag (
107
+ GeneratorFunction . displayName = define (
97
108
GeneratorFunctionPrototype ,
109
+ toStringTagSymbol ,
98
110
"GeneratorFunction"
99
111
) ;
100
112
101
113
// Helper for defining the .next, .throw, and .return methods of the
102
114
// Iterator interface in terms of a single ._invoke method.
103
115
function defineIteratorMethods ( prototype ) {
104
116
[ "next" , "throw" , "return" ] . forEach ( function ( method ) {
105
- prototype [ method ] = function ( arg ) {
117
+ define ( prototype , method , function ( arg ) {
106
118
return this . _invoke ( method , arg ) ;
107
- } ;
119
+ } ) ;
108
120
} ) ;
109
121
}
110
122
@@ -123,7 +135,7 @@ var runtime = (function (exports) {
123
135
Object . setPrototypeOf ( genFun , GeneratorFunctionPrototype ) ;
124
136
} else {
125
137
genFun . __proto__ = GeneratorFunctionPrototype ;
126
- ensureDefaultToStringTag ( genFun , "GeneratorFunction" ) ;
138
+ define ( genFun , toStringTagSymbol , "GeneratorFunction" ) ;
127
139
}
128
140
genFun . prototype = Object . create ( Gp ) ;
129
141
return genFun ;
@@ -393,7 +405,7 @@ var runtime = (function (exports) {
393
405
// unified ._invoke helper method.
394
406
defineIteratorMethods ( Gp ) ;
395
407
396
- ensureDefaultToStringTag ( Gp , "Generator" ) ;
408
+ define ( Gp , toStringTagSymbol , "Generator" ) ;
397
409
398
410
// A Generator should always return itself as the iterator object when the
399
411
// @@iterator function is called on it. Some browsers' implementations of the
0 commit comments