{"id":15505817,"url":"https://github.com/adrian-samoticha/num_remap","last_synced_at":"2025-04-23T01:54:29.948Z","repository":{"id":48998448,"uuid":"517124123","full_name":"Adrian-Samoticha/num_remap","owner":"Adrian-Samoticha","description":"An implementation for the “Arduino map” function in Dart, which allows numbers to be remapped from one range to another.","archived":false,"fork":false,"pushed_at":"2023-10-20T09:22:01.000Z","size":15,"stargazers_count":4,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-23T01:54:22.305Z","etag":null,"topics":["arduino","dart","double","integer","map","number","remap"],"latest_commit_sha":null,"homepage":"https://pub.dev/packages/num_remap","language":"Dart","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Adrian-Samoticha.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":"2022-07-23T17:37:48.000Z","updated_at":"2023-07-22T15:36:57.000Z","dependencies_parsed_at":"2024-11-15T12:16:39.431Z","dependency_job_id":null,"html_url":"https://github.com/Adrian-Samoticha/num_remap","commit_stats":{"total_commits":13,"total_committers":2,"mean_commits":6.5,"dds":0.07692307692307687,"last_synced_commit":"f75409a5ebff3cd70833d537b4f5096ecc6b4625"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Adrian-Samoticha%2Fnum_remap","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Adrian-Samoticha%2Fnum_remap/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Adrian-Samoticha%2Fnum_remap/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Adrian-Samoticha%2Fnum_remap/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Adrian-Samoticha","download_url":"https://codeload.github.com/Adrian-Samoticha/num_remap/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250354301,"owners_count":21416751,"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":["arduino","dart","double","integer","map","number","remap"],"created_at":"2024-10-02T09:24:36.676Z","updated_at":"2025-04-23T01:54:29.926Z","avatar_url":"https://github.com/Adrian-Samoticha.png","language":"Dart","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003c!-- \nThis README describes the package. If you publish this package to pub.dev,\nthis README's contents appear on the landing page for your package.\n\nFor information about how to write a good package README, see the guide for\n[writing package pages](https://dart.dev/guides/libraries/writing-package-pages). \n\nFor general information about developing packages, see the Dart guide for\n[creating packages](https://dart.dev/guides/libraries/create-library-packages)\nand the Flutter guide for\n[developing packages and plugins](https://flutter.dev/developing-packages). \n--\u003e\n\nAn implementation for the [“Arduino map”](https://www.arduino.cc/reference/en/language/functions/math/map/) function in Dart, which allows numbers to be remapped from one range to another.\n\n## Features\n\n**`remap` method:**\n\nRemaps a number from one range to another. That is, a value of `fromLow` would\nget mapped to `toLow`, a value of `fromHigh` to `toHigh`, and values in-between to values\nin-between.\n\nIt does not constrain the values to the provided range, because out-of-range values are\nsometimes intended and useful. Use the `remapAndClamp` method if you wish for\nthe values to be constrained.\n\nNote that the “lower bounds” of either range may be larger or smaller than the\n“upper bounds” so the `remap()` method may be used to reverse a range of numbers,\nfor example:\n```dart\nfinal reversedX = x.remap(1, 50, 50, 1);\n```\n\nThe method also handles negative numbers well, so that this example\n```dart\nfinal y = x.remap(1, 50, 50, -100);\n```\nis also valid.\n\n\u003cbr\u003e\n\n**`remapAndClamp` method:**\n\nSame as `remap`, however, the result is being constrained to the range\n`toLow`-`toHigh`.\n\nFor instance, the following code returns `1`:\n```dart\n150.remapAndClamp(0, 100, 0, 1)\n```\n\nNote that `toLow` may be greater than `toHigh`, so the following code\n```dart\nfinal y = x.remapAndClamp(0, 100, 100, 0);\n```\nworks.\n\n\u003cbr\u003e\n\n**Integer-only methods:**\n\nBoth the `remap` and the `remapAndClamp` offer integer-only versions of themselves (named `remapInt` and `remapAndClampInt` respectively). These work the same as their `num` counterparts, however, their returned value is guaranteed to be an integer.\n\n\u003cbr\u003e\n\n**`isWithinRange` method:**\n\nReturns whether a number is within a given range.\n\n\u003cbr\u003e\n\n## Getting started\n\n1. Add the package as a dependency to your `pubspec.yaml`.\n2. Import the library:\n\n```dart\nimport 'package:num_remap/num_remap.dart';\n```\n\n\u003cbr\u003e\n\n## Usage\n\nThe library acts as an extension to the `num` and `int` types. You can use its methods as follows:\n\n```dart\nimport 'package:num_remap/num_remap.dart';\n\n...\n\nfinal someDouble = 0.5;\nfinal remappedDouble = someDouble.remap(0.0, 1.0, -100.0, 100.0);\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fadrian-samoticha%2Fnum_remap","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fadrian-samoticha%2Fnum_remap","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fadrian-samoticha%2Fnum_remap/lists"}