{"id":27642012,"url":"https://github.com/bathos/justin-diff","last_synced_at":"2025-04-23T23:52:10.044Z","repository":{"id":86886302,"uuid":"44224200","full_name":"bathos/justin-diff","owner":"bathos","description":"that thing we were talking about maybe","archived":false,"fork":false,"pushed_at":"2015-10-14T22:03:50.000Z","size":140,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-23T23:52:05.990Z","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":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/bathos.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":"2015-10-14T04:37:12.000Z","updated_at":"2015-10-14T15:03:43.000Z","dependencies_parsed_at":"2023-03-13T19:49:42.712Z","dependency_job_id":null,"html_url":"https://github.com/bathos/justin-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/bathos%2Fjustin-diff","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bathos%2Fjustin-diff/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bathos%2Fjustin-diff/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bathos%2Fjustin-diff/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bathos","download_url":"https://codeload.github.com/bathos/justin-diff/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250535081,"owners_count":21446506,"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":"2025-04-23T23:52:09.472Z","updated_at":"2025-04-23T23:52:10.029Z","avatar_url":"https://github.com/bathos.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# JstnDiff\n\nHere’s a first try...\n\nI don’t have a clear picture in my head of the objects in question, though if I\nunderstood correctly this might yield what we’re looking for -- comparable,\ndiffable re-serializations with special handling for arrays.\n\nBut this depends an awful lot on the content of those arrays ... if we get a\nrandomly sequenced array of objects, who’s to say any one of those members is a\nmodification of its prior form rather than that of one of its peers? It all\nhinges on the assumption that the top-level properties of such objects are\nstatic ... and then some.\n\nHowever, if we know more about that actual form these objects will take though,\nwe could take more into account with a custom comparator, ensuring the critical,\n‘identity’ declaring properties float to the top.\n\nWe’re taking a little shortcut by exploiting the fact that properties have a\nspecified sequence in all modern JS engines (with a few caveats that don’t apply\nto these circumstances).\n\nAfter reorganizing the objects / arrays to their new 'sorted' forms, we run them\nthrough `diff`, an existing lib. It poops to stdout now but obviously we’ll want\nit to do something else later...\n\n## Example\n\nThis is the setup in ./test/test.js:\n\n```js\nconst a = JSON.stringify({\n  propertyA: 'X',\n  propertyB: 'Y',\n  propertyC: 'Z',\n  propertyD: [\n    { name: 'cat', softness: 7 },\n    { name: 'antelope', softness: 4 },\n    { name: 'basalt', softness: 0 }\n  ]\n});\n\nconst b = JSON.stringify({\n  propertyB: 'Y',\n  propertyA: 'new!',\n  propertyD: [\n    { name: 'antelope', softness: 4 },\n    { name: 'basalt', softness: 0, rock: true },\n    { name: 'cat', softness: 12 }\n  ],\n  propertyC: 'Z'\n});\n```\n\nAnd y’get:\n\n![example outpoop](https://github.com/bathos/justin-diff/raw/master/resource/example.png)\n\nSo it handles that fine, but note that if one of the `propertyD` members had\nadded a new property that would sort before 'name', the whole array would have\nbeen considered a diff. That’s why I figured we’d need domain-specific knowledge\nto augment this.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbathos%2Fjustin-diff","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbathos%2Fjustin-diff","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbathos%2Fjustin-diff/lists"}