{"id":20499397,"url":"https://github.com/ts95/lang-detector","last_synced_at":"2025-04-13T18:51:37.285Z","repository":{"id":29527541,"uuid":"33066130","full_name":"ts95/lang-detector","owner":"ts95","description":"A library for detecting the programming language of a code snippet.","archived":false,"fork":false,"pushed_at":"2022-12-13T20:06:06.000Z","size":3088,"stargazers_count":52,"open_issues_count":3,"forks_count":12,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-12T03:38:18.870Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ts95.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-03-29T08:24:30.000Z","updated_at":"2025-02-13T20:11:21.000Z","dependencies_parsed_at":"2023-01-14T15:07:38.787Z","dependency_job_id":null,"html_url":"https://github.com/ts95/lang-detector","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ts95%2Flang-detector","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ts95%2Flang-detector/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ts95%2Flang-detector/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ts95%2Flang-detector/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ts95","download_url":"https://codeload.github.com/ts95/lang-detector/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248765983,"owners_count":21158296,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-15T18:17:16.936Z","updated_at":"2025-04-13T18:51:37.253Z","avatar_url":"https://github.com/ts95.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"lang-detector  [![Build Status](https://travis-ci.org/hosein2398/lang-detector.svg?branch=master)](https://travis-ci.org/hosein2398/lang-detector) [![npm downloads](https://img.shields.io/npm/v/lang-detector.svg)](https://www.npmjs.com/package/lang-detector) [![Software License](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE)\n=====\n\n![lang-detector](https://raw.githubusercontent.com/hosein2398/File-Container/master/Lang-detector/Lang-detector.png)\n\nA fast and small library for detecting the programming language of a code snippet. \nCan be used for strings of code spanning multiple thousand lines.\n\nThis library should only be used if you don't have anything else to go by to determine the language of the code, like a file extension.\n## Demo \n[Here](https://hosein2398.github.io/lang-detect/) you can see demo of this project.\n\n## Detectable languages\n* JavaScript\n* C\n* C++\n* Python\n* Java\n* HTML\n* CSS\n* Ruby\n* Go\n* PHP\n\n## Install\n```Shell\nnpm install lang-detector --save\n```\n\n## Usage\n```JavaScript\n/**\n * function detectLang(snippet, options) { ... }\n *\n * @snippet {String} The code snippet.\n * @options {Object} (Optional) {\n *   heuristic: {Boolean} Enable heuristic optimisation for better performance. `true` by default.\n *   statistics: {Boolean} Return statistics. `false` by default.\n * }\n * @return {String} (Name of the detected language) or {Object} (Statistics).\n */\nvar detectLang = require('lang-detector');\n\ndetectLang('List\u003cString\u003e things = new ArrayList\u003c\u003e();')\n    // =\u003e    'Java'\ndetectLang('console.log(\"Hello world\");')\n    // =\u003e    'JavaScript'\ndetectLang('Hello world.', { statistics: true })\n    /* =\u003e   {\n                \"detected\": \"Unknown\",\n                \"statistics\": {\n                    \"JavaScript\": 0,\n                    \"C\": 0,\n                    \"C++\": 0,\n                    \"Python\": 0,\n                     ...\n                    \"Unknown\": 1\n                }\n            } \n     */\n```\n\n## Unit tests\nRun `npm test` in the root of the directory to run the tests.\n\n## License\n\u003ca href=\"https://tldrlegal.com/license/mit-license\" target=\"_blank\"\u003eMIT\u003c/a\u003e © \u003ca href=\"https://github.com/ts95/\" target=\"_blank\"\u003eToni Sučić\u003c/a\u003e","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fts95%2Flang-detector","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fts95%2Flang-detector","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fts95%2Flang-detector/lists"}