Last active
January 13, 2017 14:53
-
-
Save fokusferit/6b059c8c1688bfc4a556ecd62a14b42c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var estraverse = require('estraverse'); | |
var fs = require('fs'); | |
fs.readFile('./ast.json', 'utf-8', function(err, ast) { | |
if(err) throw err; | |
const data = JSON.parse(ast); | |
estraverse.traverse(data, { | |
enter: function(node, parent) { | |
if(node.type === "Literal" && parent.type === "ArrayExpression") { | |
if(!Number.isInteger(node.value)){ | |
// stop traversal when a Literal is not a number | |
return estraverse.VisitorOption.Break; | |
} | |
} | |
}, | |
leave: function(node, parent) { | |
//nothing for now | |
} | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment