Security News
CISA Brings KEV Data to GitHub
CISA's KEV data is now on GitHub, offering easier access, API integration, commit history tracking, and automated updates for security teams and researchers.
broccoli-multi-filter
Advanced tools
Helper base class for Broccoli plugins that map input files into output files one-to-many
Helper base class for Broccoli plugins that map input files into output files
one-to-many. This class is a drop-in replacement for broccoli-filter
.
class MultiFilter {
/**
* Abstract base-class for filtering purposes.
*
* Enforces that it is invoked on an instance of a class which prototypically
* inherits from Filter, and which is not itself Filter.
*/
constructor(inputNode: BroccoliNode, options: FilterOptions): MultiFilter;
/**
* Abstract method `processString`: must be implemented on subclasses of
* MultiFilter.
*
* The `addOutputFile` callback accepts two arguments `(contents: string, outputRelativeFilename: string)`
* this file must be called to generate any side-effect files and make sure they are handled properly with
* the caching layer.
*
* The return value is written as the contents of the output file
*/
abstract processString(contents: string, relativePath: string, addOutputFile: Function): string;
/**
* Virtual method `getDestFilePath`: determine whether the source file should
* be processed, and optionally rename the output file when processing occurs.
*
* Return `null` to pass the file through without processing. Return
* `relativePath` to process the file with `processString`. Return a
* different path to process the file with `processString` and rename it.
*
* By default, if the options passed into the `MultiFilter` constructor contain a
* property `extensions`, and `targetExtension` is supplied, the first matching
* extension in the list is replaced with the `targetExtension` option's value.
*/
virtual getDestFilePath(relativePath: string): string;
}
extensions
: An array of file extensions to process, e.g. ['md', 'markdown']
.targetExtension
: The file extension of the corresponding output files, e.g.
'html'
.inputEncoding
: The character encoding used for reading input files to be
processed (default: 'utf8'
). For binary files, pass null
to receive a
Buffer
object in processString
.outputEncoding
: The character encoding used for writing output files after
processing (default: 'utf8'
). For binary files, pass null
and return a
Buffer
object from processString
.name
, annotation
: Same as
broccoli-plugin;
see there.All options except name
and annotation
can also be set on the prototype
instead of being passed into the constructor.
var MultiFilter = require('broccoli-multi-filter');
Awk.prototype = Object.create(MultiFilter.prototype);
Awk.prototype.constructor = Awk;
function Awk(inputNode, search, replace, options) {
options = options || {};
MultiFilter.call(this, inputNode, {
annotation: options.annotation
});
this.keepOriginal = options.keepOriginal;
this.search = search;
this.replace = replace;
}
Awk.prototype.extensions = ['txt'];
Awk.prototype.targetExtension = 'txt';
Awk.prototype.processString = function(content, relativePath, addOutputFile) {
// Record the original content, but this could be a sourcemap file or any other side-effect.
// This can also be called multiple times -- once for each non-primary file.
if (this.keepOriginal) {
addOutputFile(content, relativePath + ".original");
}
return content.replace(this.search, this.replace);
};
In Brocfile.js
, use your new Awk
plugin like so:
var node = new Awk('docs', 'ES6', 'ECMAScript 2015');
module.exports = node;
broccoli-filter
broccoli-multi-filter
.addOutputFile
argument to your implementation of processString
.addOutputFile
to generate any additional files you need to generate.FAQs
Helper base class for Broccoli plugins that map input files into output files one-to-many
The npm package broccoli-multi-filter receives a total of 11 weekly downloads. As such, broccoli-multi-filter popularity was classified as not popular.
We found that broccoli-multi-filter demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer 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
CISA's KEV data is now on GitHub, offering easier access, API integration, commit history tracking, and automated updates for security teams and researchers.
Security News
Opengrep forks Semgrep to preserve open source SAST in response to controversial licensing changes.
Security News
Critics call the Node.js EOL CVE a misuse of the system, sparking debate over CVE standards and the growing noise in vulnerability databases.