Skip to content

Commit

Permalink
Add a define to assume ES6 is available.
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 698913601
  • Loading branch information
Dustyn Loyda authored and copybara-github committed Nov 21, 2024
1 parent 73dc7df commit 511b313
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@
* @suppress {checkTypes|reportUnknownTypes}
*/
$jscomp.iteratorFromArray = function(array, transform) {
if ($jscomp.ASSUME_ES6){
return array[Symbol.iterator]();
}
// NOTE: IE8 doesn't support indexing from boxed Strings.
if (array instanceof String) array = array + '';
var i = 0;
Expand Down
7 changes: 7 additions & 0 deletions src/com/google/javascript/jscomp/js/util/defines.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,13 @@
*/
$jscomp.ASSUME_ES5 = false;

/**
* Whether to assume ES6 is available. This enables removing several
* internal polyfills, which must otherwise be detected at runtime.
* @define {boolean}
*/
$jscomp.ASSUME_ES6 = false;

/**
* Whether to skip the conformance check and simply use the polyfill always.
* @define {boolean}
Expand Down

0 comments on commit 511b313

Please sign in to comment.