babel-source 4.4.5 → 4.4.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +8 -8
- data/lib/babel.js +405 -260
- data/lib/babel/polyfill.js +276 -196
- data/lib/babel/source.rb +2 -2
- metadata +2 -2
data/lib/babel/polyfill.js
CHANGED
@@ -13,7 +13,7 @@ require("regenerator-babel/runtime");
|
|
13
13
|
}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
|
14
14
|
},{"core-js/shim":2,"regenerator-babel/runtime":3}],2:[function(require,module,exports){
|
15
15
|
/**
|
16
|
-
* Core.js 0.
|
16
|
+
* Core.js 0.6.1
|
17
17
|
* https://github.com/zloirock/core-js
|
18
18
|
* License: http://rock.mit-license.org
|
19
19
|
* © 2015 Denis Pushkarev
|
@@ -79,16 +79,12 @@ var OBJECT = 'Object'
|
|
79
79
|
, html = document && document.documentElement
|
80
80
|
, navigator = global.navigator
|
81
81
|
, define = global.define
|
82
|
+
, console = global.console || {}
|
82
83
|
, ArrayProto = Array[PROTOTYPE]
|
83
84
|
, ObjectProto = Object[PROTOTYPE]
|
84
85
|
, FunctionProto = Function[PROTOTYPE]
|
85
86
|
, Infinity = 1 / 0
|
86
|
-
, DOT = '.'
|
87
|
-
// Methods from https://github.com/DeveloperToolsWG/console-object/blob/master/api.md
|
88
|
-
, CONSOLE_METHODS = 'assert,clear,count,debug,dir,dirxml,error,exception,' +
|
89
|
-
'group,groupCollapsed,groupEnd,info,isIndependentlyComposed,log,' +
|
90
|
-
'markTimeline,profile,profileEnd,table,time,timeEnd,timeline,' +
|
91
|
-
'timelineEnd,timeStamp,trace,warn';
|
87
|
+
, DOT = '.';
|
92
88
|
|
93
89
|
// http://jsperf.com/core-js-isobject
|
94
90
|
function isObject(it){
|
@@ -176,12 +172,6 @@ function invoke(fn, args, that){
|
|
176
172
|
: fn.call(that, args[0], args[1], args[2], args[3], args[4]);
|
177
173
|
} return fn.apply(that, args);
|
178
174
|
}
|
179
|
-
function construct(target, argumentsList /*, newTarget*/){
|
180
|
-
var proto = assertFunction(arguments.length < 3 ? target : arguments[2])[PROTOTYPE]
|
181
|
-
, instance = create(isObject(proto) ? proto : ObjectProto)
|
182
|
-
, result = apply.call(target, instance, argumentsList);
|
183
|
-
return isObject(result) ? result : instance;
|
184
|
-
}
|
185
175
|
|
186
176
|
// Object:
|
187
177
|
var create = Object.create
|
@@ -423,32 +413,97 @@ function assignHidden(target, src){
|
|
423
413
|
|
424
414
|
var SYMBOL_UNSCOPABLES = getWellKnownSymbol('unscopables')
|
425
415
|
, ArrayUnscopables = ArrayProto[SYMBOL_UNSCOPABLES] || {}
|
426
|
-
,
|
416
|
+
, SYMBOL_TAG = getWellKnownSymbol(TO_STRING_TAG)
|
417
|
+
, SYMBOL_SPECIES = getWellKnownSymbol('species')
|
418
|
+
, SYMBOL_ITERATOR;
|
427
419
|
function setSpecies(C){
|
428
|
-
if(framework || !isNative(C))defineProperty(C, SYMBOL_SPECIES, {
|
420
|
+
if(DESC && (framework || !isNative(C)))defineProperty(C, SYMBOL_SPECIES, {
|
429
421
|
configurable: true,
|
430
422
|
get: returnThis
|
431
423
|
});
|
424
|
+
}
|
425
|
+
|
426
|
+
/******************************************************************************
|
427
|
+
* Module : common.export *
|
428
|
+
******************************************************************************/
|
429
|
+
|
430
|
+
var NODE = cof(process) == PROCESS
|
431
|
+
, core = {}
|
432
|
+
, path = framework ? global : core
|
433
|
+
, old = global.core
|
434
|
+
, exportGlobal
|
435
|
+
// type bitmap
|
436
|
+
, FORCED = 1
|
437
|
+
, GLOBAL = 2
|
438
|
+
, STATIC = 4
|
439
|
+
, PROTO = 8
|
440
|
+
, BIND = 16
|
441
|
+
, WRAP = 32;
|
442
|
+
function $define(type, name, source){
|
443
|
+
var key, own, out, exp
|
444
|
+
, isGlobal = type & GLOBAL
|
445
|
+
, target = isGlobal ? global : (type & STATIC)
|
446
|
+
? global[name] : (global[name] || ObjectProto)[PROTOTYPE]
|
447
|
+
, exports = isGlobal ? core : core[name] || (core[name] = {});
|
448
|
+
if(isGlobal)source = name;
|
449
|
+
for(key in source){
|
450
|
+
// there is a similar native
|
451
|
+
own = !(type & FORCED) && target && key in target
|
452
|
+
&& (!isFunction(target[key]) || isNative(target[key]));
|
453
|
+
// export native or passed
|
454
|
+
out = (own ? target : source)[key];
|
455
|
+
// prevent global pollution for namespaces
|
456
|
+
if(!framework && isGlobal && !isFunction(target[key]))exp = source[key];
|
457
|
+
// bind timers to global for call from export context
|
458
|
+
else if(type & BIND && own)exp = ctx(out, global);
|
459
|
+
// wrap global constructors for prevent change them in library
|
460
|
+
else if(type & WRAP && !framework && target[key] == out){
|
461
|
+
exp = function(param){
|
462
|
+
return this instanceof out ? new out(param) : out(param);
|
463
|
+
}
|
464
|
+
exp[PROTOTYPE] = out[PROTOTYPE];
|
465
|
+
} else exp = type & PROTO && isFunction(out) ? ctx(call, out) : out;
|
466
|
+
// extend global
|
467
|
+
if(framework && target && !own){
|
468
|
+
if(isGlobal)target[key] = out;
|
469
|
+
else delete target[key] && hidden(target, key, out);
|
470
|
+
}
|
471
|
+
// export
|
472
|
+
if(exports[key] != out)hidden(exports, key, exp);
|
473
|
+
}
|
432
474
|
}
|
433
|
-
|
434
|
-
|
435
|
-
|
436
|
-
|
437
|
-
|
438
|
-
|
475
|
+
// CommonJS export
|
476
|
+
if(typeof module != 'undefined' && module.exports)module.exports = core;
|
477
|
+
// RequireJS export
|
478
|
+
else if(isFunction(define) && define.amd)define(function(){return core});
|
479
|
+
// Export to global object
|
480
|
+
else exportGlobal = true;
|
481
|
+
if(exportGlobal || framework){
|
482
|
+
core.noConflict = function(){
|
483
|
+
global.core = old;
|
484
|
+
return core;
|
485
|
+
}
|
486
|
+
global.core = core;
|
487
|
+
}
|
488
|
+
|
489
|
+
/******************************************************************************
|
490
|
+
* Module : common.iterators *
|
491
|
+
******************************************************************************/
|
492
|
+
|
493
|
+
SYMBOL_ITERATOR = getWellKnownSymbol(ITERATOR);
|
494
|
+
var ITER = safeSymbol('iter')
|
439
495
|
, KEY = 1
|
440
496
|
, VALUE = 2
|
441
497
|
, Iterators = {}
|
442
498
|
, IteratorPrototype = {}
|
443
|
-
|
444
|
-
// Safari define byggy iterators w/o `next`
|
499
|
+
// Safari has byggy iterators w/o `next`
|
445
500
|
, BUGGY_ITERATORS = 'keys' in ArrayProto && !('next' in [].keys());
|
446
501
|
// 25.1.2.1.1 %IteratorPrototype%[@@iterator]()
|
447
502
|
setIterator(IteratorPrototype, returnThis);
|
448
503
|
function setIterator(O, value){
|
449
504
|
hidden(O, SYMBOL_ITERATOR, value);
|
450
505
|
// Add iterator for FF iterator protocol
|
451
|
-
|
506
|
+
FF_ITERATOR in ArrayProto && hidden(O, FF_ITERATOR, value);
|
452
507
|
}
|
453
508
|
function createIterator(Constructor, NAME, next, proto){
|
454
509
|
Constructor[PROTOTYPE] = create(proto || IteratorPrototype, {next: descriptor(1, next)});
|
@@ -511,72 +566,38 @@ function getIterator(it){
|
|
511
566
|
function stepCall(fn, value, entries){
|
512
567
|
return entries ? invoke(fn, value) : fn(value);
|
513
568
|
}
|
514
|
-
function
|
515
|
-
var
|
516
|
-
|
517
|
-
,
|
518
|
-
|
569
|
+
function checkDangerIterClosing(fn){
|
570
|
+
var danger = true;
|
571
|
+
var O = {
|
572
|
+
next: function(){ throw 1 },
|
573
|
+
'return': function(){ danger = false }
|
574
|
+
};
|
575
|
+
O[SYMBOL_ITERATOR] = returnThis;
|
576
|
+
try {
|
577
|
+
fn(O);
|
578
|
+
} catch(e){}
|
579
|
+
return danger;
|
519
580
|
}
|
520
|
-
|
521
|
-
|
522
|
-
|
523
|
-
, core = {}
|
524
|
-
, path = framework ? global : core
|
525
|
-
, old = global.core
|
526
|
-
, exportGlobal
|
527
|
-
// type bitmap
|
528
|
-
, FORCED = 1
|
529
|
-
, GLOBAL = 2
|
530
|
-
, STATIC = 4
|
531
|
-
, PROTO = 8
|
532
|
-
, BIND = 16
|
533
|
-
, WRAP = 32
|
534
|
-
, SIMPLE = 64;
|
535
|
-
function $define(type, name, source){
|
536
|
-
var key, own, out, exp
|
537
|
-
, isGlobal = type & GLOBAL
|
538
|
-
, target = isGlobal ? global : (type & STATIC)
|
539
|
-
? global[name] : (global[name] || ObjectProto)[PROTOTYPE]
|
540
|
-
, exports = isGlobal ? core : core[name] || (core[name] = {});
|
541
|
-
if(isGlobal)source = name;
|
542
|
-
for(key in source){
|
543
|
-
// there is a similar native
|
544
|
-
own = !(type & FORCED) && target && key in target
|
545
|
-
&& (!isFunction(target[key]) || isNative(target[key]));
|
546
|
-
// export native or passed
|
547
|
-
out = (own ? target : source)[key];
|
548
|
-
// prevent global pollution for namespaces
|
549
|
-
if(!framework && isGlobal && !isFunction(target[key]))exp = source[key];
|
550
|
-
// bind timers to global for call from export context
|
551
|
-
else if(type & BIND && own)exp = ctx(out, global);
|
552
|
-
// wrap global constructors for prevent change them in library
|
553
|
-
else if(type & WRAP && !framework && target[key] == out){
|
554
|
-
exp = function(param){
|
555
|
-
return this instanceof out ? new out(param) : out(param);
|
556
|
-
}
|
557
|
-
exp[PROTOTYPE] = out[PROTOTYPE];
|
558
|
-
} else exp = type & PROTO && isFunction(out) ? ctx(call, out) : out;
|
559
|
-
// extend global
|
560
|
-
if(framework && target && !own){
|
561
|
-
if(isGlobal || type & SIMPLE)target[key] = out;
|
562
|
-
else delete target[key] && hidden(target, key, out);
|
563
|
-
}
|
564
|
-
// export
|
565
|
-
if(exports[key] != out)hidden(exports, key, exp);
|
566
|
-
}
|
581
|
+
function closeIterator(iterator){
|
582
|
+
var ret = iterator['return'];
|
583
|
+
if(ret !== undefined)ret.call(iterator);
|
567
584
|
}
|
568
|
-
|
569
|
-
|
570
|
-
|
571
|
-
|
572
|
-
|
573
|
-
|
574
|
-
if(exportGlobal || framework){
|
575
|
-
core.noConflict = function(){
|
576
|
-
global.core = old;
|
577
|
-
return core;
|
585
|
+
function safeIterClose(exec, iterator){
|
586
|
+
try {
|
587
|
+
exec(iterator);
|
588
|
+
} catch(e){
|
589
|
+
closeIterator(iterator);
|
590
|
+
throw e;
|
578
591
|
}
|
579
|
-
|
592
|
+
}
|
593
|
+
function forOf(iterable, entries, fn, that){
|
594
|
+
safeIterClose(function(iterator){
|
595
|
+
var f = ctx(fn, that, entries ? 2 : 1)
|
596
|
+
, step;
|
597
|
+
while(!(step = iterator.next()).done)if(stepCall(f, step.value, entries) === false){
|
598
|
+
return closeIterator(iterator);
|
599
|
+
}
|
600
|
+
}, getIterator(iterable));
|
580
601
|
}
|
581
602
|
|
582
603
|
/******************************************************************************
|
@@ -614,7 +635,7 @@ if(exportGlobal || framework){
|
|
614
635
|
: SymbolRegistry[key] = Symbol(key);
|
615
636
|
},
|
616
637
|
// 19.4.2.4 Symbol.iterator
|
617
|
-
iterator: SYMBOL_ITERATOR,
|
638
|
+
iterator: SYMBOL_ITERATOR || getWellKnownSymbol(ITERATOR),
|
618
639
|
// 19.4.2.5 Symbol.keyFor(sym)
|
619
640
|
keyFor: part.call(keyOf, SymbolRegistry),
|
620
641
|
// 19.4.2.10 Symbol.species
|
@@ -658,13 +679,18 @@ if(exportGlobal || framework){
|
|
658
679
|
return result;
|
659
680
|
}
|
660
681
|
});
|
682
|
+
|
683
|
+
// 20.2.1.9 Math[@@toStringTag]
|
684
|
+
setToStringTag(Math, MATH, true);
|
685
|
+
// 24.3.3 JSON[@@toStringTag]
|
686
|
+
setToStringTag(global.JSON, 'JSON', true);
|
661
687
|
}(safeSymbol('tag'), {}, {}, true);
|
662
688
|
|
663
689
|
/******************************************************************************
|
664
|
-
* Module : es6.object
|
690
|
+
* Module : es6.object.statics *
|
665
691
|
******************************************************************************/
|
666
692
|
|
667
|
-
!function(
|
693
|
+
!function(){
|
668
694
|
var objectStatic = {
|
669
695
|
// 19.1.3.1 Object.assign(target, source)
|
670
696
|
assign: assign,
|
@@ -689,19 +715,18 @@ if(exportGlobal || framework){
|
|
689
715
|
}
|
690
716
|
}();
|
691
717
|
$define(STATIC, OBJECT, objectStatic);
|
692
|
-
|
693
|
-
|
694
|
-
|
695
|
-
|
696
|
-
|
697
|
-
|
698
|
-
|
699
|
-
|
700
|
-
|
701
|
-
|
702
|
-
|
703
|
-
|
704
|
-
setToStringTag(global.JSON, 'JSON', true);
|
718
|
+
}();
|
719
|
+
|
720
|
+
/******************************************************************************
|
721
|
+
* Module : es6.object.prototype *
|
722
|
+
******************************************************************************/
|
723
|
+
|
724
|
+
!function(tmp){
|
725
|
+
// 19.1.3.6 Object.prototype.toString()
|
726
|
+
tmp[SYMBOL_TAG] = DOT;
|
727
|
+
if(cof(tmp) != DOT)hidden(ObjectProto, TO_STRING, function(){
|
728
|
+
return '[object ' + classof(this) + ']';
|
729
|
+
});
|
705
730
|
}({});
|
706
731
|
|
707
732
|
/******************************************************************************
|
@@ -750,7 +775,7 @@ if(exportGlobal || framework){
|
|
750
775
|
|
751
776
|
!function(NAME){
|
752
777
|
// 19.2.4.2 name
|
753
|
-
NAME in FunctionProto || defineProperty(FunctionProto, NAME, {
|
778
|
+
NAME in FunctionProto || (DESC && defineProperty(FunctionProto, NAME, {
|
754
779
|
configurable: true,
|
755
780
|
get: function(){
|
756
781
|
var match = String(this).match(/^\s*function ([^ (]*)/)
|
@@ -761,7 +786,7 @@ if(exportGlobal || framework){
|
|
761
786
|
set: function(value){
|
762
787
|
has(this, NAME) || defineProperty(this, NAME, descriptor(0, value));
|
763
788
|
}
|
764
|
-
});
|
789
|
+
}));
|
765
790
|
}('name');
|
766
791
|
|
767
792
|
/******************************************************************************
|
@@ -798,7 +823,7 @@ Number('0o1') && Number('0b1') || function(_Number, NumberProto){
|
|
798
823
|
}(Number, Number[PROTOTYPE]);
|
799
824
|
|
800
825
|
/******************************************************************************
|
801
|
-
* Module : es6.number
|
826
|
+
* Module : es6.number.statics *
|
802
827
|
******************************************************************************/
|
803
828
|
|
804
829
|
!function(isInteger){
|
@@ -1018,11 +1043,11 @@ Number('0o1') && Number('0b1') || function(_Number, NumberProto){
|
|
1018
1043
|
}(String.fromCharCode);
|
1019
1044
|
|
1020
1045
|
/******************************************************************************
|
1021
|
-
* Module : es6.array
|
1046
|
+
* Module : es6.array.statics *
|
1022
1047
|
******************************************************************************/
|
1023
1048
|
|
1024
1049
|
!function(){
|
1025
|
-
$define(STATIC, ARRAY, {
|
1050
|
+
$define(STATIC + FORCED * checkDangerIterClosing(Array.from), ARRAY, {
|
1026
1051
|
// 22.1.2.1 Array.from(arrayLike, mapfn = undefined, thisArg = undefined)
|
1027
1052
|
from: function(arrayLike/*, mapfn = undefined, thisArg = undefined*/){
|
1028
1053
|
var O = Object(assertDefined(arrayLike))
|
@@ -1030,15 +1055,26 @@ Number('0o1') && Number('0b1') || function(_Number, NumberProto){
|
|
1030
1055
|
, mapping = mapfn !== undefined
|
1031
1056
|
, f = mapping ? ctx(mapfn, arguments[2], 2) : undefined
|
1032
1057
|
, index = 0
|
1033
|
-
, length, result,
|
1034
|
-
if(isIterable(O))
|
1035
|
-
result
|
1036
|
-
|
1037
|
-
|
1058
|
+
, length, result, step;
|
1059
|
+
if(isIterable(O)){
|
1060
|
+
result = new (generic(this, Array));
|
1061
|
+
safeIterClose(function(iterator){
|
1062
|
+
for(; !(step = iterator.next()).done; index++){
|
1063
|
+
result[index] = mapping ? f(step.value, index) : step.value;
|
1064
|
+
}
|
1065
|
+
}, getIterator(O));
|
1066
|
+
} else {
|
1067
|
+
result = new (generic(this, Array))(length = toLength(O.length));
|
1068
|
+
for(; length > index; index++){
|
1069
|
+
result[index] = mapping ? f(O[index], index) : O[index];
|
1070
|
+
}
|
1038
1071
|
}
|
1039
1072
|
result.length = index;
|
1040
1073
|
return result;
|
1041
|
-
}
|
1074
|
+
}
|
1075
|
+
});
|
1076
|
+
|
1077
|
+
$define(STATIC, ARRAY, {
|
1042
1078
|
// 22.1.2.3 Array.of( ...items)
|
1043
1079
|
of: function(/* ...args */){
|
1044
1080
|
var index = 0
|
@@ -1050,6 +1086,14 @@ Number('0o1') && Number('0b1') || function(_Number, NumberProto){
|
|
1050
1086
|
}
|
1051
1087
|
});
|
1052
1088
|
|
1089
|
+
setSpecies(Array);
|
1090
|
+
}();
|
1091
|
+
|
1092
|
+
/******************************************************************************
|
1093
|
+
* Module : es6.array.prototype *
|
1094
|
+
******************************************************************************/
|
1095
|
+
|
1096
|
+
!function(){
|
1053
1097
|
$define(PROTO, ARRAY, {
|
1054
1098
|
// 22.1.3.3 Array.prototype.copyWithin(target, start, end = this.length)
|
1055
1099
|
copyWithin: function(target /* = 0 */, start /* = 0, end = @length */){
|
@@ -1095,9 +1139,7 @@ Number('0o1') && Number('0b1') || function(_Number, NumberProto){
|
|
1095
1139
|
ArrayUnscopables[it] = true;
|
1096
1140
|
});
|
1097
1141
|
SYMBOL_UNSCOPABLES in ArrayProto || hidden(ArrayProto, SYMBOL_UNSCOPABLES, ArrayUnscopables);
|
1098
|
-
}
|
1099
|
-
|
1100
|
-
setSpecies(Array);
|
1142
|
+
}
|
1101
1143
|
}();
|
1102
1144
|
|
1103
1145
|
/******************************************************************************
|
@@ -1149,16 +1191,9 @@ Number('0o1') && Number('0b1') || function(_Number, NumberProto){
|
|
1149
1191
|
* Module : es6.regexp *
|
1150
1192
|
******************************************************************************/
|
1151
1193
|
|
1152
|
-
!function(RegExpProto, _RegExp){
|
1153
|
-
function assertRegExpWrapper(fn){
|
1154
|
-
return function(){
|
1155
|
-
assert(cof(this) === REGEXP);
|
1156
|
-
return fn(this);
|
1157
|
-
}
|
1158
|
-
}
|
1159
|
-
|
1194
|
+
DESC && !function(RegExpProto, _RegExp){
|
1160
1195
|
// RegExp allows a regex with flags as the pattern
|
1161
|
-
if(
|
1196
|
+
if(!function(){try{return RegExp(/a/g, 'i') == '/a/i'}catch(e){}}()){
|
1162
1197
|
RegExp = function RegExp(pattern, flags){
|
1163
1198
|
return new _RegExp(cof(pattern) == REGEXP && flags !== undefined
|
1164
1199
|
? pattern.source : pattern, flags);
|
@@ -1178,18 +1213,7 @@ Number('0o1') && Number('0b1') || function(_Number, NumberProto){
|
|
1178
1213
|
// 21.2.5.3 get RegExp.prototype.flags()
|
1179
1214
|
if(/./g.flags != 'g')defineProperty(RegExpProto, 'flags', {
|
1180
1215
|
configurable: true,
|
1181
|
-
get:
|
1182
|
-
});
|
1183
|
-
|
1184
|
-
// 21.2.5.12 get RegExp.prototype.sticky()
|
1185
|
-
// 21.2.5.15 get RegExp.prototype.unicode()
|
1186
|
-
forEach.call(array('sticky,unicode'), function(key){
|
1187
|
-
key in /./ || defineProperty(RegExpProto, key, DESC ? {
|
1188
|
-
configurable: true,
|
1189
|
-
get: assertRegExpWrapper(function(){
|
1190
|
-
return false;
|
1191
|
-
})
|
1192
|
-
} : descriptor(5, false));
|
1216
|
+
get: createReplacer(/^.*\/(\w*)$/, '$1')
|
1193
1217
|
});
|
1194
1218
|
|
1195
1219
|
setSpecies(RegExp);
|
@@ -1277,30 +1301,55 @@ $define(GLOBAL + BIND, {
|
|
1277
1301
|
!function(Promise, test){
|
1278
1302
|
isFunction(Promise) && isFunction(Promise.resolve)
|
1279
1303
|
&& Promise.resolve(test = new Promise(function(){})) == test
|
1280
|
-
|| function(asap,
|
1281
|
-
function isThenable(
|
1304
|
+
|| function(asap, RECORD){
|
1305
|
+
function isThenable(it){
|
1282
1306
|
var then;
|
1283
|
-
if(isObject(
|
1307
|
+
if(isObject(it))then = it.then;
|
1284
1308
|
return isFunction(then) ? then : false;
|
1285
1309
|
}
|
1286
|
-
function
|
1287
|
-
var
|
1288
|
-
|
1289
|
-
|
1290
|
-
|
1291
|
-
|
1292
|
-
|
1310
|
+
function handledRejectionOrHasOnRejected(promise){
|
1311
|
+
var record = promise[RECORD]
|
1312
|
+
, chain = record.c
|
1313
|
+
, i = 0
|
1314
|
+
, react;
|
1315
|
+
if(record.h)return true;
|
1316
|
+
while(chain.length > i){
|
1317
|
+
react = chain[i++];
|
1318
|
+
if(react.fail || handledRejectionOrHasOnRejected(react.P))return true;
|
1319
|
+
}
|
1320
|
+
}
|
1321
|
+
function notify(record, reject){
|
1322
|
+
var chain = record.c;
|
1323
|
+
if(reject || chain.length)asap(function(){
|
1324
|
+
var promise = record.p
|
1325
|
+
, value = record.v
|
1326
|
+
, ok = record.s == 1
|
1327
|
+
, i = 0;
|
1328
|
+
if(reject && !handledRejectionOrHasOnRejected(promise)){
|
1329
|
+
setTimeout(function(){
|
1330
|
+
if(!handledRejectionOrHasOnRejected(promise)){
|
1331
|
+
if(NODE){
|
1332
|
+
if(!process.emit('unhandledRejection', value, promise)){
|
1333
|
+
// default node.js behavior
|
1334
|
+
}
|
1335
|
+
} else if(isFunction(console.error)){
|
1336
|
+
console.error('Unhandled promise rejection', value);
|
1337
|
+
}
|
1338
|
+
}
|
1339
|
+
}, 1e3);
|
1340
|
+
} else while(chain.length > i)!function(react){
|
1293
1341
|
var cb = ok ? react.ok : react.fail
|
1294
1342
|
, ret, then;
|
1295
1343
|
try {
|
1296
1344
|
if(cb){
|
1297
|
-
|
1345
|
+
if(!ok)record.h = true;
|
1346
|
+
ret = cb === true ? value : cb(value);
|
1298
1347
|
if(ret === react.P){
|
1299
1348
|
react.rej(TypeError(PROMISE + '-chain cycle'));
|
1300
1349
|
} else if(then = isThenable(ret)){
|
1301
1350
|
then.call(ret, react.res, react.rej);
|
1302
1351
|
} else react.res(ret);
|
1303
|
-
} else react.rej(
|
1352
|
+
} else react.rej(value);
|
1304
1353
|
} catch(err){
|
1305
1354
|
react.rej(err);
|
1306
1355
|
}
|
@@ -1308,33 +1357,33 @@ $define(GLOBAL + BIND, {
|
|
1308
1357
|
chain.length = 0;
|
1309
1358
|
});
|
1310
1359
|
}
|
1311
|
-
function resolve(
|
1312
|
-
var
|
1360
|
+
function resolve(value){
|
1361
|
+
var record = this
|
1313
1362
|
, then, wrapper;
|
1314
|
-
if(
|
1315
|
-
|
1316
|
-
|
1363
|
+
if(record.d)return;
|
1364
|
+
record.d = true;
|
1365
|
+
record = record.r || record; // unwrap
|
1317
1366
|
try {
|
1318
|
-
if(then = isThenable(
|
1319
|
-
wrapper = {
|
1320
|
-
then.call(
|
1367
|
+
if(then = isThenable(value)){
|
1368
|
+
wrapper = {r: record, d: false}; // wrap
|
1369
|
+
then.call(value, ctx(resolve, wrapper, 1), ctx(reject, wrapper, 1));
|
1321
1370
|
} else {
|
1322
|
-
|
1323
|
-
|
1324
|
-
notify(
|
1371
|
+
record.v = value;
|
1372
|
+
record.s = 1;
|
1373
|
+
notify(record);
|
1325
1374
|
}
|
1326
1375
|
} catch(err){
|
1327
|
-
reject.call(wrapper || {
|
1376
|
+
reject.call(wrapper || {r: record, d: false}, err); // wrap
|
1328
1377
|
}
|
1329
1378
|
}
|
1330
|
-
function reject(
|
1331
|
-
var
|
1332
|
-
if(
|
1333
|
-
|
1334
|
-
|
1335
|
-
|
1336
|
-
|
1337
|
-
notify(
|
1379
|
+
function reject(value){
|
1380
|
+
var record = this;
|
1381
|
+
if(record.d)return;
|
1382
|
+
record.d = true;
|
1383
|
+
record = record.r || record; // unwrap
|
1384
|
+
record.v = value;
|
1385
|
+
record.s = 2;
|
1386
|
+
notify(record, true);
|
1338
1387
|
}
|
1339
1388
|
function getConstructor(C){
|
1340
1389
|
var S = assertObject(C)[SYMBOL_SPECIES];
|
@@ -1344,12 +1393,19 @@ $define(GLOBAL + BIND, {
|
|
1344
1393
|
Promise = function(executor){
|
1345
1394
|
assertFunction(executor);
|
1346
1395
|
assertInstance(this, Promise, PROMISE);
|
1347
|
-
var
|
1348
|
-
|
1396
|
+
var record = {
|
1397
|
+
p: this, // promise
|
1398
|
+
c: [], // chain
|
1399
|
+
s: 0, // state
|
1400
|
+
d: false, // done
|
1401
|
+
v: undefined, // value
|
1402
|
+
h: false // handled rejection
|
1403
|
+
};
|
1404
|
+
hidden(this, RECORD, record);
|
1349
1405
|
try {
|
1350
|
-
executor(ctx(resolve,
|
1406
|
+
executor(ctx(resolve, record, 1), ctx(reject, record, 1));
|
1351
1407
|
} catch(err){
|
1352
|
-
reject.call(
|
1408
|
+
reject.call(record, err);
|
1353
1409
|
}
|
1354
1410
|
}
|
1355
1411
|
assignHidden(Promise[PROTOTYPE], {
|
@@ -1362,9 +1418,9 @@ $define(GLOBAL + BIND, {
|
|
1362
1418
|
} , P = react.P = new (S != undefined ? S : Promise)(function(resolve, reject){
|
1363
1419
|
react.res = assertFunction(resolve);
|
1364
1420
|
react.rej = assertFunction(reject);
|
1365
|
-
}),
|
1366
|
-
|
1367
|
-
|
1421
|
+
}), record = this[RECORD];
|
1422
|
+
record.c.push(react);
|
1423
|
+
record.s && notify(record);
|
1368
1424
|
return P;
|
1369
1425
|
},
|
1370
1426
|
// 25.4.5.1 Promise.prototype.catch(onRejected)
|
@@ -1407,13 +1463,13 @@ $define(GLOBAL + BIND, {
|
|
1407
1463
|
},
|
1408
1464
|
// 25.4.4.6 Promise.resolve(x)
|
1409
1465
|
resolve: function(x){
|
1410
|
-
return isObject(x) &&
|
1466
|
+
return isObject(x) && RECORD in x && getPrototypeOf(x) === this[PROTOTYPE]
|
1411
1467
|
? x : new (getConstructor(this))(function(resolve, reject){
|
1412
1468
|
resolve(x);
|
1413
1469
|
});
|
1414
1470
|
}
|
1415
1471
|
});
|
1416
|
-
}(nextTick || setImmediate, safeSymbol('
|
1472
|
+
}(nextTick || setImmediate, safeSymbol('record'));
|
1417
1473
|
setToStringTag(Promise, PROMISE);
|
1418
1474
|
setSpecies(Promise);
|
1419
1475
|
$define(GLOBAL + FORCED * !isNative(Promise), {Promise: Promise});
|
@@ -1468,7 +1524,7 @@ $define(GLOBAL + BIND, {
|
|
1468
1524
|
initFromIterable(that, iterable);
|
1469
1525
|
};
|
1470
1526
|
assignHidden(assignHidden(C[PROTOTYPE], methods), commonMethods);
|
1471
|
-
isWeak || defineProperty(C[PROTOTYPE], 'size', {get: function(){
|
1527
|
+
isWeak || !DESC || defineProperty(C[PROTOTYPE], 'size', {get: function(){
|
1472
1528
|
return assertDefined(this[SIZE]);
|
1473
1529
|
}});
|
1474
1530
|
} else {
|
@@ -1477,7 +1533,7 @@ $define(GLOBAL + BIND, {
|
|
1477
1533
|
, chain = inst[ADDER](isWeak ? {} : -0, 1)
|
1478
1534
|
, buggyZero;
|
1479
1535
|
// wrap to init collections from iterable
|
1480
|
-
if(
|
1536
|
+
if(checkDangerIterClosing(function(O){ new C(O) })){
|
1481
1537
|
C = function(iterable){
|
1482
1538
|
assertInstance(this, C, NAME);
|
1483
1539
|
return initFromIterable(new Native, iterable);
|
@@ -1777,7 +1833,12 @@ $define(GLOBAL + BIND, {
|
|
1777
1833
|
// 26.1.1 Reflect.apply(target, thisArgument, argumentsList)
|
1778
1834
|
apply: ctx(call, apply, 3),
|
1779
1835
|
// 26.1.2 Reflect.construct(target, argumentsList [, newTarget])
|
1780
|
-
construct:
|
1836
|
+
construct: function(target, argumentsList /*, newTarget*/){
|
1837
|
+
var proto = assertFunction(arguments.length < 3 ? target : arguments[2])[PROTOTYPE]
|
1838
|
+
, instance = create(isObject(proto) ? proto : ObjectProto)
|
1839
|
+
, result = apply.call(target, instance, argumentsList);
|
1840
|
+
return isObject(result) ? result : instance;
|
1841
|
+
},
|
1781
1842
|
// 26.1.3 Reflect.defineProperty(target, propertyKey, attributes)
|
1782
1843
|
defineProperty: wrap(defineProperty),
|
1783
1844
|
// 26.1.4 Reflect.deleteProperty(target, propertyKey)
|
@@ -1851,8 +1912,17 @@ $define(GLOBAL + BIND, {
|
|
1851
1912
|
}
|
1852
1913
|
}
|
1853
1914
|
$define(STATIC, OBJECT, {
|
1915
|
+
// https://gist.github.com/WebReflection/9353781
|
1916
|
+
getOwnPropertyDescriptors: function(object){
|
1917
|
+
var O = toObject(object)
|
1918
|
+
, result = {};
|
1919
|
+
forEach.call(ownKeys(O), function(key){
|
1920
|
+
defineProperty(result, key, descriptor(0, getOwnDescriptor(O, key)));
|
1921
|
+
});
|
1922
|
+
return result;
|
1923
|
+
},
|
1854
1924
|
// https://github.com/rwaldron/tc39-notes/blob/master/es6/2014-04/apr-9.md#51-objectentries-objectvalues
|
1855
|
-
values:
|
1925
|
+
values: createObjectToArray(false),
|
1856
1926
|
entries: createObjectToArray(true)
|
1857
1927
|
});
|
1858
1928
|
$define(STATIC, REGEXP, {
|
@@ -2363,27 +2433,33 @@ $define(GLOBAL + BIND, {
|
|
2363
2433
|
}
|
2364
2434
|
},
|
2365
2435
|
|
2366
|
-
|
2436
|
+
abrupt: function(type, arg) {
|
2367
2437
|
for (var i = this.tryEntries.length - 1; i >= 0; --i) {
|
2368
2438
|
var entry = this.tryEntries[i];
|
2369
2439
|
if (entry.tryLoc <= this.prev &&
|
2370
|
-
hasOwn.call(entry, "finallyLoc") &&
|
2371
|
-
|
2372
|
-
|
2373
|
-
|
2440
|
+
hasOwn.call(entry, "finallyLoc") &&
|
2441
|
+
this.prev < entry.finallyLoc) {
|
2442
|
+
var finallyEntry = entry;
|
2443
|
+
break;
|
2374
2444
|
}
|
2375
2445
|
}
|
2376
|
-
},
|
2377
2446
|
|
2378
|
-
|
2379
|
-
|
2380
|
-
|
2447
|
+
if (finallyEntry &&
|
2448
|
+
(type === "break" ||
|
2449
|
+
type === "continue") &&
|
2450
|
+
finallyEntry.tryLoc <= arg &&
|
2451
|
+
arg < finallyEntry.finallyLoc) {
|
2452
|
+
// Ignore the finally entry if control is not jumping to a
|
2453
|
+
// location outside the try/catch block.
|
2454
|
+
finallyEntry = null;
|
2455
|
+
}
|
2381
2456
|
|
2457
|
+
var record = finallyEntry ? finallyEntry.completion : {};
|
2382
2458
|
record.type = type;
|
2383
2459
|
record.arg = arg;
|
2384
2460
|
|
2385
|
-
if (
|
2386
|
-
this.next =
|
2461
|
+
if (finallyEntry) {
|
2462
|
+
this.next = finallyEntry.finallyLoc;
|
2387
2463
|
} else {
|
2388
2464
|
this.complete(record);
|
2389
2465
|
}
|
@@ -2410,8 +2486,12 @@ $define(GLOBAL + BIND, {
|
|
2410
2486
|
},
|
2411
2487
|
|
2412
2488
|
finish: function(finallyLoc) {
|
2413
|
-
var
|
2414
|
-
|
2489
|
+
for (var i = this.tryEntries.length - 1; i >= 0; --i) {
|
2490
|
+
var entry = this.tryEntries[i];
|
2491
|
+
if (entry.finallyLoc === finallyLoc) {
|
2492
|
+
return this.complete(entry.completion, entry.afterLoc);
|
2493
|
+
}
|
2494
|
+
}
|
2415
2495
|
},
|
2416
2496
|
|
2417
2497
|
"catch": function(tryLoc) {
|