JSPM

  • Created
  • Published
  • Downloads 27134
  • Score
    100M100P100Q149239F
  • License MIT

operate on ast

Package Exports

  • @putout/operate

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@putout/operate) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

Operate NPM version Dependency Status Build Status Coverage Status

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,
]);

isModuleExports(path)

Check if currentPath is module.exports expression.

compare(node|str, baseNode|baseStr)

Compare two ast-nodes using @putout/compare.

toExpression(node)

Can be used to convert node to expression when building new nodes.

License

MIT