🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
Book a DemoInstallSign in
Socket

detect-programming-language

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

detect-programming-language

Detects programming languages by file extension insanely fast.

1.0.4
latest
Source
npm
Version published
Weekly downloads
267
-21.93%
Maintainers
1
Weekly downloads
 
Created
Source

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.

Keywords

Programming

FAQs

Package last updated on 15 Jul 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts