Skip to content

Commit 511b313

Browse files
Dustyn Loydacopybara-github
Dustyn Loyda
authored andcommitted
Add a define to assume ES6 is available.
PiperOrigin-RevId: 698913601
1 parent 73dc7df commit 511b313

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

src/com/google/javascript/jscomp/js/es6/util/iteratorfromarray.js

+3
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@
2929
* @suppress {checkTypes|reportUnknownTypes}
3030
*/
3131
$jscomp.iteratorFromArray = function(array, transform) {
32+
if ($jscomp.ASSUME_ES6){
33+
return array[Symbol.iterator]();
34+
}
3235
// NOTE: IE8 doesn't support indexing from boxed Strings.
3336
if (array instanceof String) array = array + '';
3437
var i = 0;

src/com/google/javascript/jscomp/js/util/defines.js

+7
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,13 @@
2424
*/
2525
$jscomp.ASSUME_ES5 = false;
2626

27+
/**
28+
* Whether to assume ES6 is available. This enables removing several
29+
* internal polyfills, which must otherwise be detected at runtime.
30+
* @define {boolean}
31+
*/
32+
$jscomp.ASSUME_ES6 = false;
33+
2734
/**
2835
* Whether to skip the conformance check and simply use the polyfill always.
2936
* @define {boolean}

0 commit comments

Comments
 (0)