Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
if (!this.compilers[node.type] && this.options.knownOnly !== true) {
this.set(node.type, util.noop);
}
var compilerOpts = this.options.compiler || {};
var visitor = compilerOpts[node.type];
if (visitor === false) {
return;
}
// run any registered "before" plugins
node = before.call(this, node) || node;
// add or remove this node type from `state.types`
if (util.isOpen(node)) util.addType(this.state, node);
if (util.isClose(node)) util.removeType(this.state, node);
if (typeof visitor === 'function') {
node = visitor.apply(this, arguments) || node;
} else {
node = visit.apply(this, arguments) || node;
}
// run any registered "after" plugins
node = after.call(this, node) || node;
return node;
};
}
this.emitter.emit('node', node);
var fn = this.compilers[node.type] || this.compilers.unknown;
if (typeof fn !== 'function') {
throw this.error('compiler "' + node.type + '" is not registered', node);
}
var val = fn.call(this, node) || node;
if (util.isNode(val)) {
node = val;
}
if (util.isClose(node)) {
util.removeType(this.state, node);
}
return node;
},