{"id":23231678,"url":"https://github.com/danielduarte/diffparse","last_synced_at":"2025-04-05T19:29:21.896Z","repository":{"id":57164450,"uuid":"269764550","full_name":"danielduarte/diffparse","owner":"danielduarte","description":"Simple parser for Diff files (unified diff format)","archived":false,"fork":false,"pushed_at":"2022-11-13T00:26:23.000Z","size":16,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-02-11T17:18:25.578Z","etag":null,"topics":["diff","parse","parser","patch","tool","unified-format"],"latest_commit_sha":null,"homepage":"","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/danielduarte.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":"2020-06-05T20:14:14.000Z","updated_at":"2022-11-13T00:26:27.000Z","dependencies_parsed_at":"2023-01-22T21:45:59.915Z","dependency_job_id":null,"html_url":"https://github.com/danielduarte/diffparse","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/danielduarte%2Fdiffparse","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danielduarte%2Fdiffparse/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danielduarte%2Fdiffparse/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danielduarte%2Fdiffparse/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/danielduarte","download_url":"https://codeload.github.com/danielduarte/diffparse/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247390314,"owners_count":20931400,"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":["diff","parse","parser","patch","tool","unified-format"],"created_at":"2024-12-19T02:15:33.964Z","updated_at":"2025-04-05T19:29:21.869Z","avatar_url":"https://github.com/danielduarte.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# @tandil/diffparse\n[![NPM Package Version](https://img.shields.io/npm/v/@tandil/diffparse)](https://www.npmjs.com/package/@tandil/diffparse)\n[![License](https://img.shields.io/npm/l/@tandil/diffparse?color=%23007ec6)](https://github.com/danielduarte/diffparse/blob/master/LICENSE)\n[![Conventional Commits](https://img.shields.io/badge/Conventional%20Commits-1.0.0-blue.svg)](https://conventionalcommits.org)\n\nSimple parser for Diff files (unified diff format)\n\n## Features\n\n- Parse a diff file from its filepath\n- Parse a diff directly from a string\n- Error reporting: If there are parsing errors, the partial result is returned and the list of detected errors including line numbers\n\n## Usage\n\n### Parse from file\n\n#### Async with Promises\n\nGiven a filepath it returns a [`Promise`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise) that resolves to a JS object with the diff content parsed and easily accessible programmatically.\n\n```js\nconst parser = require('@tandil/diffparse');\n\nparser.parseDiffFile('./examples/example1.diff').then(diff =\u003e {\n  console.log(diff);\n});\n```\n\n#### Sync\n\n```js\nconst parser = require('@tandil/diffparse');\n\nconst diff = parser.parseDiffFileSync('./examples/example1.diff');\nconsole.log(diff);\n```\n\n### Parse from string\n\nGiven a diff string it returns a JS object with the diff content parsed and easily accessible programmatically.\n\n```js\nconst parser = require('@tandil/diffparse');\n\nconst diffStr = `diff --git a/.gitignore b/.gitignore\nnew file mode 100644\nindex 0000000..2ccbe46\n--- /dev/null\n+++ b/.gitignore\n@@ -0,0 +1 @@\n+/node_modules/`;\n\nconst diff = parser.parseDiffString(diffStr);\n\nconsole.log(diff);\n```\n\nOutputs\n\n```js\n{\n  header: [],\n  files: [\n    {\n      header: 'diff --git a/.gitignore b/.gitignore',\n      fileMode: 'new file mode 100644',\n      oldMode: null,\n      newMode: null,\n      index: 'index 0000000..2ccbe46',\n      oldFile: '--- /dev/null',\n      newFile: '+++ b/.gitignore',\n      chunks: [\n        {\n          header: '@@ -0,0 +1 @@',\n          content: [\n            '+/node_modules/'\n          ]\n        }\n      ]\n    }\n  ],\n  errors: []\n}\n```\n\n## Having issues?\n\nFeel free to report any issues or feature request in [Github repo](https://github.com/danielduarte/diffparse/issues/new).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdanielduarte%2Fdiffparse","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdanielduarte%2Fdiffparse","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdanielduarte%2Fdiffparse/lists"}