{"id":16125739,"url":"https://github.com/dy/swapdom","last_synced_at":"2025-09-12T21:33:09.872Z","repository":{"id":65509003,"uuid":"448095623","full_name":"dy/swapdom","owner":"dy","description":"Fast \u0026 tiny DOM differ","archived":false,"fork":false,"pushed_at":"2024-03-14T22:57:19.000Z","size":91,"stargazers_count":16,"open_issues_count":1,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2024-12-29T00:12:21.445Z","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":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/dy.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-01-14T20:14:39.000Z","updated_at":"2024-04-02T07:24:54.000Z","dependencies_parsed_at":"2024-03-14T23:41:48.993Z","dependency_job_id":"259bf338-ee04-412f-bc5e-8138255f1fa0","html_url":"https://github.com/dy/swapdom","commit_stats":null,"previous_names":["spectjs/swapdom"],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dy%2Fswapdom","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dy%2Fswapdom/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dy%2Fswapdom/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dy%2Fswapdom/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dy","download_url":"https://codeload.github.com/dy/swapdom/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":232792146,"owners_count":18577261,"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-09T21:31:22.551Z","updated_at":"2025-01-06T21:53:43.853Z","avatar_url":"https://github.com/dy.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# swapdom [![test](https://github.com/spectjs/swapdom/actions/workflows/test.yml/badge.svg)](https://github.com/spectjs/swapdom/actions/workflows/test.yml) [![npm version](https://img.shields.io/npm/v/swapdom)](http://npmjs.org/swapdom)\n\n\u003e Fast \u0026 tiny DOM swapper.\n\n```js\nimport swap from 'swapdom'\n\nswap(parentNode, oldNodes, newNodes, endNode)\n```\n\n`deflate.js` strategy is smaller (248b), but a bit slower on some cases and doesn't support live collections.\u003cbr/\u003e\n`inflate.js` strategy is bigger (318b), but faster and supports live collections.\n\nProvide custom mutators as:\n```js\nswap.same = (a,b) =\u003e a?.isSameNode(b)\nswap.replace = (a,b, parent) =\u003e a.replaceWith(b)\nswap.insert = (a,b, parent) =\u003e a ? a.before(b) : parent.append(b)\nswap.remove = (a, parent) =\u003e a.remove()\n```\n\nSee [benchmark](https://github.com/luwes/js-diff-benchmark) (it's called _spect_ there).\n\n## Alternatives\n\n* [list-difference objects](https://github.com/paldepind/list-difference/blob/master/index.js)\n* [list-difference maps](https://github.com/luwes/js-diff-benchmark/blob/master/libs/list-difference.js)\n\n\u003cp align=\"center\"\u003eॐ\u003c/p\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdy%2Fswapdom","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdy%2Fswapdom","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdy%2Fswapdom/lists"}