babel-helper-mark-eval-scopes
Advanced tools
Comparing version 0.3.0-alpha.5ee3078e to 0.3.0-alpha.636ae276
"use strict"; | ||
const EVAL_SCOPE_MARKER = Symbol("evalInScope"); | ||
function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } } | ||
var EVAL_SCOPE_MARKER = Symbol("evalInScope"); | ||
module.exports = { | ||
@@ -14,6 +16,6 @@ EVAL_SCOPE_MARKER, | ||
function getEvalScopes(path) { | ||
const evalScopes = new Set(); | ||
var evalScopes = new Set(); | ||
function add(scope) { | ||
let evalScope = scope; | ||
var evalScope = scope; | ||
do { | ||
@@ -26,3 +28,3 @@ evalScopes.add(evalScope); | ||
CallExpression(evalPath) { | ||
const callee = evalPath.get("callee"); | ||
var callee = evalPath.get("callee"); | ||
@@ -38,5 +40,7 @@ if (callee.isIdentifier() && callee.node.name === "eval" && !callee.scope.getBinding("eval")) { | ||
function markEvalScopes(path, key = EVAL_SCOPE_MARKER) { | ||
const evalScopes = getEvalScopes(path); | ||
[...evalScopes].forEach(scope => { | ||
function markEvalScopes(path) { | ||
var key = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : EVAL_SCOPE_MARKER; | ||
var evalScopes = getEvalScopes(path); | ||
[].concat(_toConsumableArray(evalScopes)).forEach(function (scope) { | ||
scope[key] = true; | ||
@@ -46,7 +50,11 @@ }); | ||
function isMarked(scope, key = EVAL_SCOPE_MARKER) { | ||
function isMarked(scope) { | ||
var key = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : EVAL_SCOPE_MARKER; | ||
return Object.prototype.hasOwnProperty.call(scope, key); | ||
} | ||
function hasEval(scope, key = EVAL_SCOPE_MARKER) { | ||
function hasEval(scope) { | ||
var key = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : EVAL_SCOPE_MARKER; | ||
if (!isMarked(scope, key)) { | ||
@@ -53,0 +61,0 @@ markEvalScopes(scope, key); |
{ | ||
"name": "babel-helper-mark-eval-scopes", | ||
"version": "0.3.0-alpha.5ee3078e", | ||
"version": "0.3.0-alpha.636ae276", | ||
"description": "Mark scopes for deopt which contain a direct eval call", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
4381
132