facebookarchive / prepack

A JavaScript bundle optimizer.
http://prepack.io
Other
14.21k stars 424 forks source link

Helper to inspect values at a particular AST node #2554

Closed sb98052 closed 6 years ago

sb98052 commented 6 years ago

This is a helper for inspecting values at a particular node in the AST. E.g.


let n = global.__abstract ? __abstract("number", "10") : 10;
let x = {foo:1};
let y = {foo:2};
let c = __abstract("boolean", "c");

let i = 0;
let obj = {};
do {
  i++;
  obj.j = i;
  obj.foo = c ? x : y;
} while (i < n);

__debugValue(obj);        // Breaks with obj in context

inspect = function() {
  return i + " " + obj.j;
};