{"id":13555600,"url":"https://github.com/eugeneware/changeset","last_synced_at":"2025-04-09T12:06:50.408Z","repository":{"id":8878812,"uuid":"10594936","full_name":"eugeneware/changeset","owner":"eugeneware","description":"Library to diff JSON objects into atomic put and delete operations, and apply change sets to objects. Useful with Levelup/LevelDB object synchronization.","archived":false,"fork":false,"pushed_at":"2021-06-12T17:38:20.000Z","size":69,"stargazers_count":123,"open_issues_count":9,"forks_count":9,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-30T15:44:52.705Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/eugeneware.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}},"created_at":"2013-06-10T06:48:37.000Z","updated_at":"2025-02-22T23:31:51.000Z","dependencies_parsed_at":"2022-08-30T17:41:50.668Z","dependency_job_id":null,"html_url":"https://github.com/eugeneware/changeset","commit_stats":null,"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eugeneware%2Fchangeset","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eugeneware%2Fchangeset/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eugeneware%2Fchangeset/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eugeneware%2Fchangeset/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/eugeneware","download_url":"https://codeload.github.com/eugeneware/changeset/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248036063,"owners_count":21037092,"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-08-01T12:03:18.355Z","updated_at":"2025-04-09T12:06:50.389Z","avatar_url":"https://github.com/eugeneware.png","language":"JavaScript","funding_links":[],"categories":["JavaScript","others"],"sub_categories":[],"readme":"# changeset\n\nGenerate diff changesets for javascript objects, decomposing diffs into a series of puts and delete operations. The format is similar to the [levelup](https://github.com/rvagg/node-levelup) [batch](https://github.com/rvagg/node-levelup#batch) operation list for bulk operations.\n\nHandles circular references of Objects and Arrays.\n\n[![build status](https://secure.travis-ci.org/eugeneware/changeset.png)](http://travis-ci.org/eugeneware/changeset)\n\n# Example\n\nTake a diff of two objects and produce a list of transformation operations:\n\n``` js\nvar diff = require('changeset');\nvar a = {\n  name: 'Eugene',\n  number: 42,\n  tags: ['tag1', 'tag2', 'tag3'],\n  scores: {\n    tetris: 1000,\n    carmageddon: 3\n  }\n};\n\nvar b = {\n  name: 'Susan',\n  number: 43,\n  tags: ['tag1', 'tag4'],\n  scores: {\n    carmageddon: 3,\n    zelda: 3000\n  },\n  age: 37\n};\n\nvar changes = diff(a, b);\nexpect(changes).to.deep.equal([\n  { type: 'put', key: ['name'], value: 'Susan' },\n  { type: 'put', key: ['number'], value: 43 },\n  { type: 'put', key: ['tags', '1'], value: 'tag4' },\n  { type: 'del', key: ['tags', '2'] },\n  { type: 'del', key: ['scores', 'tetris'] },\n  { type: 'put', key: ['scores', 'zelda'], value: 3000 },\n  { type: 'put', key: ['age'], value: 37 }\n]);\n```\n\nApply an operational changeset and apply it to an object to get a transformed object:\n\n``` js\nvar diff = require('changeset');\n\nvar changes = [\n  { type: 'put', key: ['name'], value: 'Susan' },\n  { type: 'put', key: ['number'], value: 43 },\n  { type: 'put', key: ['tags', '1'], value: 'tag4' },\n  { type: 'del', key: ['tags', '2'] },\n  { type: 'del', key: ['scores', 'tetris'] },\n  { type: 'put', key: ['scores', 'zelda'], value: 3000 },\n  { type: 'put', key: ['age'], value: 37 }\n];\n\nvar a = {\n  name: 'Eugene',\n  number: 42,\n  tags: ['tag1', 'tag2', 'tag3'],\n  scores: {\n    tetris: 1000,\n    carmageddon: 3\n  }\n};\n\n// apply the changes to a\nvar b_ = diff.apply(changes, a);\n\nvar b = {\n  name: 'Susan',\n  number: 43,\n  tags: ['tag1', 'tag4'],\n  scores: {\n    carmageddon: 3,\n    zelda: 3000\n  },\n  age: 37\n};\n\n// the transformed object should now equal b\nexpect(b_).to.deep.equals(b);\n```\n\nBy default ```apply``` will return a new modified object after applying the\nchangeset. If you want to modify the destination, pass true as the third\nparameter:\n\n``` js\n// apply the changes to a and modify a\nvar b_ = diff.apply(changes, a, true);\n// a is now modified, and b_ is the same as a\nexpect(b_).to.equal(a);\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Feugeneware%2Fchangeset","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Feugeneware%2Fchangeset","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Feugeneware%2Fchangeset/lists"}