- 移除某个父节点
- // 插件定义
- BinaryExpression(path) {
- path.parentPath.remove();
- }
- // 代码结不雅
- function square(n) {
- - return n * n;
- }
- FunctionDeclaration(path) {
- if (path.scope.hasBinding("n")) {
- // ...
- }
- }
- FunctionDeclaration(path) {
- if (path.scope.hasOwnBinding("n")) {
- // ...
- }
- }
- 创建 UID
- // 插件定义
- FunctionDeclaration(path) {
- const id = path.scope.generateUidIdentifierBasedOnNode(path.node.id);
- path.remove();
- path.scope.parent.push({ id, init: path.node });
- }
- // 代码结不雅
- - function square(n) {
- + var _square = function square(n) {
- return n * n;
- - }
- + };
【编辑推荐】
- 前端模板的道理与实现
- 给Python小白看的10个应用案例,入门Python就在这里了
- 深刻懂得游戏中寻路算法
- 前端机能优化
- 换个思路懂得Javascript中的this
推荐阅读
2009年6月,我省开端量刑规范化改革,是全国第二批试点省份。据介绍,海南最新版的量刑细则涵盖了23个常见着绫躯和罚金刑、缓刑实用,所涉的刑事犯法案件占到我省刑事案件的95%以上。此次>>>详细阅读
本文标题:JavaScript语法树与代码转化实践
地址:http://www.17bianji.com/lsqh/36429.html
1/2 1

网友点评
精彩导读
科技快报
品牌展示