How to use @putout/operate - 2 common examples

To help you get started, we’ve selected a few @putout/operate examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github coderaiser / putout / packages / engine-runner / lib / replace.js View on Github external
function setValues({waysTo, values, path}) {
    for (const [name, ways] of entries(waysTo)) {
        if (!ways) {
            replaceWith(path, values[name]);
            continue;
        }
        
        for (const way of ways) {
            nessy(way, values[name], path.node);
        }
    }
}
github coderaiser / putout / packages / engine-runner / lib / replace.js View on Github external
return;
    
    if (!to)
        return path.remove();
    
    const nodeTo = template.ast.fresh(to);
    const {node} = path;
    
    const waysFrom = findVarsWays(nodeFrom);
    const waysTo = findVarsWays(nodeTo);
    const values = getValues({
        waysFrom,
        node,
    });
    
    replaceWith(path, nodeTo);
    
    setValues({
        waysTo,
        values,
        path,
    });
    
    path._putout.push(watermark);
};

@putout/operate

Operate on AST for 🐊 Putout

MIT
Latest version published 3 days ago

Package Health Score

83 / 100
Full package analysis

Popular @putout/operate functions