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

broccoli-filter

Package Overview
Dependencies
Maintainers
3
Versions
18
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

broccoli-filter

Helper base class for Broccoli plugins that map input files into output files one-to-one

  • 1.2.1
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
56K
decreased by-54.19%
Maintainers
3
Weekly downloads
 
Created

What is broccoli-filter?

The broccoli-filter package is a base class for Broccoli plugins that map input files to output files. It is used to create plugins that process files in a Broccoli build pipeline, such as transpiling, minifying, or compiling files.

What are broccoli-filter's main functionalities?

File Transformation

This code demonstrates how to create a custom Broccoli filter that transforms JavaScript files by replacing all instances of 'console.log' with 'console.debug'. The 'processString' method is where the transformation logic is implemented.

const Filter = require('broccoli-filter');

class MyFilter extends Filter {
  constructor(inputNode) {
    super(inputNode);
  }

  get extensions() {
    return ['js'];
  }

  get targetExtension() {
    return 'js';
  }

  processString(content, relativePath) {
    // Perform some transformation on the content
    return content.replace(/console\.log/g, 'console.debug');
  }
}

module.exports = MyFilter;

Handling Multiple File Types

This code demonstrates how to create a Broccoli filter that processes multiple file types (JavaScript and CSS) and outputs them with a '.txt' extension. The 'processString' method adds a comment at the beginning of each file.

const Filter = require('broccoli-filter');

class MultiTypeFilter extends Filter {
  constructor(inputNode) {
    super(inputNode);
  }

  get extensions() {
    return ['js', 'css'];
  }

  get targetExtension() {
    return 'txt';
  }

  processString(content, relativePath) {
    // Perform some transformation on the content
    return `/* Processed File */\n${content}`;
  }
}

module.exports = MultiTypeFilter;

Other packages similar to broccoli-filter

Keywords

FAQs

Package last updated on 21 Aug 2015

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