{"id":26919430,"url":"https://github.com/vmcruz/sandboxed-diff","last_synced_at":"2026-01-17T01:35:16.907Z","repository":{"id":284173620,"uuid":"954076136","full_name":"vmcruz/sandboxed-diff","owner":"vmcruz","description":"A zero dependency, high-performance, security-conscious JavaScript diffing library","archived":false,"fork":false,"pushed_at":"2026-01-14T04:25:02.000Z","size":142,"stargazers_count":6,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2026-01-14T05:02:15.230Z","etag":null,"topics":["diff","diffing","object-diff","typescript-library"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/@sandboxed/diff","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/vmcruz.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,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-03-24T14:25:19.000Z","updated_at":"2026-01-14T04:23:49.000Z","dependencies_parsed_at":"2025-03-24T15:39:22.645Z","dependency_job_id":null,"html_url":"https://github.com/vmcruz/sandboxed-diff","commit_stats":null,"previous_names":["vmcruz/sandboxed-diff"],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/vmcruz/sandboxed-diff","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vmcruz%2Fsandboxed-diff","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vmcruz%2Fsandboxed-diff/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vmcruz%2Fsandboxed-diff/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vmcruz%2Fsandboxed-diff/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/vmcruz","download_url":"https://codeload.github.com/vmcruz/sandboxed-diff/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vmcruz%2Fsandboxed-diff/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28491609,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-17T00:50:05.742Z","status":"ssl_error","status_checked_at":"2026-01-17T00:43:11.982Z","response_time":107,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["diff","diffing","object-diff","typescript-library"],"created_at":"2025-04-01T21:33:47.385Z","updated_at":"2026-01-17T01:35:16.887Z","avatar_url":"https://github.com/vmcruz.png","language":"TypeScript","readme":"# @sandboxed/diff\n\nA **zero dependency, high-performance, security-conscious** JavaScript diffing library for comparing complex data structures with ease.\n\n## Features\n\n- ⚡️ **Zero dependencies** – lightweight and no external libraries required\n- 📝 Detects **additions, deletions, and modifications**\n- 💡 Supports **Primitives, Objects, Arrays, Maps, and Sets**\n- 🔄 **Handles circular references** safely\n- 🛠️ **Highly configurable** to fit different use cases\n- 🚨 **Built with security in mind** to prevent prototype pollution and other risks\n- 💻 Works in both **Node.js and browser environments**\n\n## Installation\n\n```\nnpm install @sandboxed/diff\n\nyarn add @sandboxed/diff\n```\n\n### Supports `esm` and `cjs`\n\nWorks with both ESM (`import`) and CJS (`require`). Use the syntax that matches your environment:\n\n```javascript\n// ESM\nimport diff, { ChangeType } from '@sandboxed/diff';\n\n// CJS option 1\nconst diff = require('@sandboxed/diff').default;\nconst { ChangeType } = require('@sandboxed/diff');\n\n// CJS option 2\nconst { default: diff, ChangeType } = require('@sandboxed/diff');\n```\n\n## Usage\n\n#### `diff(lhs: any, rhs: any, config?: DiffConfig): Diff`\n\n```javascript\nimport diff, { ChangeType } from '@sandboxed/diff';\n\nconst a = { name: \"Alice\", age: 25 };\nconst b = { name: \"Alice\", age: 26, city: \"New York\" };\n\nconst result = diff(a, b);\n\nconsole.log(result);\nconsole.log(result.toDiffString());\nconsole.log(result.equal); // false\n```\n\n**Output**:\n\n```javascript\n[\n  { type: 'noop', str: '{', depth: 0, path: [] },\n  {\n    type: 'noop',\n    str: '\"name\": \"Alice\",',\n    depth: 1,\n    path: [ 'name', { deleted: false, value: 'Alice' } ]\n  },\n  {\n    type: 'remove',\n    str: '\"age\": 25,',\n    depth: 1,\n    path: [ 'age', { deleted: true, value: 25 } ]\n  },\n  {\n    type: 'update',\n    str: '\"age\": 26,',\n    depth: 1,\n    path: [ 'age', { deleted: false, value: 26 } ]\n  },\n  {\n    type: 'add',\n    str: '\"city\": \"New York\",',\n    depth: 1,\n    path: [ 'city', { deleted: false, value: 'New York' } ]\n  },\n  { type: 'noop', str: '}', depth: 0, path: [] }\n]\n\n// ---\n\n{\n   \"name\": \"Alice\",\n-  \"age\": 25,\n!  \"age\": 26,\n+  \"city\": \"New York\",\n}\n```\n\n## Config\n\n| option | Description |\n|-|-|\n|[config.include](/docs/config.md#include-changetype--changetype)| Include only these change types from the diff result. Can be combined with `exclude`. |\n|[config.exclude](/docs/config.md#exclude-changetype--changetype)| Excludes the change types from the diff result. Can be combined with `include`. |\n|[config.strict](/docs/config.md#strict-boolean)| Performs loose type check if disabled. |\n|[config.showUpdatedOnly](/docs/config.md#showupdatedonly-boolean)| `@sandboxed/diff` creates a `ChangeType.REMOVE` entry for every `ChangeType.UPDATE`. This flags prevents this behavior. |\n|[config.pathHints](/docs/config.md#pathhints-pathints)| Hashmap of `map` and `set` path hints. These strings will be used in the `path` array to provide a hit about the object's type. |\n|[config.redactKeys](/docs/config.md#redactkeys-arraystring)| List of keys that should be redacted from the output. Works with `string` based keys and serialized `Symbol`. |\n|[config.maxDepth](/docs/config.md#maxdepth-number)| Max depth that the diffing function can traverse. |\n|[config.maxKeys](/docs/config.md#maxkeys-number)| Max keys the diffing function can traverse. |\n|[config.timeout](/docs/config.md#timeout-number)| Milliseconds before throwing a timeout error. |\n\n## Utils\n\n| util | Description |\n|-|-|\n|[toDiffString](/docs/utils.md#diff-string-output)| Generates the diff string representation of the diff result. |\n|[equal](/docs/utils.md#equality-detection)| Determines whether the inputs are structurally equal based on the diff result. |\n\n## Motivation\n\nMany diffing libraries are optimized for either structured output or human-readable text, but rarely both. `@sandboxed/diff` is designed to provide a structured diff result along with a utility to generate a string representation, making it easy to use in both programmatic logic and UI rendering.\n\nTrade-off: It may be **slower than other libraries**, but if you prioritize structured diffs with a built-in string representation, `@sandboxed/diff` is a great fit.\n\n## LICENSE\n\n[MIT](LICENSE)\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvmcruz%2Fsandboxed-diff","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fvmcruz%2Fsandboxed-diff","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvmcruz%2Fsandboxed-diff/lists"}