{"id":18158177,"url":"https://github.com/seikho/fuzzy-ratio","last_synced_at":"2026-04-29T14:36:26.359Z","repository":{"id":92529389,"uuid":"107661452","full_name":"Seikho/fuzzy-ratio","owner":"Seikho","description":"Extracting aspect ratios from imperfect dimensions","archived":false,"fork":false,"pushed_at":"2017-10-24T09:07:52.000Z","size":10,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-02-13T08:14:27.380Z","etag":null,"topics":["aspect","nodejs","ratio","tolerance","typescript"],"latest_commit_sha":null,"homepage":null,"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/Seikho.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-10-20T09:50:47.000Z","updated_at":"2017-10-20T09:51:20.000Z","dependencies_parsed_at":null,"dependency_job_id":"f40130d2-17c2-4f48-a226-e871ff983810","html_url":"https://github.com/Seikho/fuzzy-ratio","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/Seikho%2Ffuzzy-ratio","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Seikho%2Ffuzzy-ratio/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Seikho%2Ffuzzy-ratio/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Seikho%2Ffuzzy-ratio/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Seikho","download_url":"https://codeload.github.com/Seikho/fuzzy-ratio/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247584057,"owners_count":20962071,"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":["aspect","nodejs","ratio","tolerance","typescript"],"created_at":"2024-11-02T07:05:48.171Z","updated_at":"2026-04-29T14:36:21.320Z","avatar_url":"https://github.com/Seikho.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Fuzzy Ratio\nDealing with off-by-N problems when dealing with aspect ratios.  \n\n## Installation\n\n```sh\n\u003e npm install fuzzy-ratio --save\n```\n\n## Example Usage\n\n```ts\nimport fuzzRatio from 'fuzzy-ratio'\n\n// 2% tolerance in dimension fuzzing\nfuzzRatio({ width: 317, height: 376, type: 'percent', tolerance: 2 }) // --\u003e Result\n\n// 2 'pixel' tolerance in dimension fuzzing\nfuzzRatio({ width: 317, height: 376, type: 'range', tolerance: 2 }) // --\u003e Result\n```\n\n### Function: fuzzRatio\n\n```ts\nfunction fuzzRatio(options: Options): Result\n```\n\n### Interface: Ratio\n```ts\ninterface Ratio {\n  width: number\n  height: number\n}\n```\n\n### Interface: RatioError\nThis is used for posterity/debugging\n\n```ts\ninterface RatioError {\n  diff: number\n  percent: number\n  mod: number\n}\n```\n\n### Interface: Result\n\n```ts\ninterface FuzzRatio extends Ratio {\n  original: Ratio\n  error: { width: RatioError, height: RatioError }\n}\n\ninterface Result {\n  /** The real aspect ratio with no fuzzing */\n  ratio: Ratio \n\n  /** If provided, the 'best' fuzzed ratio */\n  fuzzed?: FuzzRatio\n\n  /** All of the alternative fuzzed ratio candidates used in the fuzzing process */\n  alts?: FuzzRatio[]\n}\n```\n\n### Options\n\n```ts\ninterface Options {\n  width: number\n  height: number\n  type: 'percent' | 'range'\n  tolerance: number\n  allowedRatios?: Ratio[]\n}\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fseikho%2Ffuzzy-ratio","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fseikho%2Ffuzzy-ratio","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fseikho%2Ffuzzy-ratio/lists"}