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

scnt

v1.0.3

Published

Utility program/library for counting source code lines

Downloads

11

Readme

SCNT - Source Count

NodeJS utility program for counting source code lines (aka. SLOC).

Running this program in a folder, will parse each file in the directory (or directories depending on usage) and attempt to count the number of lines, characters, white-space, and comments (both block and inline if the language supports it).

After parsing and counting is complete, it outputs a tabular report of the findings.

Installation

The preferred usage is to install it as a program, ideally globally.

npm install -g scnt
npm i -g scnt

yarn global add scnt

If you want to use it as a Node module, or in API mode, then install it locally.

npm install --save scnt
npm i -s scnt

yarn add scnt

Usage

scnt [options] [<file>|<directory>|<glob>...]

Running scnt with no options will execute with the default configuration. By default, this will parse the contents of the current working directory with the standard parsers.

Additional help is available using the -h or --help argument.

Available Options

| Argument | Description | |:--------------------------------------|:----------------------------------------------------------------------------------------------------| | -v, --version | output the version number | | -D, --debug | extra output info when processing (default: false) | | -i, --ignore-errors | logs IO errors but continues processing (default: false) | | -e, --exclude <regex> | excludes the files that match the regular expression, stackable with multiple usages (default: []) | | -a, --alias <extension>=<extension> | alias one extension for another, stackable with multiple usages (default: {}) | | -p, --parsers <parsers...> | list of Parser IDs to use, defaults to all | | -d, --default <parser> | sets the default parser to use for unknowns by Parser ID (default is none, they are skipped) | | -l, --list-parsers | lists the available parser id keys, only this will be performed if provided | | --dry-run | does not read any files, just outputs all the debug information up to that point | | -h, --help | display help for command |

Available Parsers

Plain Text

ID: plain

Name: "Plain Text"

Supported extensions: .txt, .md

C-Family

ID: cfamily

Name: "C-Family"

Supported extensions: .c, .cpp, .cc, .cxx, .cs, .h, .hpp, .hx, .js, .mjs, .jsx, .ts, .tsx, .java, .kt, .kts, .ktm, .php, .php5, .m, .mm, .swift, .scala, .sc, .sass, .scss, .less, .go, .rs

Example output

This output is taken directly from running scnt in the root folder of this repository, with no options.

Searching paths for ./*...
Processing file C:/scnt/clean.js
Processing file C:/scnt/LICENSE
Processing file C:/scnt/package-lock.json
Processing file C:/scnt/package.json
Processing file C:/scnt/README.md
Processing file C:/scnt/tsconfig.json
Completed processing 2 files

┌────────────────────────────┬────┐
│ Total of All Lines         │ 83 │
├────────────────────────────┼────┤
│ Total Source Lines         │ 52 │
├────────────────────────────┼────┤
│ Source Only Lines          │ 51 │
├────────────────────────────┼────┤
│ Total Comment Lines        │ 5  │
├────────────────────────────┼────┤
│ Inline Comment Lines       │ 0  │
├────────────────────────────┼────┤
│ Block Comment Lines        │ 4  │
├────────────────────────────┼────┤
│ Mixes Source/Comment Lines │ 1  │
├────────────────────────────┼────┤
│ Whitespace Only Lines      │ 0  │
├────────────────────────────┼────┤
│ Empty Lines                │ 27 │
└────────────────────────────┴────┘

┌─────────────────────────┬──────┐
│ Total Characters        │ 3032 │
├─────────────────────────┼──────┤
│ Source Characters       │ 1959 │
├─────────────────────────┼──────┤
│ Comment Characters      │ 96   │
├─────────────────────────┼──────┤
│ Whitespace Characters   │ 994  │
├─────────────────────────┼──────┤
│ Numerical Characters    │ 1    │
├─────────────────────────┼──────┤
│ Alphabetical Characters │ 1555 │
├─────────────────────────┼──────┤
│ Special Characters      │ 482  │
└─────────────────────────┴──────┘

License

MIT License.

See file LICENSE for full details. Licensed under the MIT license.