{"id":16096018,"url":"https://github.com/erikmichelson/array-changeset","last_synced_at":"2025-07-11T20:32:10.577Z","repository":{"id":225183724,"uuid":"765268265","full_name":"ErikMichelson/array-changeset","owner":"ErikMichelson","description":"TypeScript library for creating and applying changesets to arrays","archived":false,"fork":false,"pushed_at":"2025-07-08T11:58:42.000Z","size":46,"stargazers_count":0,"open_issues_count":5,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-07-08T13:01:33.855Z","etag":null,"topics":["array","changes","changeset","diff","javascript","node","typescript"],"latest_commit_sha":null,"homepage":"https://npm.im/array-changeset","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/ErikMichelson.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":"SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":"AUTHORS.md","dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2024-02-29T15:44:36.000Z","updated_at":"2025-01-07T12:27:30.000Z","dependencies_parsed_at":"2024-02-29T17:56:33.872Z","dependency_job_id":"a9e65b30-ae0f-4cbb-b8f6-6579ddf3c709","html_url":"https://github.com/ErikMichelson/array-changeset","commit_stats":{"total_commits":8,"total_committers":2,"mean_commits":4.0,"dds":0.25,"last_synced_commit":"e09b554b8d43f708deda9d73cb32ab01ad189279"},"previous_names":["erikmichelson/array-changeset"],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/ErikMichelson/array-changeset","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ErikMichelson%2Farray-changeset","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ErikMichelson%2Farray-changeset/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ErikMichelson%2Farray-changeset/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ErikMichelson%2Farray-changeset/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ErikMichelson","download_url":"https://codeload.github.com/ErikMichelson/array-changeset/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ErikMichelson%2Farray-changeset/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":264892336,"owners_count":23679272,"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":["array","changes","changeset","diff","javascript","node","typescript"],"created_at":"2024-10-09T17:10:09.544Z","updated_at":"2025-07-11T20:32:10.568Z","avatar_url":"https://github.com/ErikMichelson.png","language":"TypeScript","readme":"\u003c!--\nSPDX-FileCopyrightText: 2025 Erik Michelson \u003copensource@erik.michelson.eu\u003e\n\nSPDX-License-Identifier: MIT\n--\u003e\n\n# array-changeset\n\n[![NPM Version](https://img.shields.io/npm/v/array-changeset)](https://www.npmjs.com/package/array-changeset)\n[![Coverage Status](https://coveralls.io/repos/github/ErikMichelson/array-changeset/badge.svg?branch=main)](https://coveralls.io/github/ErikMichelson/array-changeset?branch=main)\n[![Checks](https://github.com/ErikMichelson/array-changeset/actions/workflows/check.yml/badge.svg)](https://github.com/ErikMichelson/array-changeset/actions/workflows/check.yml)\n[![Tests](https://github.com/ErikMichelson/array-changeset/actions/workflows/test.yml/badge.svg)](https://github.com/ErikMichelson/array-changeset/actions/workflows/test.yml)\n\nThis tiny library can be used to calculate the changeset between two arrays and applying these changes to another array.\n\nThe library is **ESM-only**. See [this note by sindresorhus][esm-note] to learn more about that.\n\n## Installation\n\n### Using npm\n\n```shell\nnpm install array-changeset\n```\n\n### In browser\n\n```html\n\u003cscript type=\"module\"\u003e\nimport { Changeset } from \"https://cdn.jsdelivr.net/npm/array-changeset@1/+esm\";\n\n// your code using Changeset\n\u003c/script\u003e\n```\n\n## Usage\n\n```javascript\nimport { Changeset } from 'array-changeset'\n\nconst arrayA = ['foo', '!']\nconst arrayB = ['foo', 'bar']\n\n// Use fromDiff to create a changeset from the difference between two arrays\nconst changeset = Changeset.fromDiff(arrayA, arrayB)\n\n// Check if there are any changes from arrayA to arrayB\nconsole.log(changeset.hasChanges()) // true\n\n// Access the added and removed elements\nconsole.log(changeset.getAdded()) // ['bar']\nconsole.log(changeset.getRemoved()) // ['!']\n\n// Add an event listener for logging additions\nconst logAddition = (item) =\u003e console.log(`Added: ${item}`)\nchangeset.addEventListener('add', logAddition) // Other events are: remove, clear\n\n// Modify the changeset (arrayA and arrayB are not modified)\nchangeset.add('!') // this triggers the event listener\nchangeset.remove('bar')\nchangeset.remove('more')\nchangeset.uniquelyAddItem('unique') // This triggers the event listener as well\nchangeset.uniquelyAddItem('unique', (a, b) =\u003e a === b) // The comparator is optional and defaults to fast-deep-equal\n\nconsole.log(changeset.getAdded()) // ['unique']\nconsole.log(changeset.getRemoved()) // ['more']\n\n// Remove the event listener again\nchangeset.removeEventListener('add', logAddition)\n\n// Apply the changeset to another array (without modifying arrayC)\nconst arrayC = ['much', 'more', 'foo', '!']\nconst modifiedC = changeset.applyOnto(arrayC)\nconsole.log(modifiedC) // ['much', 'foo', '!', 'unique']\n\n// Clear the changeset\nchangeset.clear()\n\nconsole.log(changeset.hasChanges()) // false\n```\n\n## License\n\nThis project is licensed under the MIT License. See the [LICENSE](LICENSE) file for details.\n\n[esm-note]: https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ferikmichelson%2Farray-changeset","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ferikmichelson%2Farray-changeset","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ferikmichelson%2Farray-changeset/lists"}