npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

border-comment-builder

v1.0.0-beta.0

Published

A generator of a nice border around comments in your code

Downloads

10

Readme

Border comment builder

What is this?

This is a tool that transforms text you put in stdin into a nice border like that:

/*
 * +---------------------+
 * | Nice block comment! |
 * +---------------------+
 */

You can insert that thing anywhere in your source code. It would be good to use it in a begin part of your source code.

Written in Node.js.

Launching app

Install app globally:

npm i -g border-comment-builder --unsafe-perm=true

And after that border-comment-builder terminal command will be available.

You can also start app with parameters:

border-comment-builder --type python --input comment.txt --output out.txt

echo and pipe calls help you get result on single line situation:

echo "Only single line comment" | border-comment-builder --type twig

JS API usage

You can tweak borders whatever you want.

A BorderCommentBuilder constructor gets an object of params and returns compiled string.

BorderCommentBuilder constructor options

An example:

const resultString = new BorderCommentBuilder({
  text: "123\n456",
  sideSymbolLeft: "< ",
  sideSymbolRight: " >",
  cornerSymbol: "U",
}).build();

Compiled string will be:

/*
 * U-----U
 * < 123 >
 * < 456 >
 * U-----U
 */

Types of comments (predefined)

js and also by default

/*
 * +-------+
 * | a b c |
 * +-------+
 */

c

  //
  // +-------+
  // | a b c |
  // +-------+
  //

pascal

  (*
   * +-------+
   * | a b c |
   * +-------+
   *)

python

  #
  # +-------+
  # | a b c |
  # +-------+
  #

html

<!--
    -- +-------+
    -- | a b c |
    -- +-------+
    -->

twig

  {#
   # +-------+
   # | a b c |
   # +-------+
   #}

All these borders defined in pre-defined-borders.json file.

CLI util arguments

| argv | Description | | -------------------------- | ---------------------------------------------------- | | --type <type_of comment> | Type of comment. See "Types of comments" section | | --input <my_comment.txt> | File containing comment to be processed | | --output <result.txt> | File where result comment will be written | | --before-border "(%" | beforeBorder option | | --middle-border " % " | middleBorder option | | --after-border "%)" | afterBorder option | | --border-symbol "=" | borderSymbol option | | --corner-symbol "#" | cornerSymbol option | | --side-symbol-left "/" | sideSymbolLeft option | | --side-symbol-right "\\" | sideSymbolRight option |

The text of comment sets line-by-line from cli, but also can be read from file.

When you finish writing the text press any of EOF combination (Ctrl+D in Unix-like systems and Ctrl+Z in Win).

Additional commands

  • npm run build generates build directory.

  • npm run clean removes build directory.

  • npm run test launches Mocha test utility to check some costructor calls going right.