![Oracle Drags Its Feet in the JavaScript Trademark Dispute](https://cdn.sanity.io/images/cgdhsj6q/production/919c3b22c24f93884c548d60cbb338e819ff2435-1024x1024.webp?w=400&fit=max&auto=format)
Security News
Oracle Drags Its Feet in the JavaScript Trademark Dispute
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
@putout/operate
Advanced tools
operate
provide you a way to manipulate path
nodes and keep comments
and loc
information.
npm i @putout/operate
If you write plugin for putout
you already have operator
in putout
, all exampes will get operator
from putout
, but you can use direct require('@putout/operate')
as well.
extract(path)
Extract node value according to it's type::
Identifier
return name
;Literal
return value
;RegExp
return pattern
;TemplateLiteral
return qusis[0].value.raw
;TemplateElement
return value.raw
;ClassMethod
return key
;throw
in other casesreplaceWith(path, node)
const {
operator,
types,
} = require('putout');
const {replaceWith} = operator;
const {ContinueStatement} = types;
replaceWith(path, ContinueStatement());
replaceWithMultiple(path, nodes)
const {
operator,
types,
} = require('putout');
const {replaceWithMultiple} = operator;
const {
ExpressionStatement,
ContinueStatement,
} = types;
replaceWithMultiple(path, [
ExpressionStatement(path.node.argument),
ContinueStatement,
]);
isModuleExports(path)
Check if currentPath is module.exports
expression.
toExpression(node)
Can be used to convert node to expression
when building new nodes.
remove(path)
Remove node
, preserve comments.
getPathAfterImports(body)
Get next path
after latest ImportDeclaration
:
const programPath = path.scope.getProgramParent().path;
const afterImportsPath = getPathAfterImports(programPath.get('body'));
getBinding(path, name)
Get binding by name using starting from path
and move up.
getBinding(path, 'hello');
getBindingPath(path, name)
Get binding path
by name using starting from path
and move up.
getBindingPath(path, 'hello');
compute(path)
Computes value of expression:
For code
like this:
const bodies = {
function: `typeof __a === 'function'`,
};
module.exports.replace = () => ({
[bodies.function]: 'isFn(__a)',
});
You can compute value of bodies.function
:
const {parse, operator} = require('putout');
const {traverse, compute} = operator;
traverse({
'__a.__b': (path) => {
const [computed, value] = compute(path);
// returns
[true, "typeof __a === 'function'"];
},
});
MIT
FAQs
Operate on AST for 🐊 Putout
The npm package @putout/operate receives a total of 9,861 weekly downloads. As such, @putout/operate popularity was classified as popular.
We found that @putout/operate demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
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.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.