{"id":17008165,"url":"https://github.com/szikszail/diffter","last_synced_at":"2025-04-12T07:21:26.922Z","repository":{"id":32114027,"uuid":"130113592","full_name":"szikszail/diffter","owner":"szikszail","description":"diffter can be used to determine the difference between two lists of any items and generate an HTML report about the results.","archived":false,"fork":false,"pushed_at":"2024-09-19T04:31:10.000Z","size":367,"stargazers_count":2,"open_issues_count":0,"forks_count":1,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-09-24T09:07:34.965Z","etag":null,"topics":["diff","filter","hacktoberfest","html","json"],"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/szikszail.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-04-18T19:43:23.000Z","updated_at":"2024-09-19T04:31:13.000Z","dependencies_parsed_at":"2023-01-14T20:32:44.030Z","dependency_job_id":"7102c942-aab1-4706-ab60-9a06a23d7cf8","html_url":"https://github.com/szikszail/diffter","commit_stats":{"total_commits":68,"total_committers":5,"mean_commits":13.6,"dds":"0.27941176470588236","last_synced_commit":"f3d29148e933fdb1ea16703fb65aa0356574f3d1"},"previous_names":[],"tags_count":9,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/szikszail%2Fdiffter","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/szikszail%2Fdiffter/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/szikszail%2Fdiffter/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/szikszail%2Fdiffter/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/szikszail","download_url":"https://codeload.github.com/szikszail/diffter/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248530761,"owners_count":21119626,"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","filter","hacktoberfest","html","json"],"created_at":"2024-10-14T05:27:35.241Z","updated_at":"2025-04-12T07:21:26.902Z","avatar_url":"https://github.com/szikszail.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# diffter\n\n![Downloads](https://img.shields.io/npm/dw/diffter?style=flat-square)\n![Version@npm](https://img.shields.io/npm/v/diffter?label=version%40npm\u0026style=flat-square)\n![Version@git](https://img.shields.io/github/package-json/v/szikszail/diffter/master?label=version%40git\u0026style=flat-square)\n![CI](https://img.shields.io/github/actions/workflow/status/szikszail/diffter/ci.yml?branch=master\u0026label=ci\u0026style=flat-square)\n\n**diffter** can be used to determine the difference between two list of any items and generate an HTML report about the results.\n\n## Prerequisites\n\n* Node.js 12+\n\n## Usage\n\nThe following script generated the report can be seen below:\n\n``` javascript\nconst {\n    diff,\n    saveReport\n} = require('diffter');\n\nconst baseList = [1, 2, 3, 4];\nconst subjectList = [1, 3, 4, 5];\n\nconst results = diff(baseList, subjectList);\nsaveReport('./report', results);\n```\n\n![report](example.png)\n\nThe items are colored in the following way:\n\n* **Green** items are the **same** in both list.\n* **Blue** items are **changed position** in subject list.\n* **Red** items in base list are those which are **deleted** in subject list.\n* **Yellow** items in subject list are those which are **new** compared to the base list.\n* **Gray** items are the **ignored** items.\n\n## CLI\n\nAfter `diffter` is installed globally or in local NPM scripts:\n\n``` \ndiffter-report --base path\\to\\base.json --subject path\\to\\subject.json --save report.html\ndiffter-results --base path\\to\\base.json --subject path\\to\\subject.json --save data.js --js\n\nOptions:\n  --help        Show help                                              [boolean]\n  --config      Path to JS/JSON config file\n  --base        Path of BASE results list JSON file.                  [required]\n  --subject     Path of SUBJECT results list JSON file.               [required]\n  --title       Title of the report                          [default: \"Report\"]\n  --save        Path of JSON file where DiffResults should be saved.  [required]\n  --comparator  Path of JS file which exports custom Comparator function. Config\n                could also contain actual Comparator function.\n  --filter      Path of JS file which exports custom Filter function. Config\n                could also contain actual Filter function.\n  --modifier    Path of JS file which exports custom function to transform\n                source data to display data. Config could also contain actual\n                Transform function.\n  --js          Should the result be save to JS file which exports DiffResults\n                Object.                                         [default: false]\n```\n\nThe `--config` can specify a JS/JSON file, which can contain all the above-listed options.\n\n## API\n\n### `diff(baseList, subjectList[, options])`\n\n**Params**:\n\n* `{SourceList|Array} baseList` - the list of items used as the base list\n* `{SourceList|Array} subjectList` - the list of subject items which are compared to the base list\n* `{DiffOptions} options` - options could be passed to the analyzer.\n\n**Returns**: `{DiffResults}` the results of the analysis\n\n### `saveReport(filePath, title, results)`\n\n**Params**:\n\n* `{string} filePath` - the path to the file, where report needs to be stored\n* `{string} title` - the title of the report\n* `{DiffResults} results` - the results needs to be displayed in report\n\n### `saveResults(filePath, results[, type[, jsPrefix]])`\n\n**Params**:\n\n* `{string} filePath` - the path to the file, where results needs to be stored\n* `{DiffResults} results` - the results needs to be stored in the file\n* `{string} type` - the type of the file to store the results,  `js` or `json`, default: `json`\n* `{string} jsPrefix` - the prefix which needs to be used in case of storing to JS, default: `module.exports = `\n\n## Types\n\n### `SourceList`\n\nType of a list as input for given methods.\n\n* `{string} title` - the title/name of the list\n* `{Array} items` - the actual items of the list\n\n``` json\n{\n    \"title\": \"Souce List\",\n    \"items\": [1, 2, 3]\n}\n```\n\n### `DiffResults`\n\nType of the diff-analysis results.\n\n* `{DiffList} baseList` - the items of the base list\n* `{DiffList} subjectList` - the items of the subject list\n* `{Array\u003cArray\u003cnumber\u003e\u003e} indexes` - the list of indexes/states\n\n``` json\n{\n    \"baseList\": {\n        \"title\": \"Base List\",\n        \"items\": [\n            {\"title\": 1},\n            {\"title\": 2},\n            {\"title\": 3}\n        ]\n    },\n    \"subjectList\": {\n        \"title\": \"Subject List\",\n        \"items\": [\n            {\"title\": 1},\n            {\"title\": 3},\n            {\"title\": 2}\n        ]\n    },\n    \"indexes\": [\n        [0, 0],\n        [1, 2],\n        [2, 1]\n    ]\n}\n```\n\n### `DiffList`\n\nType for a list to store result items.\n\n* `{string} title` - the title/name of the list\n* `{Array\u003cDiffListItem\u003e} items` - the actual items of the list\n\n``` json\n{\n    \"title\": \"Subject List\",\n    \"items\": [\n        {\"title\": 1},\n        {\"title\": 3},\n        {\"title\": 2}\n    ]\n}\n```\n\n### `DiffListItem`\n\nType for an item of a list.\n\n* `{string} title` - the title/name of the actual item\n* `{Object} metadata` - any metadata (key-value pair) of the given item\n\n``` json\n{\n    \"title\": 2\n}\n```\n\n### `DiffOptions`\n\nType to define options of diff-analysis.\n\n* `{Comparator} comparator` - the comparator function, by default: [deep-eql](https://www.npmjs.com/package/deep-eql)\n* `{Filter} filter` - the filter funtion, by default: `() =\u003e true`\n* `{Transform} transform` - the transform function, by default: `item =\u003e item`\n\n``` javascript\nmodule.exports = {\n    comparator: (a, b) =\u003e a === b,\n    filter: item =\u003e !item.ignore,\n    transform: item =\u003e ({\n        title: item\n    })\n}\n```\n\n### `Comparator`\n\nType for comparator function, to compare to items in the diff-analyzer.\n\n**Params**:\n\n* `{*} base` - the base item\n* `{*} subject` - the subject item\n\n**Returns**: `{boolean}` - `true` if the two items are equal\n\n### `Filter`\n\nType for filter function, to determine items to ignore.\n\n**Params**:\n\n* `{*} item` - the item to check\n\n**Returns**: `{boolean}` - `true` if the item should be kept\n\n### `Transform`\n\nType for transform function, to convert given items to `DiffListItem` .\n\n**Params**:\n\n* `{*} item` - the item to transform\n\n**Returns**: `{DiffListItem}` - the transformed item\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fszikszail%2Fdiffter","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fszikszail%2Fdiffter","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fszikszail%2Fdiffter/lists"}