Operate
operate
provide you a way to manipulate path
nodes and keep comments
and loc
information you need
to build the same source file you had before parsing with help of recast
.
Install
npm i @putout/operate
If you use write plugin for putout
you already have operate
in putout
, all exampes will get operate
from putout
, but you can use direct require
as well.
API
replaceWith(path, node)
const {replaceWith} = require('putout').operate;
replaceWith(path, ContinueStatement);
replaceWithMultiple(path, nodes)
const {replaceWithMultiple} = require('putout').operate;
replaceWith(path, [
ExpressionStatement(path.node.argument),
ContinueStatement,
]);
License
MIT