{"id":25219765,"url":"https://github.com/zhanba/codiff","last_synced_at":"2026-02-16T19:07:29.246Z","repository":{"id":276067281,"uuid":"925580590","full_name":"zhanba/codiff","owner":"zhanba","description":"diff algorithms in vscode","archived":false,"fork":false,"pushed_at":"2025-02-06T04:20:29.000Z","size":219,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-06T05:26:00.883Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://zhanba.github.io/codiff/","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/zhanba.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2025-02-01T07:52:14.000Z","updated_at":"2025-02-06T04:22:04.000Z","dependencies_parsed_at":"2025-02-06T05:27:01.030Z","dependency_job_id":"a87cc733-fa91-4253-8fb2-e8c573213f62","html_url":"https://github.com/zhanba/codiff","commit_stats":null,"previous_names":["zhanba/codiff"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zhanba%2Fcodiff","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zhanba%2Fcodiff/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zhanba%2Fcodiff/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zhanba%2Fcodiff/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/zhanba","download_url":"https://codeload.github.com/zhanba/codiff/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":238189321,"owners_count":19431039,"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":"2025-02-10T21:23:03.026Z","updated_at":"2025-10-25T17:31:32.883Z","avatar_url":"https://github.com/zhanba.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Codiff\n\nCodiff is a library for computing line by line diff using the same diff algorithms in VSCode.\n\n## Install\n\n```sh\nnpm install codiff\n```\n\n# Usage\n\n```typescript\nimport { linesDiffComputers } from \"codiff\";\n\nconst doc = `one\ntwo\nthree\nfour\nfive`;\n\nconst docModified = doc.replace(/t/g, \"T\") + \"\\nSix\";\n\nconst codiff = new Codiff();\nconst result = codiff.computeDiff(doc, docmodified);\n```\n\ndiff result:\n\n```json\n{\n  \"changes\": [\n    {\n      \"original\": {\n        \"startLineNumber\": 2,\n        \"endLineNumberExclusive\": 4\n      },\n      \"modified\": {\n        \"startLineNumber\": 2,\n        \"endLineNumberExclusive\": 4\n      },\n      \"innerChanges\": [\n        {\n          \"originalRange\": {\n            \"startLineNumber\": 2,\n            \"startColumn\": 1,\n            \"endLineNumber\": 2,\n            \"endColumn\": 2\n          },\n          \"modifiedRange\": {\n            \"startLineNumber\": 2,\n            \"startColumn\": 1,\n            \"endLineNumber\": 2,\n            \"endColumn\": 2\n          }\n        },\n        {\n          \"originalRange\": {\n            \"startLineNumber\": 3,\n            \"startColumn\": 1,\n            \"endLineNumber\": 3,\n            \"endColumn\": 2\n          },\n          \"modifiedRange\": {\n            \"startLineNumber\": 3,\n            \"startColumn\": 1,\n            \"endLineNumber\": 3,\n            \"endColumn\": 2\n          }\n        }\n      ]\n    },\n    {\n      \"original\": {\n        \"startLineNumber\": 6,\n        \"endLineNumberExclusive\": 6\n      },\n      \"modified\": {\n        \"startLineNumber\": 6,\n        \"endLineNumberExclusive\": 7\n      },\n      \"innerChanges\": [\n        {\n          \"originalRange\": {\n            \"startLineNumber\": 5,\n            \"startColumn\": 5,\n            \"endLineNumber\": 5,\n            \"endColumn\": 5\n          },\n          \"modifiedRange\": {\n            \"startLineNumber\": 5,\n            \"startColumn\": 5,\n            \"endLineNumber\": 6,\n            \"endColumn\": 4\n          }\n        }\n      ]\n    }\n  ],\n  \"quitEarly\": false,\n  \"identical\": false,\n  \"moves\": []\n}\n```\n\n## Playground\n\nCodiff provide a [playground](https://zhanba.github.io/codiff/) to test the diff algorithm and preview the diff result in code diff editor and JSON editor.\n\n## Performance\n\n- Diff performance is related to the number of lines of code and the number of changes.\n- Suggestion:\n  - Cache the diff result for same content.\n  - Use wroker to do the diff in the background.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzhanba%2Fcodiff","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzhanba%2Fcodiff","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzhanba%2Fcodiff/lists"}