How to use decomment - 9 common examples

To help you get started, we’ve selected a few decomment examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github electricimp / Builder / src / AstParser.js View on Github external
let matches, type, arg;
    const lines = source.match(LINES);

    for (let i = 0; i < lines.length - 1 /* last line is always empty */; i++) {
      const text = lines[i];

      if (matches = text.match(DIRECTIVE)) {
        const token = {_line: 1 + i};

        type = matches[1];
        arg = matches[2].trim();
        token.args = [];

        // remove single line comments from arg
        arg = decomment.text(arg);

        switch (type) {

          case 'include':
            // detect "once" flag
            if (/^once\b/.test(arg)) {
              token.args.push('once');
              arg = arg.substr(5).trim();
            }

            this._checkArgumentIsNonempty(type, arg, token._line);
            token.type = TOKENS.INCLUDE;
            token.args.push(arg);
            break;

          case 'set':
github processing / p5.js-web-editor / client / modules / IDE / components / PreviewFrame.jsx View on Github external
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;
  }
github processing / p5.js-web-editor / client / modules / IDE / components / PreviewFrame.jsx View on Github external
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;
  }
github stoikerty / dev-toolkit / src / packages / dev-toolkit / src / postinstall-prepare / copy-templates.js View on Github external
.then(data => {
        // Uncomment files as if they were plain text files (avoiding issues with jsx)
        outputFile(filePath, decomment.text(data));
      })
      .catch(err => {
github bucharest-gold / szero / lib / reader.js View on Github external
function getFileLines (file) {
  const lines = [];
  let decommented, EOL;
  const strFile = fs.readFileSync(file).toString().replace(/#/g, ' ');
  try {
    EOL = decomment.getEOL(strFile);
    decommented = decomment(strFile);
  } catch (e) {
    console.error(file, e);
    return lines;
  }
  decommented.split(EOL)
    .forEach(line => lines.push(line));
  return lines;
}
github mongodb-js / compass-aggregations / src / components / stage-preview-toolbar / stage-preview-toolbar.jsx View on Github external
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>
        );
      }
github mongodb-js / compass-aggregations / src / components / stage-preview / stage-preview.jsx View on Github external
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>
github mongodb-js / compass-aggregations / src / modules / stage.js View on Github external
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;
}
github vitaly-t / gulp-decomment / index.js View on Github external
gulpDecomment.html = function (options) {
    return main(options, decomment.html);
};

decomment

Removes comments from JSON/JavaScript, CSS/HTML, CPP/H, etc.

MIT
Latest version published 3 years ago

Package Health Score

50 / 100
Full package analysis