How to use repeating - 5 common examples

To help you get started, we’ve selected a few repeating 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 forivall / tacoscript / packages / tacotruck / src / printer / index.js View on Github external
_catchUp(newlines, parent) {
    if (newlines <= 0) return 0;
    if (
          // TODO: this will become unnecessary with future parsing udpates -- should remove
          parent && parent.type === "SequenceExpression" ||
        false) {
      // TODO: check other contexts
      // TODO: preserve indentation for escaped newlines
      this.push({type: tt.whitespace, value: {code: repeating("\\\n", newlines)}})
    } else {
      let first = true;
      for (let i = newlines; i > 0; i--) {
        this.newline(!first);
        first = false;
      }
    }
    return newlines;
  }
github decaffeinate / decaffeinate / src / utils / indentNode.js View on Github external
export default function indentNode(node, patcher, levels=1) {
  if (levels === 0) {
    return;
  }

  let source = patcher.original;
  let range = trimmedNodeRange(node, source);
  let offset = range[0];
  let indent = repeat(determineIndent(source), levels);

  while (offset < range[1]) {
    patcher.insert(offset, indent);
    offset = source.indexOf('\n', offset);
    if (offset < 0) {
      break;
    }
    while (source[offset] === '\n') {
      // Skip empty lines.
      offset += '\n'.length;
    }
  }
}
github forivall / tacoscript / packages / comal-traverse / src / scope / index.js View on Github external
dump() {
    let sep = repeating("-", 60);
    console.log(sep);
    let scope = this;
    do {
      console.log("#", scope.block.type);
      for (let name in scope.bindings) {
        let binding = scope.bindings[name];
        console.log(" -", name, {
          constant: binding.constant,
          references: binding.references,
          violations: binding.constantViolations.length,
          kind: binding.kind
        });
      }
    } while (scope = scope.parent);
    console.log(sep);
  }
github babel / babel / packages / babel-generator / src / buffer.js View on Github external
getIndent() {
    if (this.format.compact || this.format.concise) {
      return "";
    } else {
      return repeating(this.format.indent.style, this._indent);
    }
  }
github forivall / tacoscript / packages / horchata / src / lexer / serialization.js View on Github external
tt.tab.toCode = function(token, state) {
  return token.value ? repeating(state.format.indent.indent, token.value) : "";
};
tt.indent.toCode = function() {

repeating

Repeat a string - fast

MIT
Latest version published 3 years ago

Package Health Score

67 / 100
Full package analysis

Popular repeating functions