{"id":13411392,"url":"https://github.com/wil92/string-mismatch","last_synced_at":"2026-01-23T03:03:51.097Z","repository":{"id":31183678,"uuid":"127142558","full_name":"wil92/string-mismatch","owner":"wil92","description":"This library share functions for compare two strings and see the differences","archived":false,"fork":false,"pushed_at":"2025-11-20T12:30:49.000Z","size":535,"stargazers_count":9,"open_issues_count":2,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-11-20T14:27:53.617Z","etag":null,"topics":["algorithm","hacktoberfest","javascript","string"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/wil92.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.md","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-03-28T13:13:53.000Z","updated_at":"2025-11-20T12:29:45.000Z","dependencies_parsed_at":"2023-01-14T18:30:21.673Z","dependency_job_id":"e64ce4a0-1e2c-471f-8e86-f8c3938caa07","html_url":"https://github.com/wil92/string-mismatch","commit_stats":{"total_commits":193,"total_committers":4,"mean_commits":48.25,"dds":0.1968911917098446,"last_synced_commit":"3474d2e8000c4c8a13fcb8628917305ba59d1202"},"previous_names":[],"tags_count":27,"template":false,"template_full_name":null,"purl":"pkg:github/wil92/string-mismatch","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wil92%2Fstring-mismatch","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wil92%2Fstring-mismatch/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wil92%2Fstring-mismatch/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wil92%2Fstring-mismatch/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/wil92","download_url":"https://codeload.github.com/wil92/string-mismatch/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wil92%2Fstring-mismatch/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28679140,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-23T01:00:35.747Z","status":"online","status_checked_at":"2026-01-23T02:00:08.296Z","response_time":59,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":["algorithm","hacktoberfest","javascript","string"],"created_at":"2024-07-30T20:01:13.355Z","updated_at":"2026-01-23T03:03:51.081Z","avatar_url":"https://github.com/wil92.png","language":"TypeScript","readme":"# string-mismatch library\n\n[![Build Status](https://travis-ci.org/wil92/string-mismatch.png?branch=master)](https://travis-ci.org/wil92/string-mismatch)\n[![codecov.io](https://img.shields.io/codecov/c/github/wil92/string-mismatch/master.svg?style=flat-square)](http://codecov.io/github/wil92/string-mismatch?branch=master)\n[![contributions welcome](https://img.shields.io/badge/contributions-welcome-brightgreen.svg?style=flat)](https://github.com/wil92/string-mismatch/issues)\n\nThe library contain the next string comparison algorithms:\n\n|                                       |Greedy                         |[Levenshtein](https://en.wikipedia.org/wiki/Levenshtein_distance)|[Dice Coefficient](https://en.wikipedia.org/wiki/S%C3%B8rensen%E2%80%93Dice_coefficient)|\n|---------------------------------------|-------------------------------|-----------------------------------------------------------------|----------------------------------------------------------------------------------------|\n|**Complexity**                         |O(n*k) (**k** precision)       |O(n^2)                                                           |O(nlog n)                                                                               |\n|**Good**                               |Fast algorithm                 |Always the optimal solution                                      |Is based in probabilities and is a really fast algorithm                                |\n|**Bad**                                |The solution is not the optimal|Complexity is O(n^2)                                             |Impossible to see the differences between the strings                                   |\n|                                       |                               |Use n^2 memory                                                   |                                                                                        |\n|**Methods**                            |*difference*                   |*difference*                                                     |*distance*                                                                              |\n|                                       |*distance*                     |*distance*                                                       |                                                                                        |\n|**Operations for transform the string**|*insertion*                    |*insertion*                                                      |*not apply*                                                                             |\n|                                       |*deletion*                     |*deletion*                                                       |                                                                                        |\n|                                       |                               |*substitution*                                                   |                                                                                        |\n|**Class name**                         |`Greedy`                       |`Levenshtein`                                                    |`DiceCoefficient`                                                                                      |\n\nWhy use string-mismatch:\n\n- Ease to install and start using it\n- Modular library (use only what you want to use).\n- Support for browser and node applications.\n- Compatible with es5\n- Not external dependencies.\n- Completely documented.\n- Coverage over 95%.\n\n## Library documentation\n\n[https://wil92.github.io/string-mismatch/](https://wil92.github.io/string-mismatch/)\n\n## Install\n\n```\nnpm install --save string-mismatch\n```\n\n## Getting started\n\n### Nodejs application example\n\nHow to use the library and see the differences between two strings:\n\n```es5\nconst sm = require(\"string-mismatch\");\nconst greedyInstance = new sm.Greedy();\n\nvar start = 'This is a test for see how work the library',\n    end   = 'This is a test for know how work the new library';\n\nconsole.log(greedyInstance.differences(start, end));\n```\n\nThe result is an object array with the mismatch result. Each object with the next structure:\n\n```es5\n{\n  type: string, // type of sub-string:\n                //   'sub' -\u003e substitution\n                //   'ins' -\u003e insertion\n                //   'del' -\u003e deletion\n                //   'eql' -\u003e equal\n  value: string // value of the current sub-string\n}\n```\n\nThe resulting string can be concatenated like the next example:\n\n```es5\nconst sm = require(\"string-mismatch\");\nconst greedyInstance = new sm.Greedy();\n\nvar start = 'This is a test for see how work the library',\n    end   = 'This is a test for know how work the new library';\n\nfunction showResult(diffs) {\n    return diffs.reduce(function (text, value) {\n        switch (value.type) {\n            case 'del':\n                return text + '(-' + value.value + ')';\n            case 'ins':\n                return text + '(+' + value.value + ')';\n            case 'sub':\n                return text + '(-+' + value.value + ')';\n            case 'eql':\n                return text + value.value;\n        }\n    }, '');\n}\n\nconsole.log(showResult(greedyInstance.differences(start, end)));\n/*\nresult:\nThis is a test for (-see)(+know) how work the (+new )library\n*/\n```\n\nThis code can be tested in the project's examples. To run the examples use the next command:\n\n```\nnpm start\n```\n\n\n### Web application example\n\nImport the library\n\n```html5\n\u003c!--Greedy algorithm--\u003e\n\u003cscript src=\"lib/greedy.min.js\" type=\"application/javascript\"\u003e\u003c/script\u003e\n\u003c!--Levenshtein algorithm--\u003e\n\u003cscript src=\"lib/levenshtein.min.js\" type=\"application/javascript\"\u003e\u003c/script\u003e\n```\n\nExample with greedy algorithm:\n\n```html5\n\u003cscript type=\"application/javascript\"\u003e\n    var start = 'This is a test for see how work the library';\n    var end = 'This is a test for know how work the new library';\n    var alg = new Greedy(options);\n    var diffs = alg.differences(start, end);\n    console.log(diffs);\n\u003c/script\u003e\n```\n\nExample with the levenshtein algorithm:\n\n```html5\n\u003cscript type=\"application/javascript\"\u003e\n    var start = 'This is a test for see how work the library';\n    var end = 'This is a test for know how work the new library';\n    var alg = new Levenshtein(options);\n    var diffs = alg.differences(start, end);\n    console.log(diffs);\n\u003c/script\u003e\n```\n\n## Testing code\n\n```\nnpm test\n```\n\n## Built With\n\n* [webpack](https://webpack.js.org/) - For build the project\n* [npm](https://www.npmjs.com/) - Dependency Management\n* [jest](https://jestjs.io/) - Jest framework for test\n\n## Contributing\n\nAll contributions are welcome.\n\n## Versioning\n\nWe use [SemVer](http://semver.org/) for versioning. For the versions available, see the [tags on this repository](https://github.com/wil92/string-mismatch/tags).\n\n## Authors\n\n* **Guillermo González** - *Initial work* - [wil92](https://github.com/wil92)\n\n## [CHANGELOG](https://github.com/wil92/string-mismatch/blob/master/CHANGELOG.md)\n\n## License\n\nThis project is licensed under the MIT License - see the [LICENSE.md](https://gitlab.com/wil92/wankar-server/blob/development/LICENSE) file for details\n","funding_links":[],"categories":["Web Development"],"sub_categories":["Javascript"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwil92%2Fstring-mismatch","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwil92%2Fstring-mismatch","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwil92%2Fstring-mismatch/lists"}