Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
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
  • Socket score

Version published
Weekly downloads
225
decreased by-26.71%
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

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc