Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

language-detect

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

language-detect

Detect the programming language of any file.

  • 1.1.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
449
increased by4.18%
Maintainers
1
Weekly downloads
 
Created
Source

Language Detect

NPM version NPM downloads Build status Test coverage

Detect the programming language of any file by checking the file name, file extension, file shebang and falling back to a programming language classifier. For more language information, it should be used in conjunction with language-map.

Installation

npm install language-detect --save

Usage

var detect = require('language-detect');

Asynchronously From a File

detect(__dirname + '/test.js', function (err, language) {
  console.log(err);      //=> null
  console.log(language); //=> "JavaScript"
});

Synchronously From a File

detect.sync(__dirname + '/test.js'); //=> "JavaScript"

From The Filename and Contents

detect.contents(__dirname + '/test.js', 'var test = true;\n'); //=> "JavaScript"

From Only a Filename

detect.filename(__dirname + '/test.js'); //=> "JavaScript"

Check for Shebang

detect.shebang('#!/usr/bin/env node\n...'); //=> "JavaScript"

Run Classification

Uses language-classifier which can only detect a small subset of languages.

detect.classify('.test { color: red; }')

Other Properties

  • detect.aliases A map of known aliases
  • detect.interpreters A map of known interpreters
  • detect.extensions A map of known file extensions
  • detect.filenames A map of known file names

License

MIT

Keywords

FAQs

Package last updated on 14 Nov 2015

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