{"id":18417939,"url":"https://github.com/danieljdufour/fast-max","last_synced_at":"2025-04-07T12:32:54.275Z","repository":{"id":57233029,"uuid":"297070433","full_name":"DanielJDufour/fast-max","owner":"DanielJDufour","description":":fire: Quickest Way to get the Maximum Value of an Array of Numbers (Typed or Untyped)","archived":false,"fork":false,"pushed_at":"2024-01-14T17:56:36.000Z","size":71,"stargazers_count":2,"open_issues_count":1,"forks_count":0,"subscribers_count":3,"default_branch":"main","last_synced_at":"2024-05-01T23:50:25.585Z","etag":null,"topics":["algorithm","math","maximum","numbers"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"cc0-1.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/DanielJDufour.png","metadata":{"files":{"readme":"README.md","changelog":null,"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":"2020-09-20T12:23:31.000Z","updated_at":"2024-06-20T18:57:24.096Z","dependencies_parsed_at":"2024-01-14T19:07:08.679Z","dependency_job_id":"3b013dfe-421a-405c-bdd6-a73c365ba077","html_url":"https://github.com/DanielJDufour/fast-max","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DanielJDufour%2Ffast-max","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DanielJDufour%2Ffast-max/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DanielJDufour%2Ffast-max/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DanielJDufour%2Ffast-max/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/DanielJDufour","download_url":"https://codeload.github.com/DanielJDufour/fast-max/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247653400,"owners_count":20973824,"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":["algorithm","math","maximum","numbers"],"created_at":"2024-11-06T04:12:20.067Z","updated_at":"2025-04-07T12:32:53.426Z","avatar_url":"https://github.com/DanielJDufour.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# fast-max\n:fire: The Quickest Way to get the Maximum Value of an Array of Numbers (Typed or Untyped)\n\n# install\n```\nnpm install fast-max\n```\n\n# why is it so much faster?\nThis library excels with typed arrays.  It takes into account the theoretical maximum of a typed array.\nFor example, if you have a  Uint8Array, it's not possible for a maximum value to be greater than 255,\nso if we encounter a 255 in the array, we can stop searching for a higher value.\n\n# usage\n# getting maximum value of a normal array\n```javascript\nconst fastMax = require(\"fast-max\"); // or import max from \"fast-max\";\n\nconst result = fastMax([0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]);\n// result is 10\n```\n\n# getting maximum value of a typed array\n```javascript\nconst fastMax = require(\"fast-max\");\n\nconst pixel_values = Uint8Array.from([0, 128, 255, 34, ...]);\nconst result = fastMax(pixel_values);\n// result is 255\n```\n\n# setting theoretical maximum\nIf you know that an array's values can't exceed a specific number,\nyou can set the theoretical_max.\n```javascript\nconst fastMax = require(\"fast-max\");\n\nconst numbers = [0, 9, 4, 2, 10, ...]);\nconst result = fastMax(numbers, { theoretical_max: 10 });\n// result is 10\n```\n\n# no data value\nIf you want to ignore one or more specific values, you can set the no_data value.\n```javascript\nconst fastMax = require(\"fast-max\");\n\nconst numbers = [99, 0, 7, 99, 5, ...];\nconst result = fastMax(numbers, { no_data: 99 });\n// result is 7\n\nconst result = fastMax(numbers, { no_data: [7, 99] });\n// result is still 5\n```\n\n# performance tests\nHere are test results comparing fast-max to two other popular libraries underscore and lodash.\nTests have been conducted by creating an array of ten million random numbers from zero to the maximum\ntheoretical value of the typed array.\n| array type | library | average duration in milliseconds |\n| ---------- | ------- | -------------------------------- |\n| Int8Array | fast-max | **\u003c 1** | \n| Int8Array | lodash | 20.9 | \n| Int8Array | underscore | 14.3 | \n| Uint8Array | fast-max | **0.1** | \n| Uint8Array | lodash | 21.4 | \n| Uint8Array | underscore | 14.3 | \n| Int16Array | fast-max | **1.4** | \n| Int16Array | lodash | 21 | \n| Int16Array | underscore | 13.7 | \n| Uint16Array | fast-max | **1.9** | \n| Uint16Array | lodash | 20.9 | \n| Uint16Array | underscore | 13.8 | \n| Int32Array | fast-max | **31.2** | \n| Int32Array | lodash | 21.2 | \n| Int32Array | underscore | 14.2 | \n| Uint32Array | fast-max | **109.8** | \n| Uint32Array | lodash | 73.3 | \n| Uint32Array | underscore | 15 | \n| BigInt64Array | fast-max | **115.4** | \n| BigInt64Array | lodash | 237.5 | \n| BigInt64Array | underscore | 222.4 | \n| BigUint64Array | fast-max | **113.9** | \n| BigUint64Array | lodash | 236.4 | \n| BigUint64Array | underscore | 219.7 |\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdanieljdufour%2Ffast-max","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdanieljdufour%2Ffast-max","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdanieljdufour%2Ffast-max/lists"}