lang-detector
A fast and small library for detecting the programming language of a code snippet.
Can be used for strings of code spanning multiple thousand lines.
This library should only be used if you don't have anything else to go by to determine the language of the code, like a file extension.
Detectable languages
- JavaScript
- C
- C++
- Python
- Java
- HTML
- CSS
- Ruby
- Go
- PHP
Install
npm install lang-detector --save
Usage
var detectLang = require('lang-detector');
detectLang('List<String> things = new ArrayList<>();')
detectLang('console.log("Hello world");')
detectLang('Hello world.', { statistics: true })
Unit tests
Run npm test
in the root of the directory to run the tests.
License
MIT © Toni Sučić