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

@igor.dvlpr/comment-it

v3.1.0

Published

📜 Formats the provided string as a comment, either a single or a multi line comment for the given programming language. 💻

Downloads

2

Readme

/* CommentIt! */

📜 Formats the provided string as a comment, either a single or a multi line comment for the given programming language. 💻

🕵🏼 Usage

Install it by executing:

npm i "@igor.dvlpr/comment-it"

🤹🏼 API

getLanguageIds()

getLanguageIds(): string[]

Gets IDs of all available language formatters. Language formatters are callable as comment.<languageId>. See more below at comment.

language()

language(id: string): CommentFormatter | null

Performs a case-insensitive search for a language formatter with the provided id and returns it - if one is found - else returns null.

supportsLanguage()

supportsLanguage(id: string): boolean

Returns whether the given language formatter is supported, case-insensitive.

See the comment object below for available valid identifiers.

alias()

 alias(id: CommentLanguage, alias: string): boolean

Adds an alias for an existing comment formatter. Returns true upon success, false otherwise.

comment

An object where all formatters are stored.

comment's properties/formatters:

  • comment.ada - Ada
  • comment.bash - Bash
  • comment.batch - Batch
  • comment.c - C
  • comment.carbon - Carbon
  • comment.cSharp - C#
  • comment.coffeeScript - CoffeeScript
  • comment.cpp - C++
  • comment.crystal - Crystal
  • comment.css - CSS
  • comment.dart - Dart
  • comment.delphi - Delphi
  • comment.dockerFile - Dockerfile
  • comment.elixir - Elixir
  • comment.erlang - Erlang
  • comment.euphoria - Euphoria
  • comment.fortran - Fortran
  • comment.fSharp - F#
  • comment.genie - Genie
  • comment.go - Go
  • comment.groovy - Groovy
  • comment.hack - Hack
  • comment.haskell - Haskell
  • comment.html - HTML
  • comment.icon - Icon
  • comment.java - Java
  • comment.javaScript - JavaScript
  • comment.jsx - JSX
  • comment.julia - Julia
  • comment.kotlin - Kotlin
  • comment.lisp - Lisp
  • comment.liveCode - LiveCode
  • comment.lua - Lua
  • comment.maple - Maple
  • comment.matlab - MATLAB
  • comment.mercury - Mercury
  • comment.mql4 - MQL4
  • comment.objectiveC - Objective-C
  • comment.objectiveCpp - Objective-C++
  • comment.oz - Oz
  • comment.pascal - Pascal
  • comment.perl - Perl
  • comment.php - PHP
  • comment.powerShell - PowerShell
  • comment.pug - Pug/Jade
  • comment.python - Python
  • comment.q - Q
  • comment.r - R
  • comment.razor - Razor
  • comment.red - Red
  • comment.ring - Ring
  • comment.ruby - Ruby
  • comment.rust - Rust
  • comment.scala - Scala
  • comment.sql - SQL
  • comment.swift - Swift
  • comment.typeScript - TypeScript
  • comment.vala - Vala
  • comment.visualBasic - VisualBasic
  • comment.vue - Vue
  • comment.vueHtml - VueHtml
  • comment.xml - XML

Each formatter exposes two functions, single() for single-line comments and multi() for multi-line comments.

single()
single(value: string): string

Returns a single-line comment formatted for the selected language.

multi()
multi(value: string): string

Returns a multi-line comment formatted for the selected language.

Examples

import { comment, supportsLanguage } from '@igor.dvlpr/comment-it'

const singleLine: string = 'hello world'
const multiLine: string = `hello


world

this is a test`

console.log(comment.javaScript.single(singleLine)) // prints '// hello world'

console.log(comment.jsx.single(singleLine)) // prints '{/* hello world */}'

console.log(comment.coffeeScript.multi(multiLine)) // prints '###\nhello\n\n\nworld\n\nthis is a test\n###'

// note: new lines in the example results are written as-is for brevity

console.log(supportsLanguage('lua')) // prints true
console.log(supportsLanguage('TYPEscript')) // prints true
console.log(supportsLanguage('foo')) // prints false

🪪 License

Licensed under the MIT license which is available here, MIT license.


🧬 Related

@igor.dvlpr/mapped-replacer

🗺 Zero-dependency Map and RegExp based string replacer with Unicode support. 🍁

@igor.dvlpr/jmap

🕶️ Reads a JSON file into a Map. 🌻

@igor.dvlpr/strip-html-headings

🍛 Strips HTML headings! 🍤

@igor.dvlpr/strip-headings

⛸ Strips Markdown headings! 🏹

@igor.dvlpr/unc-path

🥽 Provides ways of parsing UNC paths and checking whether they are valid. 🎱

Provided by Igor Dimitrijević (@igorskyflyer).