Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const { Writable } = require('stream');
const esprima = require('esprima');
const fs = require('fs');
const safe = require('./safe-regexp');
const color = require('colors-cli/safe');
const error = color.red.bold;
const notice = color.magenta;
const warn = color.red;
class RedosScanner extends Writable {
constructor() {
super();
this.issues = {};
}
_write(filePath, enc, next) {
const instance = this;
fs.readFile(filePath, 'utf8', handleFile);
function handleFile(err, file) {
try {
esprima.tokenize(file, { loc: true, range: true, comment: true }, handleToken(instance, filePath));
} catch (err) { } // eslint-disable-line