{"id":16367552,"url":"https://github.com/alexmacarthur/striff","last_synced_at":"2025-03-15T11:32:44.639Z","repository":{"id":40306748,"uuid":"465954183","full_name":"alexmacarthur/striff","owner":"alexmacarthur","description":"Real simple string diffing.","archived":false,"fork":false,"pushed_at":"2022-12-15T03:16:56.000Z","size":281,"stargazers_count":203,"open_issues_count":1,"forks_count":4,"subscribers_count":6,"default_branch":"master","last_synced_at":"2025-02-27T00:54:55.424Z","etag":null,"topics":["diffing","javascript","text"],"latest_commit_sha":null,"homepage":"","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/alexmacarthur.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":"2022-03-04T02:25:28.000Z","updated_at":"2024-08-23T22:31:35.000Z","dependencies_parsed_at":"2023-01-29T01:45:15.475Z","dependency_job_id":null,"html_url":"https://github.com/alexmacarthur/striff","commit_stats":null,"previous_names":[],"tags_count":9,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alexmacarthur%2Fstriff","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alexmacarthur%2Fstriff/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alexmacarthur%2Fstriff/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alexmacarthur%2Fstriff/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/alexmacarthur","download_url":"https://codeload.github.com/alexmacarthur/striff/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243725001,"owners_count":20337656,"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":["diffing","javascript","text"],"created_at":"2024-10-11T02:50:12.433Z","updated_at":"2025-03-15T11:32:44.346Z","avatar_url":"https://github.com/alexmacarthur.png","language":"TypeScript","readme":"# striff\n\n[![Bundle Size](https://badgen.net/bundlephobia/minzip/striff)](https://bundlephobia.com/result?p=striff)\n\nSimple string diffing. Given two strings, `striff` will return an object noting which characters were added or removed, and at which indices.\n\n## Installation\n\nRun `npm install striff`. Or stick in on a page [via CDN](https://unpkg.com/striff).\n\n## Usage\n\nImport it, pass a couple of strings, and do whatever you want with the results.\n\n```js\nimport striff from \"striff\";\n\nconst result = striff(\"string #1\", \"string #2\");\n\n// {\n//   added: [\n//     ...added characters\n//   ],\n//   removed: [\n//     ...removed characters\n//   ]\n// }\n```\n\n## Examples\n\nHere's the kind of result you'll get with different types of diffing.\n\n### Strings w/ Characters Added\n\n#### Input\n\n```js\nconst str1 = \"abc\";\nconst str2 = \"abcde\";\n\nconst result = striff(str1, str2);\n```\n\n#### Result\n\n```js\n{\n  added: [\n    {\n      value: \"d\",\n      index: 3\n    },\n    {\n      value: \"e\",\n      index: 4\n    }\n  ],\n  removed: []\n}\n```\n\n### Strings w/ Characters Removed\n\n#### Input\n\n```js\nconst str1 = \"abc\";\nconst str2 = \"a\";\n\nconst result = striff(str1, str2);\n```\n\n#### Result\n\n```js\n{\n    added: [],\n    removed: [\n    {\n      value: \"b\",\n      index: 1\n    },\n    {\n      value: \"c\",\n      index: 2\n    }\n  ]\n}\n```\n\n### Strings w/ Duplicate, Consecutive Characters\n\nFor strings whose characters were changed at the _end_, the indices will be grouped together at the end of the string.\n\n#### Input\n\n```js\nconst str1 = \"abbbc\";\nconst str2 = \"ab\";\n\nconst result = striff(str1, str2);\n```\n\n#### Result\n\n```js\n{\n  added: [],\n  removed: [\n    {\n      value: \"b\",\n      index: 2\n    },\n    {\n      value: \"b\",\n      index: 3\n    },\n    {\n      value: \"c\",\n      index: 4\n    }\n  ]\n}\n```\n\nFor those whose characters were changed at the _beginning_, the indices will be grouped together at the beginning.\n\n#### Input\n\n```js\nconst str1 = \"abbbc\";\nconst str2 = \"bc\";\n\nconst result = striff(str1, str2);\n```\n\n#### Result\n\n```js\n{\n  added: [].\n  removed: [\n    {\n      value: \"a\",\n      index: 0\n    },\n    {\n      value: \"b\",\n      index: 1\n    },\n    {\n      value: \"b\",\n      index: 2\n    }\n  ]\n}\n```\n\n## Feedback or Contributions\n\nMake an issue or a pull request!\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falexmacarthur%2Fstriff","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Falexmacarthur%2Fstriff","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falexmacarthur%2Fstriff/lists"}