{"id":24089478,"url":"https://github.com/abhisheksoni27/lexer.js","last_synced_at":"2026-05-18T03:35:52.060Z","repository":{"id":57290046,"uuid":"115695435","full_name":"abhisheksoni27/lexer.js","owner":"abhisheksoni27","description":"A lexer and longest common sequence finder (between JS source code files)","archived":false,"fork":false,"pushed_at":"2018-01-09T17:23:10.000Z","size":478,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2026-05-17T09:55:53.084Z","etag":null,"topics":["javascript","lexer","longest-common-substring","npm"],"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/abhisheksoni27.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":"2017-12-29T06:46:46.000Z","updated_at":"2019-03-31T15:54:16.000Z","dependencies_parsed_at":"2022-08-25T05:20:29.686Z","dependency_job_id":null,"html_url":"https://github.com/abhisheksoni27/lexer.js","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"purl":"pkg:github/abhisheksoni27/lexer.js","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/abhisheksoni27%2Flexer.js","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/abhisheksoni27%2Flexer.js/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/abhisheksoni27%2Flexer.js/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/abhisheksoni27%2Flexer.js/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/abhisheksoni27","download_url":"https://codeload.github.com/abhisheksoni27/lexer.js/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/abhisheksoni27%2Flexer.js/sbom","scorecard":{"id":160997,"data":{"date":"2025-08-11","repo":{"name":"github.com/abhisheksoni27/lexer.js","commit":"6cab18a46409c497eec235594322d7fb75d124e1"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":1.7,"checks":[{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"Code-Review","score":0,"reason":"Found 0/30 approved changesets -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Pinned-Dependencies","score":-1,"reason":"no dependencies found","details":null,"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"SAST","score":0,"reason":"no SAST tool detected","details":["Warn: no pull requests merged into dev branch"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}},{"name":"Dangerous-Workflow","score":-1,"reason":"no workflows found","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Token-Permissions","score":-1,"reason":"No tokens found","details":null,"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE:0","Info: FSF or OSI recognized license: MIT License: LICENSE:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'master'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"Vulnerabilities","score":0,"reason":"16 existing vulnerabilities detected","details":["Warn: Project is vulnerable to: GHSA-fwr7-v2mv-hh25","Warn: Project is vulnerable to: GHSA-v6h2-p8h4-qcjw","Warn: Project is vulnerable to: GHSA-h6ch-v84p-w6p9","Warn: Project is vulnerable to: GHSA-43f8-2h32-f4cj","Warn: Project is vulnerable to: GHSA-fvqr-27wr-82fm","Warn: Project is vulnerable to: GHSA-4xc9-xhrj-v574","Warn: Project is vulnerable to: GHSA-x5rq-j2xg-h7qm","Warn: Project is vulnerable to: GHSA-jf85-cpcp-j695","Warn: Project is vulnerable to: GHSA-p6mc-m468-83gw","Warn: Project is vulnerable to: GHSA-29mw-wpgm-hmr9","Warn: Project is vulnerable to: GHSA-35jh-r3h4-6jhm","Warn: Project is vulnerable to: GHSA-f8q6-p94x-37v3","Warn: Project is vulnerable to: GHSA-vh95-rmgr-6w4m","Warn: Project is vulnerable to: GHSA-xvch-5gv4-984h","Warn: Project is vulnerable to: GHSA-c2qf-rxjj-qqgw","Warn: Project is vulnerable to: GHSA-7p7h-4mm5-852v"],"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}}]},"last_synced_at":"2025-08-16T13:25:11.605Z","repository_id":57290046,"created_at":"2025-08-16T13:25:11.605Z","updated_at":"2025-08-16T13:25:11.605Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33163781,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-17T22:39:12.733Z","status":"online","status_checked_at":"2026-05-18T02:00:06.436Z","response_time":71,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["javascript","lexer","longest-common-substring","npm"],"created_at":"2025-01-10T04:39:13.887Z","updated_at":"2026-05-18T03:35:52.026Z","avatar_url":"https://github.com/abhisheksoni27.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# lexer.js\n\nA lexical analyzer and longest common shared sequence finder between a list of JS files.\n\n[![Build Status](https://travis-ci.org/abhisheksoni27/lexer.js.svg?branch=master)](https://travis-ci.org/abhisheksoni27/lexer.js)\n\n# Table of Contents\n\n* [What It Does](#what-it-does)\n* [Installation](#installation)\n* [Running lexer.js](#running-lexer.js)\n    - [JSON configruation](#json-configuration)\n    - [CSV configruation](#csv-configuration)\n* [Result](#result)\n* [Options](#options)\n* [Running Examples](#running-examples)\n    - [Test Github Project](#test-github-project)\n* [Tests](#tests)\n* [Known Issues](https://github.com/abhisheksoni27/lexer.js/wiki/Known-Issues)\n\n# What it does\n\nSuppose, you have two files with the same function but different function calls:\n\n**`test1.js`**\n\n\u003cimg alt=\"Test File 1\" align=\"right\" src =\"https://raw.githubusercontent.com/abhisheksoni27/lexer.js/master/src/assets/test1.png\"\u003e\n\n```js\nfunction add(a, b){\n    return a + b;\n}\n\nconst sum = add(11 + 11);\n```\n\n**`test2.js`**\n\n\u003cimg alt=\"Test File 2\" align=\"right\" src =\"https://raw.githubusercontent.com/abhisheksoni27/lexer.js/master/src/assets/test2.png\"\u003e\n\n```js\nfunction add(a, b){\n    return a + b;\n}\n\nlet sum = add(11 + 11);\n```\n\nThe longest common shared sequence between these two files is the *entire function definition.*\n\n**LCSS**\n\n\n```js\nfunction add(a, b){\n    return a + b;\n}\n```\n\n![Results](https://raw.githubusercontent.com/abhisheksoni27/lexer.js/master/src/assets/result.png)\n\n# Installation\n\n### CLI\nYou can download the module via ***npm***. (To install npm, which ships with node.js, you can download node from [nodejs.org](https://nodejs.org) for your OS.) `node.js \u003e 6.x`\n\n```bash\n$ npm install -g lexer.js\n```\n\nOr, if you prefer ***yarn***\n\n```bash\n$ yarn global add lexer.js\n```\n\nThat's it. 🎉\n\n### As module\n\nIn your application:\n\n```js\nconst lexerJS = require('lexer.js');\n\nconst result = lexerJS(files, options);\n```\n\n`files`: An array of files.\n\n`options`: See [options](#options) This parameter is *(ironically)* optional.\n\n# Running lexer.js\n\nTo run it on your own set of files, you can either provide the files in CSV/JSON, or as command line arguments like this:\n\n```bash\nlexer.js test1.js test2.js\n```\n\n### JSON configuration\nThe **JSON** must have a key named `files` and it's value should be an array of the *paths* of files you want to test on.\n\n```json\n{\n    \"files\": [\n        \"./example/test1.js\",\n        \"./example/test2.js\",\n    ]\n}\n```\n\n### CSV configuration\n\nThe **CSV** config file only has one header (or column) and is called `filename`. Each new line should contain the path of a source code file.\n\n```csv\nfilename,\n./example/test1.js,\n./example/test2.js\n```\n\n# Result\n\nThe result contains the **longest common `shared` sequence** found between the set of files. The default format is JSON, but can be configured. (See options below.)\n\nIt also asssigns a score to each subsequnce using the following formula:\n\n```js\nscore = log2(count) * log2(total)\n```\n\n**count**: Total number of occurences of the subsequence\n\n**total**: Total number of tokens in the subsequence\n\n## Options\n\n#### **`-o`** Output Mode `[default: \"json\"]`\n\nlexer.js supports **JSON** as well as **CSV** output. JSON is the defualt output format if you do not specify any during invocation.\n\n```bash\nlexer.js test.json -o csv\n```\n\u003e Output would now be a `CSV` file. To know what that file would contain, check out [result](#result).\n\n#### **`-s`** Save Tokens `[default: false]`\n\nThis is a boolean option, which when set, saves the tokens for each test file.\n\n```bash\nlexer.js test.json -s\n```\n\n\u003e It will generate a tokens folder, and save individual `tokens` for each file in that directory.\n\n#### **`-f`** Output File Name `[default: \"result\"]`\n\n```\nlexer.js test.json -f YayTheResultsYay\n```\n\n***Note:*** If you provide a file name with extension, such as `art.json`, then the output mode will be determined from the fileName and the output mode flag (if passed) will be overridden.\n\n# Running Examples\n\nThe [examples](https://) directory contains a minimal example set that you can run lexer.js on. To do so, clone the repo, fire a terminal, and run:\n\n```bash\nnpm install\n```\n\nThis will downdload the dependencies. Then, run:\n\n```bash\nlexer.js test.json\n```\n\nThis assumes that you already have lexer.js installed. If you don't, you can directly invoke the node script as follows:\n\n```bash\nnode index.js test.json\n```\n\nAs always, you must have `node` installed.\n\n## Test GitHub project\n\nThe repo also contains a script to test lexer.js on any GitHub project. The script does the following:\n\n1. Find all JS files in a project.\n2. Select a file which has more than **n** commits. n is configurable.\n3. Downloads the file at that point in time (when that commit was made).\n4. Generates a configuration file for lexer.js.\n5. Run lexer.js with that config file.\n\nTo run it, fire a terminal and run (assuming you are inside the project directory):\n\n```bash\nnode runGitHubExamples.js -t TOKEN --owner OWNERNAME --repo REPONAME -n 20\n```\n\n**`OWNERNAME`**: Owner of the repo `[default: prettier]`\n\n**`REPONAME`**: Name of the repo `[default: prettier]`\n\n**`n`**: Minimum commits the selected file must have `[default: 10]`\n\n**`t`**: GitHub OAuth token `[Mandatory]`\n\nThe results are saved in `result.json`. The command line [options](#options) for **lexer.js** can also be passed.\n\nThe GitHub OAuth token is a required argument. To generate a Personal Access Token for testing, you can generate one here: [GitHub - Personal Access Token](https://github.com/settings/tokens)\n\n# Tests\n\nTo run tests, clone the repo (That green button above the repo contents) and run the following command:\n\n```bash\nnpm install \u0026\u0026 npm run test\n```\n\nThis will first download the dependencies, and then run the tests (using `mocha`) and output the result.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fabhisheksoni27%2Flexer.js","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fabhisheksoni27%2Flexer.js","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fabhisheksoni27%2Flexer.js/lists"}