Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
jsPreprocess(jsText) {
let newContent = jsText;
// check the code for js errors before sending it to strip comments
// or loops.
JSHINT(newContent);
if (JSHINT.errors.length === 0) {
newContent = decomment(newContent, {
ignore: /\/\/\s*noprotect/g,
space: true
});
newContent = loopProtect(newContent);
}
return newContent;
}
jsPreprocess(jsText) {
let newContent = jsText;
// check the code for js errors before sending it to strip comments
// or loops.
JSHINT(newContent);
if (JSHINT.errors.length === 0) {
newContent = decomment(newContent, {
ignore: /\/\/\s*noprotect/g,
space: true
});
newContent = loopProtect(newContent);
}
return newContent;
}
getText() {
if (this.props.isEnabled) {
if (this.props.stageOperator) {
if (this.props.stageOperator === OUT && this.props.isValid) {
return `Documents will be saved to the collection: ${decomment(this.props.stageValue)}`;
}
const stageInfo = STAGE_SPRINKLE_MAPPINGS[this.props.stageOperator];
return (
<div>
<span>
Output after <span>
{this.props.stageOperator}
</span> stage
</span>
{this.renderInfoSprinkle(stageInfo)}
<span>(Sample of {this.props.count} {this.getWord()})</span>
</div>
);
}
renderOutSection() {
if (this.props.isComplete) {
return (
<div>
<div>
Documents persisted to collection: {decomment(this.props.stage)}.
</div>
<div>
Go to collection.
</div>
</div>
);
}
return (
<div>
<div>
The $out operator will cause the pipeline to persist the results
to the specified collection. If the collection exists it will be
replaced. Please confirm to execute.
</div></div>
export default function generateStage(state) {
if (!state.isEnabled || !state.stageOperator || state.stage === '') {
return {};
}
const stage = {};
try {
const decommented = decomment(state.stage);
parse(`{${state.stageOperator}: ${decommented}}`);
stage[state.stageOperator] = parser(decommented);
} catch (e) {
state.syntaxError = e.message;
state.isValid = false;
state.previewDocuments = [];
return {};
}
state.isValid = true;
state.syntaxError = null;
return stage;
}