Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Suggestion: writer.pairedWrite(startToken, endToken, newLine, indent, block: () => void) #44

Open
ajvincent opened this issue Mar 24, 2023 · 0 comments

Comments

@ajvincent
Copy link

ajvincent commented Mar 24, 2023

I like block(), quote(), etc. But there are other pairings of tokens which are important: parentheses, square brackets, backticks for template strings, etc.

Suggested code:

  pairedWrite(
    startToken: string,
    endToken: string,
    newLine: boolean,
    indent: boolean,
    block: () => void
  ) : void
  {
    this.write(startToken);
    if (newLine) this.newLine();
    indent ? this.indent(block) : block();
    if (newLine) this.newLine();
    this.write(endToken);
  }

Paired writes could also be useful for (// #region ..., // #endregion ...) cases.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant