You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
Socket

code-block-language-detector

Package Overview
Dependencies
Maintainers
0
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

code-block-language-detector - npm Package Compare versions

Comparing version

to
1.0.2

2

package.json
{
"name": "code-block-language-detector",
"version": "1.0.1",
"version": "1.0.2",
"main": "src/index.js",

@@ -5,0 +5,0 @@ "scripts": {

@@ -23,1 +23,52 @@ # Code Block Language Detector

```
### Usage
#### Basic Usage
Detect the programming language of a given code snippet:
const detectLanguage = require('code-block-language-detector');
const code = `const x = 42; console.log(x);`;
const language = detectLanguage(code);
console.log(language); // Output: 'javascript'
#### Restricting to Specific Languages
const detectLanguage = require('code-block-language-detector');
const code = `SELECT * FROM users WHERE age > 21;`;
const language = detectLanguage(code, ['sql', 'javascript', 'python']);
console.log(language); // Output: 'sql'
### Supported Languages
The following languages are currently supported:
JavaScript
Python
Java
C
C++
Ruby
PHP
TypeScript
Go
Swift
Kotlin
Rust
C#
HTML
CSS
JSON
YAML
Bash
SQL
Perl
R
Dart
Scala
Shell