{"id":21964335,"url":"https://github.com/dunosaurs/diff","last_synced_at":"2025-03-22T21:19:26.128Z","repository":{"id":56777468,"uuid":"488066290","full_name":"dunosaurs/diff","owner":"dunosaurs","description":"A simple and fast typescript diff implementation for Deno","archived":false,"fork":false,"pushed_at":"2023-08-28T20:08:21.000Z","size":22,"stargazers_count":3,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-01T18:38:20.046Z","etag":null,"topics":["deno","typescript"],"latest_commit_sha":null,"homepage":"https://deno.land/x/diff","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/dunosaurs.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2022-05-03T03:29:45.000Z","updated_at":"2025-02-07T23:36:15.000Z","dependencies_parsed_at":"2023-01-21T04:45:53.681Z","dependency_job_id":null,"html_url":"https://github.com/dunosaurs/diff","commit_stats":null,"previous_names":[],"tags_count":10,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dunosaurs%2Fdiff","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dunosaurs%2Fdiff/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dunosaurs%2Fdiff/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dunosaurs%2Fdiff/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dunosaurs","download_url":"https://codeload.github.com/dunosaurs/diff/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245020692,"owners_count":20548228,"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":["deno","typescript"],"created_at":"2024-11-29T12:06:04.103Z","updated_at":"2025-03-22T21:19:26.103Z","avatar_url":"https://github.com/dunosaurs.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# diff\n\n\u003e Deno library for usage of diff Based on the O(n * m) DP solution to the LCS\n\u003e problem\n\n```typescript\nimport { diffCharacters } from \"https://deno.land/x/diff/mod.ts\";\n\ndiffCharacters(\"ABCBDAB\", \"BDCABA\");\n```\n\n## API\n\n### diffCharacters(oldString: string, newString: string, ignoreCase = false): DiffCharacter[]\n\nCompares two strings by character and returns a list\n\n**oldString**: The string to be transformed\n\n**newString**: The string to be transformed into\n\n**ignoreCase**: Whether case differences should be taken into account\n\nReturns an array of `DiffCharacter` objects (explained below)\n\n### longestCommonSubsequence(a: string, b: string, ignoreCase = false)\n\nCompares two strings by character and returns the\n[longest common subsequence](https://en.wikipedia.org/wiki/Longest_common_subsequence_problem)\n\n## Types\n\n_DiffCharacter_\n\n```typescript\n{\n  character:\n  string;\n  wasAdded:\n  boolean;\n  wasRemoved:\n  boolean;\n}\n```\n\nThe object contains the character and whether that character was removed, added,\nor neither. Here is example usage\n\n```typescript\nlet finalString = \"\";\nfor (const character of diffCharacters(\"boopa\", \"boop beep boppy\")) {\n  if (character.wasRemoved) {\n    // print red if removed without newline\n    finalString += `\\x1b[31m${character.character}\\x1b[0m`;\n  } else if (character.wasAdded) {\n    // print green if added\n    finalString += `\\x1b[32m${character.character}\\x1b[0m`;\n  } else {\n    // print white if unchanged\n    finalString += `\\x1b[37m${character.character}\\x1b[0m`;\n  }\n}\nconsole.log(finalString);\n```\n\n![image](https://user-images.githubusercontent.com/11367844/200397905-1885fdb1-b765-4871-a66d-7f2bbe453bea.png)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdunosaurs%2Fdiff","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdunosaurs%2Fdiff","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdunosaurs%2Fdiff/lists"}