use*_*582 0 javascript jscodeshift
如何将节点转换为 JavaScript?
// target file
function execute() {
var a = 'a'
}
// jscodeshift
export default(file, api) => {
const j = api.jscodeshift
const root = j(file.source)
var node = root.find(j.VariableDeclaration)
// i want to see what node looks like in javascript.
return root.toSource()
}
Run Code Online (Sandbox Code Playgroud)
假设您搜索的内容有一个非空集合:
var node = root.find(j.VariableDeclaration).at(0).get();
// in js node looks like
return j(node).toSource();
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1148 次 |
| 最近记录: |