节点属性们做浅层检查

 

 

对节点的属性们做浅层检查:

BinaryExpression(path) {
  if (t.isIdentifier(path.node.left, { name: "n" })) {
    // ...
  }
}
功能上等价于:

BinaryExpression(path) {
  if (
    path.node.left != null &&
    path.node.left.type === "Identifier" &&
    path.node.left.name === "n"
  ) {
    // ...
  }
}

 

posted @ 2022-01-17 20:32  AngDH  阅读(24)  评论(0编辑  收藏  举报