Security News
RubyGems.org Adds New Maintainer Role
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.
A fork of ts95/lang-detector, rewritten in Typescript with more language support.
Detects a programming language from a given string.
Languages | |||
---|---|---|---|
C | HTML | Lua | Rust |
C++ | Java | Pascal | SQL |
C# | Javascript | PHP | YAML |
CSS | Julia | Python | |
Go | Kotlin | Ruby |
$ npm install flourite
or via a CDN (unpkg or jsdelivr)
<script src="https://unpkg.com/flourite@1.1.1"></script>
<script src="https://cdn.jsdelivr.net/npm/flourite@1.1.1/dist/index.iife.js"></script>
import flourite from 'flourite';
const code = flourite('console.log("Hello World");'); // => Javascript
You could supply options to make see numbers of points for a certain language:
import flourite from 'flourite';
const code = flourite('printf("Hello World")', { statistics: true });
// code.detected = 'C'
// code.statistics = {
// C: 5,
// 'C++': 0,
// 'C#': 0,
// CSS: 0,
// Go: 0,
// HTML: 0,
// Java: 0,
// Javascript: 0,
// Julia: 0,
// Kotlin: 0,
// Lua: -20,
// Pascal: 0,
// PHP: 0,
// Python: 0,
// Ruby: 0,
// Rust: 0,
// SQL: 0,
// Unknown: 1,
// YAML: 0
// }
Or if you want to integrate it with Shiki, you could pass:
const code = flourite('Console.WriteLine("Hello world!");', { shiki: true }); // => csharp
If you want to handle Unknown
value, you could pass:
const code = flourite("SELECT 'Hello world!' text FROM dual;", { noUnknown: true });
import flourite from 'flourite';
import type { Options, StatisticOutput } from 'flourite';
const flouriteOptions: Options = {
heuristic: true,
statistics: true,
};
const code = flourite('print!({:?}, &v);', flouriteOptions) as StatisticOutput;
Key | Type | Default | Description |
---|---|---|---|
heuristic | boolean | true | Checks for codes on the top of the given input. Only checks when the lines of code is above 500. |
statistics | boolean | false | If true , will return the statistics of all the guessed language. |
shiki | boolean | false | Straightforward compatibility with Shiki's language specification type |
noUnknown | boolean | false | If true , will not output Unknown on detected and statistics result |
.nvmrc
file.npm run test:tdd
to initiate a test driven development environment.npm run lint
and npm run format
before commit a change.FAQs
A library for detecting the programming language of a code snippet.
The npm package flourite receives a total of 0 weekly downloads. As such, flourite popularity was classified as not popular.
We found that flourite demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
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.
Security News
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.
Security News
Node.js will be enforcing stricter semver-major PR policies a month before major releases to enhance stability and ensure reliable release candidates.
Security News
Research
Socket's threat research team has detected five malicious npm packages targeting Roblox developers, deploying malware to steal credentials and personal data.