Open cpojer opened 9 years ago
There are two things blocking me from using map
.
NodePath
with a right parent.instanceof
to check if a result is a NodePath
fails when people mixing global installed jscodeshift
with local installed jscodeshift
or ast-types
.And because the map
function works like a bind
function for lists, I think it should accept a Collection
as a result instead of some NodePath
. If someone can find a way to recreate a Collection
with a proper parent, it will make jscodeshift
more expressive.
j(file.source)
.findVariableDeclarators(someName)
// with an improved map function
.map(p => fromNodes(p.node.init.properties));
This should work:
cc @iammerrick