{"id":19223340,"url":"https://github.com/akushwarrior/starfruit","last_synced_at":"2025-07-15T04:08:04.195Z","repository":{"id":56840462,"uuid":"205468216","full_name":"AKushWarrior/starfruit","owner":"AKushWarrior","description":"A math library for Dart, similar to Guava for Java.","archived":false,"fork":false,"pushed_at":"2021-09-02T05:51:26.000Z","size":45,"stargazers_count":8,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-05-13T12:49:42.656Z","etag":null,"topics":["arrays","collection","dart","math","regression","starfruit","statistics"],"latest_commit_sha":null,"homepage":"https://pub.dev/packages/starfruit","language":"Dart","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mpl-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/AKushWarrior.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}},"created_at":"2019-08-30T23:08:13.000Z","updated_at":"2021-09-02T05:51:29.000Z","dependencies_parsed_at":"2022-08-29T01:51:09.495Z","dependency_job_id":null,"html_url":"https://github.com/AKushWarrior/starfruit","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/AKushWarrior/starfruit","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AKushWarrior%2Fstarfruit","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AKushWarrior%2Fstarfruit/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AKushWarrior%2Fstarfruit/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AKushWarrior%2Fstarfruit/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/AKushWarrior","download_url":"https://codeload.github.com/AKushWarrior/starfruit/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AKushWarrior%2Fstarfruit/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":265402583,"owners_count":23759185,"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":["arrays","collection","dart","math","regression","starfruit","statistics"],"created_at":"2024-11-09T15:07:56.573Z","updated_at":"2025-07-15T04:08:04.168Z","avatar_url":"https://github.com/AKushWarrior.png","language":"Dart","funding_links":["https://www.paypal.me/kishoredev"],"categories":[],"sub_categories":[],"readme":"# Starfruit\n\nA library containing useful utilities, efficiencies, and \nabstractions to improve over the Dart SDK and dart:math. It takes heavy \ninspiration from Guava (by Google) for Java, and ports some functions from \nit. \n\n---\n\nIt takes time, effort, and mental power to keep this package updated, useful, and\nimproving. If you used or are using the package, I'd appreciate it if you could spare a few \ndollars to help me continue to do so.\n\n[![PayPal](https://img.shields.io/static/v1?label=PayPal\u0026message=Donate\u0026color=blue\u0026logo=paypal\u0026style=for-the-badge\u0026labelColor=black)](https://www.paypal.me/kishoredev)\n\n---\n\n## Classes\n\nNote: https://pub.dev/documentation/starfruit/latest/starfruit/starfruit-library.html \nis auto-generated dartdocs. This has a more detailed rundown of every class\nand method. It's impossible to list every method offered and its purpose, \nso I won't try. You **should** use the usage examples and documentation to understand\nthe utilities of this library. For here, I'm just offering basic details on how to \ninstantiate every class.\n\n##### StarMathUtils (mathUtils)\nTo use, call methods on the singleton instance mathUtils (e.g. `mathUtils.chunks([1, 2, 3, 4, 5, 6], 2)` ).\n\n##### StarCollectionUtils (collectionUtils)\nTo use, call methods on the singleton instance collectionUtils (e.g. `collectionUtils.chunks([1, 2, 3, 4, 5, 6], 2)` ).\n\n##### StarStats (`List\u003cnum\u003e`)\nTo use, collect a list of numerical input data. You can then call StarStats methods on it, because\nStarStats is defined as an extension on List\u003cnum\u003e.\n\n##### StarStatsXY (```Map\u003cnum,num\u003e``` of points)\nTo use, collect input data formatted {x1: y1, x2: y2, x3: y3, ...}. You can then call StarStatsXY methods\non it, because StarStatsXY is defined as an extension on Map\u003cnum, num\u003e.\n\n---\n\n## Usage Examples\n\n##### Math Utilities:\n\n```dart\nimport 'package:starfruit/starfruit.dart';\n\nmain() {\n  /Round to 2 decimal places\n  //Ceiling and flooring to decimal places is also available\n  print('Round 3.5634 to 2 decimal places:');\n  print(mathUtils.roundToDouble(3.5634, 2));\n  print('');\n\n  //Power of two check\n  print('Is 8 a power of two?');\n  print(mathUtils.isPowerOfTwo(8));\n  print('');\n\n  //Calculate log base 2 of 8\n  print('Calculate log base 2 of 8:');\n  print(mathUtils.log(2, 8));\n  print('');\n\n  //double isInteger check\n  print('Is 6.0 an integer?');\n  print(mathUtils.isMathematicalInteger(6.0));\n  print('');\n\n  //Calculate 5!\n  print('Calculate 5 factorial:');\n  print(mathUtils.factorial(5));\n  print('');\n\n  //Check if 2 is within 3 of 5\n  print('Is 2 within 3 of 5?');\n  print(mathUtils.fuzzyEquals(2, 5, 3));\n  print('');\n\n  //Check if 7919 is a prime number\n  print('Is 7919 prime?');\n  print(mathUtils.isPrime(7919));\n  print('');\n\n  //LCM of 2 and 7\n  print('Calculate LCM of 2 and 7:');\n  print(mathUtils.lcm(2, 7));\n  print('');\n\n  //sinh of 1 radian\n  print('Calculate sinh of 1 radian:');\n  print(mathUtils.sinh(1));\n  print('');\n\n  //mean of 3 and 7\n  print('Calculate mean of 3 and 7:');\n  print(mathUtils.mean(3,7));\n  print('');\n\n  //nCr where n = 5 and r = 2\n  print('Calculate the binomial coefficient of 2 and 5:');\n  print(mathUtils.combinationsOf(5, 2));\n  print('');\n\n  //nPr where n = 5 and r = 2\n  print('Calculate the permutations of 5 and 2:');\n  print(mathUtils.permutationsOf(5, 2));\n  print('');\n}\n```\n##### Collection Utilities:\n```dart\nimport 'package:starfruit/starfruit.dart';\n\nmain() {\n  //Separate List into chunks\n  print(\"Separate List into chunks of 4:\");\n  print(cUtils.chunks([1,2,3,4,5,6,7,8], 4));\n  print(\"\");\n\n  //Collapse List\u003cList\u003cObject\u003e\u003e into just List\u003cObject\u003e\n  print(\"Collapse List\u003cList\u003e into List:\");\n  print(cUtils.collapse( [[1,2,3],[4,5,6,7,8]] ));\n  print(\"\");\n\n  //Get every nth object of list\n  print(\"Get every 4th object:\");\n  print(cUtils.nth([1,2,3,4,5,6,7,8], 4));\n  print(\"\");\n\n  //Get every n random elements of list\n  print(\"Get 5 random elements:\");\n  print(cUtils.random([1,2,3,4,5,6,7,8], 5));\n  print(\"\");\n\n  //Flip keys and values of a map\n  print(\"Flip keys and values of a map:\");\n  print(cUtils.flip({1:0, 2:8, 3:4, 0:5}));\n  print(\"\");\n\n  //Zip two Lists into a map\n  print(\"Zip two lists into a map:\");\n  print(cUtils.zip([1,2,3,4], [5,6,7,8]));\n  print(\"\");\n\n  //Unzip a map into two lists\n  print(\"Unzip a map into two lists:\");\n  print(cUtils.unzip({0:1, 8:2, 4:3, 5:0}));\n  print(\"\");\n}\n```\n\n##### Stats Utilities:\n\n```dart\nimport 'package:starfruit/starfruit.dart';\n\nmain() {\n  var stats = [1,3,4,5,12,3,4,67,8,0,22];\n\n  //median\n  print(\"Calculate the median:\");\n  print(stats.median);\n  print(\"\");\n\n  //mean\n  print(\"Calculate the mean:\");\n  print(stats.mean);\n  print(\"\");\n\n  //mode\n  print(\"Calculate the mode:\");\n  print(stats.mode);\n  print(\"\");\n\n  //variance\n  print('Calculate the variance:');\n  print(stats.variance);\n  print(\"\");\n\n  //standard deviation\n  print(\"Calculate the standard deviation:\");\n  print(stats.stdDev);\n  print(\"\");\n\n  //cardinality; number of unique elements\n  print(\"Calculate the cardinality:\");\n  print(stats.cardinality);\n  print(\"\");\n\n  //7 greatest elements\n  print(\"Return the 7 greatest elements:\");\n  print(stats.topElements(7));\n  print(\"\");\n}\n```\n##### XY (Paired) Stats Utilities:\n\n```dart\nimport 'package:starfruit/starfruit.dart';\n\nmain() {\n  var xystats = {2:3, 7:4, 4:6, 8:9, 1:2, 3:5, 11:14, 12:18};\n\n  //Get correlation coefficient\n  print(\"Calculate correlation coefficient:\");\n  print(xystats.corCoefficient);\n  print(\"\");\n\n  //Get determination coefficent\n  print(\"Calculate determination coefficient:\");\n  print(xystats.detCoefficient);\n  print(\"\");\n\n  //Get adjusted determination coefficient\n  print(\"Calculate adj. determination coefficient:\");\n  print(xystats.adjDetCoefficient);\n  print(\"\");\n\n  //Get linear regression line\n  print(\"Calculate linear regression line in form y = mx + b:\");\n  var lr = xystats.linReg;\n  print(\"y = ${lr[0]}x + ${lr[1]}\");\n  print(\"\");\n\n  //Get quadratic regression line\n  print(\"Calculate quadratic regression line in form y = ax^2 + bx + c:\");\n  var qdr = xystats.quadReg;\n  print(\"y = ${qdr[0]}x^2 + ${qdr[1]}x + ${qdr[2]}\");\n  print(\"\");\n\n  //Get cubic regression line\n  print(\"Calculate cubic regression line in form y = ax^3 + bx^2 + cx + d:\");\n  var cr = xystats.cubicReg;\n  print(\"y = ${cr[0]}x^3 + ${cr[1]}x^2 + ${cr[2]}x + ${cr[3]}\");\n  print(\"\");\n\n  //Get quartic regression line\n  print(\"Calculate quartic regression line in form y = ax^4 + bx^3 + cx^2 + dx + e:\");\n  var qrr = xystats.quarReg;\n  print(\"y = ${qrr[0]}x^4 + ${qrr[1]}x^3 + ${qrr[2]}x^2 + ${qrr[3]}x + ${qrr[4]}\");\n  print(\"\");\n}\n```\n\n---\n\n## Features and bugs\n\nPlease file feature requests and bugs at the [issue tracker][tracker].\n\n[tracker]: https://github.com/AKushWarrior/starfruit/issues\n\n---\n\n[![Pub](https://img.shields.io/pub/v/starfruit?color=blue\u0026label=pub\u0026logo=Steel%20Crypt\u0026logoColor=blue\u0026style=for-the-badge\u0026labelColor=black)](https://pub.dev/packages/starfruit)\n[![License](https://img.shields.io/github/license/AKushWarrior/starfruit?color=blue\u0026style=for-the-badge\u0026labelColor=black)](https://opensource.org/licenses/lgpl-3.0.html)\n[![Commits](https://img.shields.io/github/commit-activity/m/AKushWarrior/starfruit?color=blue\u0026style=for-the-badge\u0026labelColor=black)](https://github.com/AKushWarrior/starfruit)\n\n\n###### Starfruit, a set of Dart utility libraries.\n###### ©2020 Aditya Kishore\n###### Licensed under the MPL 2.0 (See LICENSE)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fakushwarrior%2Fstarfruit","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fakushwarrior%2Fstarfruit","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fakushwarrior%2Fstarfruit/lists"}