esrefactor
esrefactor copied to clipboard
[Question] meaning of ctx.identify(4); in example code
Could you update or help me understand what is the meaning of ctx.identify(4); in example of this project ???
If I'm not wrong, ctx.indefity(4) is the location of the variable 'x' in that example.
var [x] = 42; y = x * 2; z = x / 2'"; // x match with 4th position;
if you take a look inside of the code
if (node.type === esprima.Syntax.Identifier) {
if (node.range[0] <= pos && node.range[1] >= pos) {
identifier = node;
return estraverse.VisitorOption.Break;
}
}
Once the position match with the range of some node, it breaks the iteration and return the Node. The number exact location it could come from some javascript editor or so on.