Nixinova / LinguistJS

Analyse and list all languages used in a folder. Implementation of and powered by GitHub's Linguist.
ISC License
39 stars 12 forks source link

Add `minSize` option which moves small languages into `other` result #35

Open Nixinova opened 3 months ago

Nixinova commented 3 months ago

An implementation of a minSize option, proposed here:

This allows filtering the output to only show languages with a resulting size greater than what the user inputs.

This is done by moving the results of these too-small languages to an other key and deleting the original results.

This may be too ad-hoc - for instance, maybe this should be a CLI-only option and the actual data isn't changed? Is the other key needed, or not?

For this reason this feature is not being committed straight to main and will sit as a pull request for proposal.


Feedback would be welcome on the best implementation for this feature.

Example console output with this feature implemented:

C:\Users\Nixinova\Documents\GitHub\Linguist>node bin -a .

 Analysed 47,664 B from 20 files with linguist-js

 Language analysis results:

   1. █ TypeScript               79.57%     37,924 B
   2. █ JavaScript               10.85%      5,172 B
   3. █ JSON                      9.01%      4,296 B
   4. █ INI                       0.57%        272 B

 Total: 47,664 B
C:\Users\Nixinova\Documents\GitHub\Linguist>node bin -a . --minSize 5KB

 Analysed 47,664 B from 20 files with linguist-js

 Language analysis results:

   1. █ TypeScript               79.57%     37,924 B
   2. █ JavaScript               10.85%      5,172 B
   3. █ other                     9.58%      4,568 B

 Total: 47,664 B
Nixinova commented 3 months ago

The diff is very readable if anyone interested in this feature wants to look at the methodology of doing this - https://github.com/Nixinova/LinguistJS/pull/35/files