detect-programming-language

1.0.4 • Public • Published

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

	
		import getProgrammingLanguage from "detect-programming-language";

	    getProgrammingLanguage(".rs"); // Returns 'Rust'.
	

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.

Package Sidebar

Install

npm i detect-programming-language

Weekly Downloads

319

Version

1.0.4

License

MIT

Unpacked Size

37.7 kB

Total Files

8

Last publish

Collaborators

  • lorenzobloedow