{"id":22880959,"url":"https://github.com/beermoneydev/serially-equivalent","last_synced_at":"2025-03-31T15:49:03.151Z","repository":{"id":54225289,"uuid":"343182708","full_name":"BeerMoneyDev/serially-equivalent","owner":"BeerMoneyDev","description":"An equivalence function comparing objects by serialized equivalence no nested functions or Symbols involved.","archived":false,"fork":false,"pushed_at":"2021-03-02T14:06:14.000Z","size":128,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-03-07T16:42:02.899Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/BeerMoneyDev.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","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":"2021-02-28T18:31:57.000Z","updated_at":"2021-03-02T14:06:12.000Z","dependencies_parsed_at":"2022-08-13T09:40:11.175Z","dependency_job_id":null,"html_url":"https://github.com/BeerMoneyDev/serially-equivalent","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BeerMoneyDev%2Fserially-equivalent","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BeerMoneyDev%2Fserially-equivalent/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BeerMoneyDev%2Fserially-equivalent/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BeerMoneyDev%2Fserially-equivalent/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/BeerMoneyDev","download_url":"https://codeload.github.com/BeerMoneyDev/serially-equivalent/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246491415,"owners_count":20786177,"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-12-13T17:28:48.497Z","updated_at":"2025-03-31T15:49:03.135Z","avatar_url":"https://github.com/BeerMoneyDev.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# SeriallyEquivalent\n\n\n### Purpose\n\nSeriallyEquivalent is a equivalence function derivative of [deep-equal](https://github.com/inspect-js/node-deep-equal/). It exists to compare objects as they would be expressed serially, outside the memory of a given application. SeriallyEquivalent ignore functions and Symbols and types that aren't intended to serialize through `JSON.stringify()`.\nIt provides options for excluding array ordering. If the length of the arrays are the same, and all elements have a serially equivalent \"partner\" then it will return true, ignoring the order. You can exclude properties by name if that is requried in your usecase (See examples below).  Most importantly, you can inject your own logging function to determine where two objects are failing their equivalence checks.\n\u003cbr/\u003e\n\u003cbr/\u003e\n\n### Usage\n\nThis library can be useful for people to determine if changes have been made in an object as it would be expressed outside your application.\nWhat does it matter to out-of-process consumers that a function is defined on one object and not another?\n\n```ts\nimport { seriallyEquivalent } from 'serially-equivalent';\nimport deepEqual from 'deep-equal';\n\nconst a = {\n    name: 'Ben',\n    age: 33,\n    isFun: () =\u003e false,\n};\n\nconst b = {\n    name: 'Ben',\n    age: 33,\n};\nassert.equal(seriallyEquivalent(a,b), true);\nassert.equal(deepEqual(a,b), false);\n\n```\n\u003cbr/\u003e\n\u003cbr/\u003e\n\n### Options\n\n\u003cbr/\u003e\n\n#### RequireArrayOrdering\n\nBy default array ordering is required but it can be easily disabled as seen below.\n\n\n```ts\nimport { seriallyEquivalent, SeriallyEquivalentOptions } from 'serially-equivalent';\nimport deepEqual from 'deep-equal';\n\nconst a = {\n    arr: [{ name: 'Ben'}, { name: 'Sam'}],\n};\n\nconst b = {\n    arr: [{ name: 'Sam'}, { name: 'Ben'}]\n};\nconst opts: SeriallyEquivalentOptions = {\n    requireArrayOrdering: false,\n}\nassert.equal(seriallyEquivalent(a,b, opts), true);\nassert.equal(deepEqual(a,b), false);\n\n```\n\u003cbr/\u003e\n\n#### ExcludedProperties\n\nYou can exclude properties from comparison by specifying a string array of properties to be excluded.\nProperty names are seperated by `.` and `root` is always the prefix.\n\nArray example\n```ts\nimport { seriallyEquivalent, SeriallyEquivalentOptions } from 'serially-equivalent';\nimport deepEqual from 'deep-equal';\n\nconst a = {\n    arr: [{ name: 'Ben', age: 33, favoriteColor: 'blue'}],\n};\n\nconst b = {\n    arr: [{ name: 'Ben', age: 33, favoriteColor: 'red'}]\n};\nconst opts: SeriallyEquivalentOptions = {\n    excludedProperties: ['root.arr.favoriteColor'],\n}\nassert.equal(seriallyEquivalent(a,b, opts), true);\nassert.equal(deepEqual(a,b), false);\n\n```\n\nObject example\n```ts\nimport { seriallyEquivalent, SeriallyEquivalentOptions } from 'serially-equivalent';\nimport deepEqual from 'deep-equal';\n\nconst a = {\n    name: 'Ben',\n    address: {\n        city: 'Baltimore',\n        state: 'MD',\n        guid: '370e9584-4db9-4e20-8972-f8eae5c81d35',\n    }\n};\n\nconst b = {\n    name: 'Ben',\n    address: {\n        city: 'Baltimore',\n        state: 'MD',\n        guid: 'a93c1253-8b8f-4e3d-8794-2819e4411a4c',\n    }\n};\nconst opts: SeriallyEquivalentOptions = {\n    excludedProperties: ['root.address.guid'],\n}\nassert.equal(seriallyEquivalent(a,b, opts), true);\nassert.equal(deepEqual(a,b), false);\n\n```\n\n\u003cbr/\u003e\n\n#### Debugging\n\nWith complex objects it can be helpful to know where a mismatch occured within the structure of the object.\nWe optionally allow you to inject a debug function to log the mismatch.\n\n\n```ts\nimport { seriallyEquivalent, SeriallyEquivalentOptions } from 'serially-equivalent';\nimport deepEqual from 'deep-equal';\n\nconst a = {\n    name: 'Ben',\n    age: 33,\n};\n\nconst b = {\n    name: 'Ben',\n    age: 32,\n};\n\nconst opts: SeriallyEquivalentOptions = {\n    debug: (msg: string) =\u003e { console.warn(msg);}\n}\nassert.equal(seriallyEquivalent(a,b, opts), false);\n\n\n//  console.warn\n//    Equivalence failed at root.age for issue: Actual not equal to expected. One may not be truthy...\n//            truthy status actual: true\n//            truthy status expected: true. \n//            Or both do not have typeof object and unmatched values...\n//            typof actual: number\n//            typeof expected: number\n//            value actual: 33\n//            value expected: 32\n\n```\n\n\nThese are the basic use cases for the library. ","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbeermoneydev%2Fserially-equivalent","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbeermoneydev%2Fserially-equivalent","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbeermoneydev%2Fserially-equivalent/lists"}