detect-programming-language
v1.0.4
Published
Detects programming languages by file extension insanely fast.
Downloads
1,213
Maintainers
Readme
About
This is a package that provides a single function: getProgrammingLanguage(fileName)
which returns the name of the programming language associated with the filename you provided. This is done by extracting the file extension.
Time complexity
The time complexity for calling getProgrammingLanguage(fileName)
is constant, that means:
Best case: O(1)
Worst case: O(1)
Installation
npm install detect-programming-language
Usage
Notes
- This package has native TypeScript support, no need to install anything else.
- The file extensions and their corresponding language names are pulled from a local copy of: https://raw.githubusercontent.com/github/linguist/master/lib/linguist/languages.yml
- Only programming languages are considered, markup, data interchange formats and others are not.
- If the function is unable to match a filename to a programming language it returns undefined.