Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@contrast/rewriter

Package Overview
Dependencies
Maintainers
17
Versions
34
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

  • 1.0.1
  • npm
  • Socket score

Version published
Weekly downloads
16K
decreased by-11.34%
Maintainers
17
Weekly downloads
 
Created
Source

@contrast/rewriter

Provides a configured service for rewriting code.

Basic idea: Enabled features can register rewrite transforms to support their end goal.

Example: Assess

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({ config, 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.rewriteFile({
  content: 'function add(x, y) { return x + y; }'
});

FAQs

Package last updated on 08 Jul 2022

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