{"_id":"@codingame/vscode-languagedetection","_rev":"3-727a94b955d3b731b4a82426285b457f","name":"@codingame/vscode-languagedetection","dist-tags":{"latest":"1.0.23"},"versions":{"1.0.22":{"name":"@codingame/vscode-languagedetection","version":"1.0.22","author":{"name":"Tyler Leonhardt"},"license":"MIT","_id":"@codingame/vscode-languagedetection@1.0.22","maintainers":[{"name":"codingame_team","email":"developers@codingame.com"},{"name":"nantoniazzi","email":"nicolas@codingame.com"},{"name":"samuel.olivier","email":"samuel@coderpad.io"},{"name":"maximecg","email":"maxime@codingame.com"},{"name":"beli4l","email":"vetter.valentin@gmail.com"},{"name":"nonofr","email":"loic@codingame.com"}],"homepage":"https://github.com/microsoft/vscode-languagedetection#readme","bugs":{"url":"https://github.com/microsoft/vscode-languagedetection/issues"},"bin":{"vscode-languagedetection":"cli/index.js"},"dist":{"shasum":"0df4fe9d3bc894aed2414f309255a4a86409c39e","tarball":"https://registry.npmjs.org/@codingame/vscode-languagedetection/-/vscode-languagedetection-1.0.22.tgz","fileCount":17,"integrity":"sha512-b1tbcc/80zGF6m1mHNQO413tebqfJe8HRbT5k74Ly+uv9/hibfZdZgc3lKS3Xjbl5RfiwTZ1zqiZSejEFpvFcA==","signatures":[{"sig":"MEUCIQDIK5Z905eAMdSB5+GXXWQntvVsVKT5UjjghIlY6klPPgIgQEem1+CES96jl55BbqsiWLziFZ0j+xm2qf999jUTlaQ=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":5459541},"main":"dist/lib/index.js","types":"dist/lib/index.node.d.ts","module":"dist/lib/index.esm.js","browser":"dist/lib/index.web.js","gitHead":"f2af67a53d4eb800ac3ddd05482023ba3966309c","scripts":{"test":"mocha --recursive dist/test/**/*.test.js","clean":"rimraf dist","watch":"npm run clean && rollup --config rollup.config.ts --configPlugin 'typescript={tsconfig: `tsconfig.rollup.json`}' --watch","compile":"npm run clean && NODE_ENV=production rollup --config rollup.config.ts --configPlugin 'typescript={tsconfig: `tsconfig.rollup.json`}'","prepack":"npm run compile","pretest":"npm run clean && tsc --build ./test","prepublishOnly":"npm test && npm run compile"},"_npmUser":{"name":"nonofr","email":"loic@codingame.com"},"repository":{"url":"git+https://github.com/microsoft/vscode-languagedetection.git","type":"git"},"_npmVersion":"10.3.0","description":"An npm package that uses guesslang's ML model to detect source code languages","directories":{},"_nodeVersion":"18.19.0","_hasShrinkwrap":false,"devDependencies":{"chai":"^4.3.4","mocha":"^10.2.0","rimraf":"^3.0.2","rollup":"^4.5.1","esbuild":"^0.12.15","typescript":"^5.2.2","@types/chai":"^4.3.10","@types/node":"^16.3.1","npm-run-all":"^4.1.5","@types/mocha":"^10.0.4","@rollup/plugin-json":"^6.0.1","@rollup/plugin-terser":"^0.4.4","@tensorflow/tfjs-core":"^3.21.0","@rollup/plugin-commonjs":"^25.0.7","@rollup/plugin-typescript":"^11.1.5","@tensorflow/tfjs-converter":"^3.21.0","@rollup/plugin-node-resolve":"^15.2.3","@tensorflow/tfjs-backend-cpu":"^3.21.0"},"_npmOperationalInternal":{"tmp":"tmp/vscode-languagedetection_1.0.22_1713197743889_0.08618105769081397","host":"s3://npm-registry-packages"}},"1.0.23":{"name":"@codingame/vscode-languagedetection","version":"1.0.23","author":{"name":"Tyler Leonhardt"},"license":"MIT","_id":"@codingame/vscode-languagedetection@1.0.23","maintainers":[{"name":"codingame_team","email":"developers@codingame.com"},{"name":"nantoniazzi","email":"nicolas@codingame.com"},{"name":"samuel.olivier","email":"samuel@coderpad.io"},{"name":"maximecg","email":"maxime@codingame.com"},{"name":"beli4l","email":"vetter.valentin@gmail.com"},{"name":"nonofr","email":"loic@codingame.com"}],"homepage":"https://github.com/microsoft/vscode-languagedetection#readme","bugs":{"url":"https://github.com/microsoft/vscode-languagedetection/issues"},"bin":{"vscode-languagedetection":"cli/index.js"},"dist":{"shasum":"1919a6e931e5f939e387f4e90faf5ff7552f3775","tarball":"https://registry.npmjs.org/@codingame/vscode-languagedetection/-/vscode-languagedetection-1.0.23.tgz","fileCount":17,"integrity":"sha512-PqMisj1WEb1d9YtFapOjDQYACq8HD3f5/d+tFfZltsqAomGvoQxl7LBtftPUDT4zpvxls0IsJHiWrR/wvwyuzg==","signatures":[{"sig":"MEUCIQDbTEC7hSjay5Ttdm1zfCGjbOOAiyz0CSlEZ3AnHJa5bwIgXF4sj7kO4Ep4l5dK9fXjIa9sYZqirxWPYh2FiCyDhNQ=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":5459378},"main":"dist/lib/index.js","types":"dist/lib/index.node.d.ts","module":"dist/lib/index.esm.js","browser":"dist/lib/index.web.js","gitHead":"7b3c7bb1dd31a8629e718f8c347409dc37ca4ce3","scripts":{"test":"mocha --recursive dist/test/**/*.test.js","clean":"rimraf dist","watch":"npm run clean && rollup --config rollup.config.ts --configPlugin 'typescript={tsconfig: `tsconfig.rollup.json`}' --watch","compile":"npm run clean && NODE_ENV=production rollup --config rollup.config.ts --configPlugin 'typescript={tsconfig: `tsconfig.rollup.json`}'","prepack":"npm run compile","pretest":"npm run clean && tsc --build ./test","prepublishOnly":"npm test && npm run compile"},"_npmUser":{"name":"nonofr","email":"loic@codingame.com"},"repository":{"url":"git+https://github.com/microsoft/vscode-languagedetection.git","type":"git"},"_npmVersion":"10.3.0","description":"An npm package that uses guesslang's ML model to detect source code languages","directories":{},"_nodeVersion":"18.19.0","_hasShrinkwrap":false,"devDependencies":{"chai":"^4.3.4","mocha":"^10.2.0","rimraf":"^3.0.2","rollup":"^4.5.1","esbuild":"^0.12.15","typescript":"^5.2.2","@types/chai":"^4.3.10","@types/node":"^16.3.1","npm-run-all":"^4.1.5","@types/mocha":"^10.0.4","@rollup/plugin-json":"^6.0.1","@rollup/plugin-terser":"^0.4.4","@tensorflow/tfjs-core":"^3.21.0","@rollup/plugin-replace":"^5.0.5","@rollup/plugin-commonjs":"^25.0.7","@rollup/plugin-typescript":"^11.1.5","@tensorflow/tfjs-converter":"^3.21.0","@rollup/plugin-node-resolve":"^15.2.3","@tensorflow/tfjs-backend-cpu":"^3.21.0"},"_npmOperationalInternal":{"tmp":"tmp/vscode-languagedetection_1.0.23_1713200292639_0.40180208437660814","host":"s3://npm-registry-packages"}}},"time":{"created":"2024-04-15T16:15:43.626Z","modified":"2025-07-15T14:03:57.099Z","1.0.22":"2024-04-15T16:15:44.106Z","1.0.23":"2024-04-15T16:58:12.938Z"},"bugs":{"url":"https://github.com/microsoft/vscode-languagedetection/issues"},"author":{"name":"Tyler Leonhardt"},"license":"MIT","homepage":"https://github.com/microsoft/vscode-languagedetection#readme","repository":{"url":"git+https://github.com/microsoft/vscode-languagedetection.git","type":"git"},"description":"An npm package that uses guesslang's ML model to detect source code languages","maintainers":[{"email":"loic@codingame.com","name":"nonofr"},{"email":"samuel@coderpad.io","name":"samuel.olivier"},{"email":"nicolas@codingame.com","name":"nantoniazzi"},{"email":"maxime@codingame.com","name":"maximecg"},{"email":"developers@codingame.com","name":"codingame_team"}],"readme":"# vscode-languagedetection\n\nAn 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!\n\n## Usage\n\nFirst install it in your project:\n\n```sh\nnpm install --save @vscode/vscode-languagedetection\n# or using yarn\nyarn add @vscode/vscode-languagedetection\n```\n\nThen instantiate a ModuleOperations and run the run the model on a string of code:\n\n```ts\nimport { ModelOperations } from \"@vscode/vscode-languagedetection\";\n\nconst modulOperations = new ModelOperations();\n\nconst result = await modulOperations.runModel(`\nfunction makeThing(): Thing {\n    let size = 0;\n    return {\n        get size(): number {\n        return size;\n        },\n        set size(value: string | number | boolean) {\n        let num = Number(value);\n        // Don't allow NaN and stuff.\n        if (!Number.isFinite(num)) {\n            size = 0;\n            return;\n        }\n        size = num;\n        },\n    };\n}\n`);\n```\n\nwhich will give you the following in order of confidence:\n```ts\n[\n  { languageId: 'ts', confidence: 0.48307517170906067 },\n  { languageId: 'rs', confidence: 0.10045434534549713 },\n  { languageId: 'js', confidence: 0.07833506911993027 },\n  { languageId: 'c', confidence: 0.045049071311950684 },\n  { languageId: 'lua', confidence: 0.044198162853717804 },\n  { languageId: 'cpp', confidence: 0.03847603127360344 },\n  { languageId: 'cs', confidence: 0.03298814222216606 },\n  { languageId: 'mm', confidence: 0.02999635599553585 },\n  { languageId: 'html', confidence: 0.01874217577278614 },\n  { languageId: 'sql', confidence: 0.01811739057302475 },\n  { languageId: 'swift', confidence: 0.01418407540768385 },\n  { languageId: 'pl', confidence: 0.014126052148640156 },\n  { languageId: 'md', confidence: 0.01112559624016285 },\n  { languageId: 'java', confidence: 0.009976979345083237 },\n  { languageId: 'ps1', confidence: 0.009242385625839233 },\n  { languageId: 'php', confidence: 0.008150739595293999 },\n  { languageId: 'go', confidence: 0.0069260732270777225 },\n  { languageId: 'tex', confidence: 0.006594990845769644 },\n  { languageId: 'scala', confidence: 0.00619362760335207 },\n  { languageId: 'py', confidence: 0.004240741487592459 },\n  { languageId: 'r', confidence: 0.0033439004328101873 },\n  { languageId: 'matlab', confidence: 0.0030552551615983248 },\n  { languageId: 'css', confidence: 0.0026798006147146225 },\n  { languageId: 'sh', confidence: 0.0023688252549618483 },\n  { languageId: 'ipynb', confidence: 0.002114647999405861 },\n  { languageId: 'bat', confidence: 0.0018151027616113424 },\n  { languageId: 'hs', confidence: 0.001677449094131589 },\n  { languageId: 'erl', confidence: 0.0014191442169249058 },\n  { languageId: 'coffee', confidence: 0.000696933304425329 },\n  { languageId: 'rb', confidence: 0.0006357143283821642 }\n]\n```\n\n### Advanced options\n\nBy default, this library will work in Node.js. It uses the `fs` and `path` modules provided by Node.js to read in the `model.json` file and the weights file, `group1-shard1of1.bin`, that are contained in this repo.\n\nYou can overwrite that behavior using the first two optional parameters of `ModelOperations`:\n\n```ts\nmodelJSONFunc?: () => Promise<any> // This must return a JSON.parse() object\nweightsFunc?: () => Promise<ArrayBuffer>\n```\n\nThese allow you to overwrite the model loading behavior of this package if you happen to be in a non-traditional environment. For an example of this, check out how [VS Code is doing it](https://github.com/microsoft/vscode/blob/3a1cf8e51e3797a2d9ccb12d207378de364596c4/src/vs/workbench/services/languageDetection/browser/languageDetectionService.ts#L60-L80).\n\nThe third parameter is the options bag that has:\n\n* `minContentSize?: number` - The minimum number of characters in a file to be considered for language detection. Defaults to `20`.\n* `maxContentSize?: number` - The maximum number of characters *that will be used* in a file to be considered for language detection. Defaults to `100000`.\n\n## Local development\n\nTo build from source, follow these steps:\n\n1. Clone the repository\n2. Run `npm install`\n3. Run `npm run watch`\n\nTo run the tests, simply run `npm test`.\n\nTo build a production package:\n\n1. Run `npm run build`\n2. Run `npm pack`\n\nTo publish this package, run `npm publish`.\n\n## Contributing\n\nThis project welcomes contributions and suggestions.  Most contributions require you to agree to a\nContributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us\nthe rights to use your contribution. For details, visit https://cla.opensource.microsoft.com.\n\nWhen you submit a pull request, a CLA bot will automatically determine whether you need to provide\na CLA and decorate the PR appropriately (e.g., status check, comment). Simply follow the instructions\nprovided by the bot. You will only need to do this once across all repos using our CLA.\n\nThis project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/).\nFor more information see the [Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) or\ncontact [opencode@microsoft.com](mailto:opencode@microsoft.com) with any additional questions or comments.\n\n## Trademarks\n\nThis project may contain trademarks or logos for projects, products, or services. Authorized use of Microsoft \ntrademarks or logos is subject to and must follow \n[Microsoft's Trademark & Brand Guidelines](https://www.microsoft.com/en-us/legal/intellectualproperty/trademarks/usage/general).\nUse of Microsoft trademarks or logos in modified versions of this project must not cause confusion or imply Microsoft sponsorship.\nAny use of third-party trademarks or logos are subject to those third-party's policies.\n","readmeFilename":"README.md"}