Observed since 20 Oct, 22:04 UTC
No superseded metadata states collected. Unchanged observations do not create new revisions.
modern code counter
https://www.npmjs.com/package/@0b1.org/loci
I have been a huge fan of Cloc for many years. In fact, I have used it so often on new projects that other code counters just don't give me the confidence: Any other code counter and I would be "comparing apples to oranges" - they don't all give the same results.
Unfortunately many environments don't allow custom binaries, ruling out cloc as a Perl script AND cloc.exe.
Node, however, is more prevalent, so I decided to see if I could create a close cousin of cloc written in node.
I think I succeeeded, but the Open Source community will be the ultimate judge.
There is still a few minor differences between the two. Loci excludes the folders bin, obj and .vscode by default, whereas Cloc does not. Cloc also has a very mature feature list that Loci does not: git repo querying, diffs, sql generation. If you need those features, Cloc remains the better choice.
Cloc is faster on smaller groups of files but only by fractions of a second. For bulk scanning Loci invokes worker threads so that counting can continue without waiting for file i/o.
In Cloc definitions are spread throughout the Perl functions, but in Loci definitions fare stored as YAML definition files. This means new languages can be added quickly and easily. And at ~7,500 lines of SOLID code = data to CLOC's 17,000 lines in a single script, its a little more maintainable, imo.
Performance comparisons show Loci outperforming Cloc at almost all code sizes

To install for command line usage, enter the command
>npm install -g @0b1.org/loci
To remove the CLI, enter the command
npm remove -g @0b1.org/loci
Basic help:
loci --helploci --show:environmentalsloci --show:defaultsloci --show:options (includes any command line switches and selected folders)loci --show:languagesBasic scanning:
loci c:\_dev\OLD_CODE\uisdkloci --unique c:\_dev\OLD_CODE\uisdkloci --unique --xd:+backup c:\_dev\OLD_CODE\uisdkloci --unique --xd:backup c:\_dev\OLD_CODE\uisdk
Separated lists in switches with semicolons. Separate lists of folders to scan with spaces. (if your folder names have spaces, wrap them in double quotes)
Link to full help: https://github.com/0bOne/loci/blob/main/lib/data/help/basic-usage.txt
Environment Variable information: https://github.com/0bOne/loci/blob/main/lib/data/help/environmentals.txt
You can include the npm package in your own project.
In your current project enter the command npm install @0b1.org/loci
For the simplest use, which just wraps the CLI, use:
const Loci = require ("@0b1.org/loci/lib/Loci");
Loci.CLIScan();
And you can run your own code as though it were Loci:
node index.js --unique .
This, of course, is not much use. A more complete program would look like this:
const Loci = require ("@0b1.org/loci/lib/Loci");
const options = Loci.LoadDefaultOptions();
options.sources.push("scan_this_folder);
options.xf.push("not_this_subfolder");
options.threads = 5;
//the default logger logs to the console.
//Or pass in your own logger implementing the same methods
const logger = Loci.GetLogger(options);
//instantiate and scan
const scanner = new Loci(logger);
const output = scanner.Scan(options);
//format and display the output.
//Alternatively, process the json object elsewhere in your project.
const formatter = Loci.GetFormatter(options);
const textResult = formatter.Format(output);
Loci.Output(textResult, options);
That's it! Happy coding!
Please inlude the command line switches, environment variables, or programmatic options. If possible, also include the code file that loci did not process as expected.
PLEASE check the existing bug list before submitting
If you would like a language added, you can experiment yourself by editing languages.yaml or send us some sample files.
You can contact me at sourcecoder0b1@gmail.com
Even a small open source project like this takes a fair amount of time. If you would like to contribute, please let me know!
The license is MIT, so feel free to branch and experiment as you please. (But bear in mind it is benefits the community more if one project is improved than if multiple derivations exist)
Download counts and popularity will appear here as the collector receives them.
This describes our collected data; it is not a security assessment.
Observed since 20 Oct, 22:04 UTC
No superseded metadata states collected. Unchanged observations do not create new revisions.
package:af9be83610f458b79cb787116d6a1dacd268045e1620f5ecc603b275feb24872