Socket
Socket
Sign inDemoInstall

@vscode/vscode-languagedetection

Package Overview
Dependencies
0
Maintainers
10
Versions
22
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.0.8 to 1.0.9

17

dist/lib/index.js.LICENSE.txt

@@ -203,19 +203,2 @@ /**

/**
* @license
* Copyright 2021 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
/** @license See the LICENSE file. */

10

package.json
{
"name": "@vscode/vscode-languagedetection",
"version": "1.0.8",
"version": "1.0.9",
"description": "An npm package that uses guesslang's ML model to detect source code languages",
"main": "dist/lib/index.commonjs.js",
"main": "dist/lib/index.js",
"module": "dist/lib/index.js",

@@ -25,6 +25,4 @@ "types": "dist/lib/index.d.ts",

"homepage": "https://github.com/microsoft/vscode-languagedetection#readme",
"dependencies": {
"@tensorflow/tfjs": "^3.7.0"
},
"devDependencies": {
"@tensorflow/tfjs": "^3.7.0",
"@types/chai": "^4.2.21",

@@ -42,5 +40,5 @@ "@types/mocha": "8.2.3",

"typescript": "^4.3.5",
"webpack": "^5.44.0",
"webpack": "~5.44.0",
"webpack-cli": "^4.7.2"
}
}

88

README.md

@@ -1,13 +0,85 @@

# Project
# vscode-languagedetection
> This repo has been populated by an initial template to help get you started. Please
> make sure to update the content to build a great experience for community-building.
An npm package that uses machine learning to detect source code languages. Powered by [@yoeo](https://github.com/yoeo)'s [guesslang](https://github.com/yoeo/guesslang) model!
As the maintainer of this project, please make a few updates:
Usage:
- Improving this README.MD file to provide a great experience
- Updating SUPPORT.MD with content about this project's support experience
- Understanding the security reporting process in SECURITY.MD
- Remove this section from the README
First install it in your project:
```sh
npm install --save @vscode/vscode-languagedetection
# or using yarn
yarn add @vscode/vscode-languagedetection
```
Then instantiate a ModuleOperations and pass it in the `model.json` and `weights` file content:
> NOTE: This is only for VS Code. In the future, you shouldn't have to do this.
```ts
import { ModelJSON, ModelOperations } from "@vscode/vscode-languagedetection";
const modulOperations = new ModelOperations(async () => {
return JSON.parse(readFileSync(join(__dirname, '..', '..', 'model', 'model.json')).toString()) as ModelJSON;
}, async () => {
return readFileSync(join(__dirname, '..', '..', 'model', 'group1-shard1of1.bin')).buffer;
});
const result = await modulOperations.runModel(`
function makeThing(): Thing {
let size = 0;
return {
get size(): number {
return size;
},
set size(value: string | number | boolean) {
let num = Number(value);
// Don't allow NaN and stuff.
if (!Number.isFinite(num)) {
size = 0;
return;
}
size = num;
},
};
}
`);
```
which will give you the following in order of confidence:
```ts
[
{ languageId: 'ts', confidence: 0.48307517170906067 },
{ languageId: 'rs', confidence: 0.10045434534549713 },
{ languageId: 'js', confidence: 0.07833506911993027 },
{ languageId: 'c', confidence: 0.045049071311950684 },
{ languageId: 'lua', confidence: 0.044198162853717804 },
{ languageId: 'cpp', confidence: 0.03847603127360344 },
{ languageId: 'cs', confidence: 0.03298814222216606 },
{ languageId: 'mm', confidence: 0.02999635599553585 },
{ languageId: 'html', confidence: 0.01874217577278614 },
{ languageId: 'sql', confidence: 0.01811739057302475 },
{ languageId: 'swift', confidence: 0.01418407540768385 },
{ languageId: 'pl', confidence: 0.014126052148640156 },
{ languageId: 'md', confidence: 0.01112559624016285 },
{ languageId: 'java', confidence: 0.009976979345083237 },
{ languageId: 'ps1', confidence: 0.009242385625839233 },
{ languageId: 'php', confidence: 0.008150739595293999 },
{ languageId: 'go', confidence: 0.0069260732270777225 },
{ languageId: 'tex', confidence: 0.006594990845769644 },
{ languageId: 'scala', confidence: 0.00619362760335207 },
{ languageId: 'py', confidence: 0.004240741487592459 },
{ languageId: 'r', confidence: 0.0033439004328101873 },
{ languageId: 'matlab', confidence: 0.0030552551615983248 },
{ languageId: 'css', confidence: 0.0026798006147146225 },
{ languageId: 'sh', confidence: 0.0023688252549618483 },
{ languageId: 'ipynb', confidence: 0.002114647999405861 },
{ languageId: 'bat', confidence: 0.0018151027616113424 },
{ languageId: 'hs', confidence: 0.001677449094131589 },
{ languageId: 'erl', confidence: 0.0014191442169249058 },
{ languageId: 'coffee', confidence: 0.000696933304425329 },
{ languageId: 'rb', confidence: 0.0006357143283821642 }
]
```
## Contributing

@@ -14,0 +86,0 @@

@@ -1,11 +0,1 @@

# TODO: The maintainer of this repo has not yet edited this file
**REPO OWNER**: Do you want Customer Service & Support (CSS) support for this product/project?
- **No CSS support:** Fill out this template with information about how to file issues and get help.
- **Yes CSS support:** Fill out an intake form at [aka.ms/spot](https://aka.ms/spot). CSS will work with/help you to determine next steps. More details also available at [aka.ms/onboardsupport](https://aka.ms/onboardsupport).
- **Not sure?** Fill out a SPOT intake as though the answer were "Yes". CSS will help you decide.
*Then remove this first heading from this SUPPORT.MD file before publishing your repo.*
# Support

@@ -19,5 +9,3 @@

For help and questions about using this project, please **REPO MAINTAINER: INSERT INSTRUCTIONS HERE
FOR HOW TO ENGAGE REPO OWNERS OR COMMUNITY FOR HELP. COULD BE A STACK OVERFLOW TAG OR OTHER
CHANNEL. WHERE WILL YOU HELP PEOPLE?**.
For help and questions about using this project, please also open issues.

@@ -24,0 +12,0 @@ ## Microsoft Support Policy

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc