New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@putout/operate

Package Overview
Dependencies
Maintainers
1
Versions
107
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@putout/operate

operate on ast

1.7.0
Source
npm
Version published
Weekly downloads
20K
-3.75%
Maintainers
1
Weekly downloads
 
Created
Source

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

Keywords

ast

FAQs

Package last updated on 30 Oct 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts