{"id":23458223,"url":"https://github.com/moxio/js-struct-compare","last_synced_at":"2025-04-14T02:51:25.120Z","repository":{"id":52100827,"uuid":"243301024","full_name":"Moxio/js-struct-compare","owner":"Moxio","description":"Javascript library to compare two (JSON-serializable) structures and return their differences","archived":false,"fork":false,"pushed_at":"2024-02-26T10:59:52.000Z","size":377,"stargazers_count":10,"open_issues_count":0,"forks_count":3,"subscribers_count":11,"default_branch":"master","last_synced_at":"2025-04-10T18:06:33.308Z","etag":null,"topics":["compare","diff","javascript","json","structure"],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","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/Moxio.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":"2020-02-26T15:48:00.000Z","updated_at":"2025-02-11T17:39:38.000Z","dependencies_parsed_at":"2024-02-26T11:55:54.762Z","dependency_job_id":"3162b678-0d8a-4e64-9b4a-f15330415539","html_url":"https://github.com/Moxio/js-struct-compare","commit_stats":{"total_commits":19,"total_committers":3,"mean_commits":6.333333333333333,"dds":0.3157894736842105,"last_synced_commit":"c14c9554d0743ab82393103f1e08ee9d791605d3"},"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Moxio%2Fjs-struct-compare","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Moxio%2Fjs-struct-compare/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Moxio%2Fjs-struct-compare/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Moxio%2Fjs-struct-compare/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Moxio","download_url":"https://codeload.github.com/Moxio/js-struct-compare/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248813824,"owners_count":21165631,"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":["compare","diff","javascript","json","structure"],"created_at":"2024-12-24T05:17:39.138Z","updated_at":"2025-04-14T02:51:25.100Z","avatar_url":"https://github.com/Moxio.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"![CI](https://github.com/Moxio/js-struct-compare/workflows/Continuous%20Integration/badge.svg)\n[![NPM version](https://img.shields.io/npm/v/js-struct-compare.svg)](https://www.npmjs.com/package/js-struct-compare)\n\njs-struct-compare\n=================\nJavascript library to compare two (JSON-serializable) structures and return their\ndifferences.\n\nInstallation\n------------\nThis library can be installed from the NPM package registry. Using NPM:\n```sh\nnpm install --save js-struct-compare\n```\nOr using Yarn:\n```sh\nyarn add js-struct-compare\n```\n\nUsage\n-----\nThis package is meant to be consumed as an ES module. Its default export is a\ncomparison function that takes a _left_ and a _right_ instance and returns an\narray of differences between them. These can be seen as the operations needed\nto transform _left_ into _right_. An example:\n```js\nimport compare from \"js-struct-compare\";\n\nconst left = {\n    \"foo\": {\n        \"bar\": [ 42, 0 ],\n    },\n    \"qux\": \"quux\",\n    \"corge\": \"grault\",\n    \"garply\": [],\n};\nconst right = {\n    \"foo\": {\n        \"bar\": [ 43, 0 ],\n        \"baz\": 99,\n    },\n    \"corge\": \"grault\",\n    \"garply\": {},\n};\n\nconst differences = compare(left, right);\n// =\u003e [\n//   Difference{path: ['foo', 'bar', 0], type: 'changed', left_value: 42, right_value: 43},\n//   Difference{path: ['foo', 'baz'], type: 'added', left_value: undefined, right_value: 99},\n//   Difference{path: ['qux'], type: 'deleted', left_value: 'quux', right_value: undefined}\n//   Difference{path: ['garply'], type: 'changed', left_value: [], right_value: {}},\n// ]\n```\n\nEach `Difference` object contains:\n\n* A `path`: an array of path elements traversed to the location of the differences. The path\n  elements are strings in case of object properties and numbers in case of array keys.\n* A `type`: describes the kind of difference. Can be one of the following:\n    * `Difference.TYPE_CHANGED = 'changed'`: both the _left_ and the _right_ instance have a\n      value at the given path, but these values are different.\n    * `Difference.TYPE_ADDED = 'added'`: the _left_ instance does not have a value at the\n      given path, but the _right_ instance does, i.e. the value was added in the transition\n      from _left_ to _right_.\n    * `Difference.TYPE_DELETED = 'deleted'`: the _left_ instance has a value at the given\n      path, but the _right_ instance does not, i.e. the value was deleted in the transition\n      from _left_ to _right_.\n* A `left_value`: the value the _left_ instance has at the given path. Is `undefined` in case\n  of an addition. Can be a non-scalar value, i.e. a struct in itself.\n* A `right_value`: the value the _right_ instance has at the given path. Is `undefined` in case\n  of a deletion. Can be a non-scalar value, i.e. a struct in itself.\n\nThe `Difference` and `Comparator` classes can be accessed separately as named exports:\n```js\nimport { Difference, Comparator } from \"js-struct-compare\";\n```\n\nVersioning\n----------\nThis project adheres to [Semantic Versioning](http://semver.org/).\n\nContributing\n------------\nContributions to this project are more than welcome.\n\nLicense\n-------\nThis project is released under the MIT license.\n\n---\nMade with love, coffee and fun by the [Moxio](https://www.moxio.com) team from\nDelft, The Netherlands. Interested in joining our awesome team? Check out our\n[vacancies](https://werkenbij.moxio.com/) (in Dutch).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmoxio%2Fjs-struct-compare","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmoxio%2Fjs-struct-compare","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmoxio%2Fjs-struct-compare/lists"}