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 🙏

© 2026 – Pkg Stats / Ryan Hefner

leijona

v1.0.8

Published

Line count tool for modern applications

Readme

leijona

Leijona (LAY-uh-nuh) is a line count tool for modern applications. From the Finnish word for "lion", because "lion" sounds like "line".

Hear how to pronounce "leijona" here.

Contents

Installation

Install the package globally using npm i -g leijona, or download the zip.

Running

If you downloaded it with npm, you should be able to simply call leijona as a command-line executable from the directory you wish to count.

If you downloaded the .zip, extract it, then run node <location of the extracted leijona/ dir> from the directory of the project you want to count.

Command line arguments

There are no command line arguments for leijona. All configuration is done through leijona.json.

Configuration

There is plenty to configure to get leijona working just the way you want it to. In the project root there is a sample leijona.json file which contains all available options. You can include your own leijona.json file in the directory you are running the script from and it will override the default configuration.

Format

"format": "html"

html will generate an .html file with a table displaying the results.

csv will generate a comma-separated list of values in a CSV file.

More to come.

Output File

"outputFile": "line-count.html"

The name of the file to output results to. You should generally give this file the extension to match what you chose for the format option, but you have the freedom to choose any filename you wish.

Count Inclusions

"count": {
	"comments": true,
	"trivial": true,
	"empty": false
}

Leijona categorizes code in four different ways:

  • source lines include any line of code containing at least one character that is not a symbol
  • comments include any line beginning with a series of characters matching at least one series in the commentCharacters portion of leijona.json
  • trivial lines of code encompass any line that contains symbols, but no alphanumeric characters
  • empty lines of code are lines that do not contain anything other than whitespace, line breaks, tabs, and carriage returns.

Using this entry, you can choose to individually include or exclude any line of code that leijona considers to be trivial, empty, or beginning with comments. source lines cannot be excluded. The total number of lines shown on the output is a reflection of only the lines you include.

Comment Characters

"commentCharacters": [
	"/*",
	"*/",
	"* ",
	"//",
	"#",
	"<!--"
],

Any line beginning with a series of characters that exactly matches any of the items in this list will be counted as a comment. These are passed into a regex, but do not need to be escaped. Enter only the literal character sequences you wish to count as comments.

Exclusions

"exclude": {
	"paths": [
		".git/",
		"node_modules/",
		"vendor/",
		"package.json"
	],
	"fileTypes": [
		"mp3",
		"gif",
		"jpeg"
	]
}

Leijona can blacklist files, directories, and filetypes from being counted.

Each file or directory's path relative to the directory in which leijona is run will be compared to the paths list. If it is found to match any entry in paths it will be excluded from being counted. The trailing / on directories is optional, but recommended for slightly easier readability.

Likewise, specific file types can be excluded altogether if you add them to the fileTypes list. You may include the leading . if you wish (e.g. .mp3), but mp3 will work just fine.

Since leijona.json can be overridden per project, you can have separate exclusions on a per-project basis.

License

Leijona is licensed under the GNU General Public License v3.0. See LICENSE.txt in the project root for more information.

Feel free to fork this repo and do whatever you want with it, as long as you keep it open source. I would appreciate credit but it's not necessary.

Issues

If you have issues, comments, or suggestions, please feel free to make an issue on Github.

Troubleshooting

Can't install package globally without sudo

See this link to fix your node permissions.