Socket
Socket
Sign inDemoInstall

@contrast/rewriter

Package Overview
Dependencies
Maintainers
14
Versions
31
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@contrast/rewriter

A transpilation tool mainly used for instrumentation


Version published
Weekly downloads
19K
decreased by-19.13%
Maintainers
14
Weekly downloads
 
Created
Source

@contrast/rewriter

Rewrite javascript code with custom rewrite transforms.

For example, Assess will register transforms for + -> contrast_add() so that it can perform propagation via instrumentation of contrast_add().

Example Service Usage
const { Rewriter } = require('.');

const rewriter = new Rewriter({ logger });

rewriter.addTransforms({
  BinaryExpression(path) {
    const method = methodLookups[path.node.operator];
    if (method) {
      path.replaceWith(
        t.callExpression(
          expression('ContrastMethods.%%method%%')({ method }), [
            path.node.left,
            path.node.right
          ]
        )
      );
    }
  }
});

const result = rewriter.rewrite('function add(x, y) { return x + y; }');

FAQs

Package last updated on 25 Aug 2023

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc