Socket
Socket
Sign inDemoInstall

flourite

Package Overview
Dependencies
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

flourite

A library for detecting the programming language of a code snippet.


Version published
Weekly downloads
663
decreased by-25.51%
Maintainers
1
Weekly downloads
 
Created
Source

Flourite - Language detector

A fork from ts95/lang-detector, rewritten in Typescript with more language support.

Detects a programming language from a given string.

  • Built-in support for CommonJS and ESM format
  • Built-in Typescript typings
  • No external dependencies
  • 100 test cases and growing!

Detectable languages

Languages
CJavascriptPython
C++JavaRuby
HTMLCSSPHP
SQLJuliaRust

Install

$ npm install flourite

Usage

import detectLang from 'flourite';

const code = detectLang('console.log("Hello World");'); // => Javascript

You could supply options to make see numbers of points for a certain language:

import detectLang from 'flourite';

const code = detectLang('printf("Hello World")', { statistics: true });
// {
//   detected: 'C',
//   statistics: [
//     [ 'C', 1 ],
//     [ 'Unknown', 1 ],
//     [ 'C++', 0 ],
//     [ 'CSS', 0 ],
//     [ 'Go', 0 ],
//     [ 'HTML', 0 ],
//     [ 'Java', 0 ],
//     [ 'Javascript', 0 ],
//     [ 'Julia', 0 ],
//     [ 'PHP', 0 ],
//     [ 'Python', 0 ],
//     [ 'Ruby', 0 ],
//     [ 'Rust', 0 ],
//     [ 'SQL', 0 ]
//   ]
// }

Development

  • Use the Node.js version as defined on the .nvmrc file.
  • Run npm run test:tdd to initiate a test driven development environment.
  • Run npm run lint and npm run format before commit a change.

License

MIT

Keywords

FAQs

Package last updated on 16 Aug 2021

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