{"id":22747126,"url":"https://github.com/micnil/vscode-diff","last_synced_at":"2025-10-06T04:54:51.048Z","repository":{"id":57394065,"uuid":"152972009","full_name":"micnil/vscode-diff","owner":"micnil","description":"A small, zero-dependency text differencing library extracted from the open source VS Code","archived":false,"fork":false,"pushed_at":"2024-06-16T21:39:09.000Z","size":370,"stargazers_count":56,"open_issues_count":3,"forks_count":3,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-09-20T15:15:15.530Z","etag":null,"topics":["diff","difference-algorithm","npm-package"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/vscode-diff","language":"TypeScript","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/micnil.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-10-14T12:35:13.000Z","updated_at":"2025-08-29T08:44:55.000Z","dependencies_parsed_at":"2024-06-21T16:24:48.668Z","dependency_job_id":"4ec645f0-4b45-410a-ba5c-bb492b1b5558","html_url":"https://github.com/micnil/vscode-diff","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/micnil/vscode-diff","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/micnil%2Fvscode-diff","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/micnil%2Fvscode-diff/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/micnil%2Fvscode-diff/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/micnil%2Fvscode-diff/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/micnil","download_url":"https://codeload.github.com/micnil/vscode-diff/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/micnil%2Fvscode-diff/sbom","scorecard":{"id":642472,"data":{"date":"2025-08-11","repo":{"name":"github.com/micnil/vscode-diff","commit":"7fed75c82d574a64e3c4146e308a0284dcc22019"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":2.1,"checks":[{"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":"Code-Review","score":0,"reason":"Found 1/26 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":"Maintained","score":0,"reason":"0 commit(s) and 1 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":"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":"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":"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":"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":"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.txt:0","Info: FSF or OSI recognized license: MIT License: LICENSE.txt: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":"SAST","score":0,"reason":"SAST tool is not run on all commits -- score normalized to 0","details":["Warn: 0 commits out of 5 are checked with a SAST tool"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}},{"name":"Vulnerabilities","score":3,"reason":"7 existing vulnerabilities detected","details":["Warn: Project is vulnerable to: GHSA-v6h2-p8h4-qcjw","Warn: Project is vulnerable to: GHSA-grv7-fg5c-xmjg","Warn: Project is vulnerable to: GHSA-3xgq-45jj-v275","Warn: Project is vulnerable to: GHSA-952p-6rrq-rcjv","Warn: Project is vulnerable to: GHSA-mwcw-c2x4-8c55","Warn: Project is vulnerable to: GHSA-76p7-773f-r4q5","Warn: Project is vulnerable to: GHSA-m95q-7qp3-xv42"],"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-21T11:12:27.977Z","repository_id":57394065,"created_at":"2025-08-21T11:12:27.977Z","updated_at":"2025-08-21T11:12:27.977Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":278561275,"owners_count":26006954,"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","status":"online","status_checked_at":"2025-10-06T02:00:05.630Z","response_time":65,"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":["diff","difference-algorithm","npm-package"],"created_at":"2024-12-11T03:13:07.907Z","updated_at":"2025-10-06T04:54:50.996Z","avatar_url":"https://github.com/micnil.png","language":"TypeScript","readme":"# vscode-diff\nA small, zero-dependency text differencing library extracted from the open source [VS Code](https://github.com/Microsoft/vscode) editor.\nThe implementation is based on the difference algorithm described in \"An O(ND) Difference Algorithm and its variations\" by Eugene W. Myers.\n\nThe package includes typescript definitions.\n\n![npm](https://img.shields.io/npm/v/vscode-diff?style=plastic)\n![GitHub](https://img.shields.io/github/license/micnil/vscode-diff)\n## Installation\n```bash\nnpm install vscode-diff --save\n```\n## Usage\n\nStarting from version 1.71.0 VS Code introduced new diffing algorithm that can also detect code moves. It is currently used by default in VS Code and can be accessed in this library as `AdvancedLinesDiffComputer`.\nThe legacy algorithm can be accessed as `DiffComputer`.\n\n### Example of legacy algorithm usage:\n\n```typescript\nimport { DiffComputer, IDiffComputerOpts, ILineChange } from 'vscode-diff';\n\nlet originalLines: string[] = [\"hello\", \"original\", \"world\"];\nlet modifiedLines: string[] = [\"hello\", \"modified\", \"world\", \"foobar\"];\nlet options: IDiffComputerOpts = {\n  shouldPostProcessCharChanges: true,\n  shouldIgnoreTrimWhitespace: true,\n  shouldMakePrettyDiff: true,\n  shouldComputeCharChanges: true,\n  maxComputationTime: 0 // time in milliseconds, 0 =\u003e no computation limit.\n}\nlet diffComputer = new DiffComputer(originalLines, modifiedLines, options);\nlet lineChanges: ILineChange[] = diffComputer.computeDiff().changes;\n\nconsole.log(JSON.stringify(lineChanges, null, 2));\n```\nOutput:\n```json\n[\n  {\n    \"originalStartLineNumber\": 2,\n    \"originalEndLineNumber\": 2,\n    \"modifiedStartLineNumber\": 2,\n    \"modifiedEndLineNumber\": 2,\n    \"charChanges\": [\n      {\n        \"originalStartLineNumber\": 2,\n        \"originalStartColumn\": 1,\n        \"originalEndLineNumber\": 2,\n        \"originalEndColumn\": 9,\n        \"modifiedStartLineNumber\": 2,\n        \"modifiedStartColumn\": 1,\n        \"modifiedEndLineNumber\": 2,\n        \"modifiedEndColumn\": 9\n      }\n    ]\n  },\n  {\n    \"originalStartLineNumber\": 3,\n    \"originalEndLineNumber\": 0,\n    \"modifiedStartLineNumber\": 4,\n    \"modifiedEndLineNumber\": 4\n  }\n]\n```\nEach element in the produced `lineChanges` array corresponds to a change from the original lines to the modified lines.\n\nThe column and row indices are 1-based. If a 0 index is present, it means that a row has been added/removed, eg:\n```json\n{\n  \"originalStartLineNumber\": 3,\n  \"originalEndLineNumber\": 0,\n  \"modifiedStartLineNumber\": 4,\n  \"modifiedEndLineNumber\": 4\n}\n```\nmeans that the 4th line in the modified text was added after line 3 in the original text.\n\nThe opposite:\n```json\n{\n  \"originalStartLineNumber\": 4,\n  \"originalEndLineNumber\": 4,\n  \"modifiedStartLineNumber\": 3,\n  \"modifiedEndLineNumber\": 0\n}\n```\nmeans that the 4th line in the original text was removed from after line 3 in the modified text.\n\n### Example of new algorithm usage:\n```typescript\nlet advOptions: ILinesDiffComputerOptions = {\n    ignoreTrimWhitespace: true,\n    computeMoves: true,\n    maxComputationTimeMs: 0\n}\nlet advDiffComputer = new AdvancedLinesDiffComputer()\nlet advLineChanges = advDiffComputer.computeDiff(originalLines, modifiedLines, advOptions).changes;\n\nconsole.log(JSON.stringify(advLineChanges, null, 2));\n```\n\nOutput:\n```json\n[\n  {\n    \"originalRange\": {\n      \"startLineNumber\": 2,\n      \"endLineNumberExclusive\": 3\n    },\n    \"modifiedRange\": {\n      \"startLineNumber\": 2,\n      \"endLineNumberExclusive\": 3\n    },\n    \"innerChanges\": [\n      {\n        \"originalRange\": {\n          \"startLineNumber\": 2,\n          \"startColumn\": 1,\n          \"endLineNumber\": 2,\n          \"endColumn\": 9\n        },\n        \"modifiedRange\": {\n          \"startLineNumber\": 2,\n          \"startColumn\": 1,\n          \"endLineNumber\": 2,\n          \"endColumn\": 9\n        }\n      }\n    ]\n  },\n  {\n    \"originalRange\": {\n      \"startLineNumber\": 4,\n      \"endLineNumberExclusive\": 4\n    },\n    \"modifiedRange\": {\n      \"startLineNumber\": 4,\n      \"endLineNumberExclusive\": 5\n    },\n    \"innerChanges\": [\n      {\n        \"originalRange\": {\n          \"startLineNumber\": 3,\n          \"startColumn\": 6,\n          \"endLineNumber\": 3,\n          \"endColumn\": 6\n        },\n        \"modifiedRange\": {\n          \"startLineNumber\": 3,\n          \"startColumn\": 6,\n          \"endLineNumber\": 4,\n          \"endColumn\": 7\n        }\n      }\n    ]\n  }\n]\n```\n\nThe format of the result mapping is similar to that returned by `DiffComputer` but beware that then ending line number in line range is exclusive, e.g.\n```json\n\"originalRange\": {\n  \"startLineNumber\": 2,\n  \"endLineNumberExclusive\": 3\n}\n```\n\nas opposed to\n```json\n\"originalStartLineNumber\": 2,\n\"originalEndLineNumber\": 2,\n```\n\n\n## Changelog\n\n### 2.1.1\n* Fix build errors in 2.1.0 [#3](https://github.com/micnil/vscode-diff/issues/3)\n\n### 2.1.0\n* Update to VS Code 1.82.1 that introduces new diffing algorithm `AdvancedLinesDiffComputer`.\n\n### 2.0.2\n* Fix issue [121436](https://github.com/microsoft/vscode/issues/121436)\n\n### 2.0.1\n* Fix missing typescript types\n* Fix issue [119051](https://github.com/microsoft/vscode/issues/119051)\n\n### 2.0.0\n * New DiffComputer option: maxComputationTime. Specify maximum time that the diff computer should run. Specify 0 for no limit. For character changes (`charChanges`) there is a new hard coded maximum limit of 5 seconds.\n * New return type from diffComputer:\n ```\n interface IDiffComputerResult {\n\tquitEarly: boolean;\n\tchanges: ILineChange[];\n}\n ```\n\n### 1.0.0\nInitial release\n\n## Contribute\nSince we do not want this package to differ from the original implementation in VS Code, no changes that differs from the [source repository](https://github.com/Microsoft/vscode) will be merged. Any changes that only affect this npm package (like changes to this README) are welcome via pull requests.\n\nSteps for updating diff algorithm:\n* Copy all necessary files from VS Code repo.\n* Verify with `npm run build` that all code is self-contained.\n* Verify with `npm run knip` that there are no unused files or exports.\n* Run `npm test` to run all the tests.\n* Update [example/example.ts] on any API changes.\n* Run `npm run example` and update this README with example usage code and output.\n* Include VS Code version and commit hash in commit message.\n\nAny help documenting the diff API is very welcome.\n\n## Attribution\nThe source code of this package is directly extracted from the open source software VS Code, Copyright (c) Microsoft Corporation.\nThe VS Code source files is licensed under the MIT license. See src/LICENSE.txt for additional details.\n\nOnly minor modifications have been made to the source files:\n* Removed code unused by the diff implementation.\n* Updated import paths to reflect their new location.\n* Added comment in each source file with a commit hash from their last modification.\n\nI am in no way affiliated to Microsoft or the VS Code team.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmicnil%2Fvscode-diff","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmicnil%2Fvscode-diff","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmicnil%2Fvscode-diff/lists"}