{"id":16961984,"url":"https://github.com/wangdahoo/list-diff","last_synced_at":"2025-07-28T05:06:25.189Z","repository":{"id":36460547,"uuid":"223954029","full_name":"wangdahoo/list-diff","owner":"wangdahoo","description":null,"archived":false,"fork":false,"pushed_at":"2022-12-30T19:17:47.000Z","size":1114,"stargazers_count":3,"open_issues_count":13,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-25T18:11:42.312Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/wangdahoo.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-11-25T13:22:32.000Z","updated_at":"2020-07-27T08:44:00.000Z","dependencies_parsed_at":"2023-01-17T01:40:24.754Z","dependency_job_id":null,"html_url":"https://github.com/wangdahoo/list-diff","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/wangdahoo%2Flist-diff","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wangdahoo%2Flist-diff/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wangdahoo%2Flist-diff/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wangdahoo%2Flist-diff/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/wangdahoo","download_url":"https://codeload.github.com/wangdahoo/list-diff/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248173849,"owners_count":21059595,"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-10-13T23:04:51.919Z","updated_at":"2025-04-11T22:12:18.762Z","avatar_url":"https://github.com/wangdahoo.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# list-diff\n\n\u003e A List-Diff Algorithm. Useful in Dom Diff.\n\n## Installation\n\n```bash\nnpm i @wangdahoo/list-diff\n```\n\n## Usage\n\n```js\nconst { listDiff, applyPatches } = require('@wangdahoo/list-diff')\n\nconst a = ['1', '2', '3', '4', '5']\nconst b = ['a', 'b', '4', 'c', '2', 'd', 'e']\n\nlet patches = listDiff(a, b)\nconsole.log(patches)\n\n// output:\n// [ { type: 'DELETE', id: '1' },\n//   { type: 'DELETE', id: '3' },\n//   { type: 'DELETE', id: '5' },\n//   { type: 'REPOSITION', id: '4', after: '' },\n//   { type: 'REPOSITION', id: '2', after: '4' },\n//   { type: 'ADD', id: 'a', after: '' },\n//   { type: 'ADD', id: 'b', after: 'a' },\n//   { type: 'ADD', id: 'c', after: '4' },\n//   { type: 'ADD', id: 'd', after: '2' },\n//   { type: 'ADD', id: 'e', after: 'd' } ]\n\nconsole.log(applyPatches(a, patches))\n\n// output:\n// [ 'a', 'b', '4', 'c', '2', 'd', 'e' ]\n\npatches = listDiff(b, a)\nconsole.log(patches)\n\n// output:\n// [ { type: 'DELETE', id: 'a' },\n//   { type: 'DELETE', id: 'b' },\n//   { type: 'DELETE', id: 'c' },\n//   { type: 'DELETE', id: 'd' },\n//   { type: 'DELETE', id: 'e' },\n//   { type: 'REPOSITION', id: '2', after: '' },\n//   { type: 'REPOSITION', id: '4', after: '2' },\n//   { type: 'ADD', id: '1', after: '' },\n//   { type: 'ADD', id: '3', after: '2' },\n//   { type: 'ADD', id: '5', after: '4' } ]\n\nconsole.log(applyPatches(b, patches))\n\n// output:\n// ['1', '2', '3', '4', '5']\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwangdahoo%2Flist-diff","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwangdahoo%2Flist-diff","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwangdahoo%2Flist-diff/lists"}