{"id":21625632,"url":"https://github.com/mhyfritz/bin-data","last_synced_at":"2026-05-16T21:39:44.570Z","repository":{"id":44074163,"uuid":"207478485","full_name":"mhyfritz/bin-data","owner":"mhyfritz","description":"Partition data into given number of chunks and pick a representative value for each chunk.","archived":false,"fork":false,"pushed_at":"2023-01-04T22:00:27.000Z","size":405,"stargazers_count":1,"open_issues_count":14,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-09-15T06:50:08.351Z","etag":null,"topics":["array","binning","bucketing","chunks","compression","iterable","quantization"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","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/mhyfritz.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}},"created_at":"2019-09-10T06:09:37.000Z","updated_at":"2023-05-04T11:48:51.000Z","dependencies_parsed_at":"2023-02-02T21:16:21.382Z","dependency_job_id":null,"html_url":"https://github.com/mhyfritz/bin-data","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"purl":"pkg:github/mhyfritz/bin-data","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mhyfritz%2Fbin-data","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mhyfritz%2Fbin-data/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mhyfritz%2Fbin-data/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mhyfritz%2Fbin-data/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mhyfritz","download_url":"https://codeload.github.com/mhyfritz/bin-data/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mhyfritz%2Fbin-data/sbom","scorecard":{"id":640367,"data":{"date":"2025-08-11","repo":{"name":"github.com/mhyfritz/bin-data","commit":"5da285515a411f16d0d3f249d52eb53d2ec9b33c"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":1.3,"checks":[{"name":"Token-Permissions","score":-1,"reason":"No tokens found","details":null,"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"Pinned-Dependencies","score":-1,"reason":"no dependencies found","details":null,"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"Code-Review","score":0,"reason":"Found 0/23 approved changesets -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"SAST","score":0,"reason":"no SAST tool detected","details":["Warn: no pull requests merged into dev branch"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}},{"name":"Dangerous-Workflow","score":-1,"reason":"no workflows found","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"License","score":0,"reason":"license file not detected","details":["Warn: project does not have a license file"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'master'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"Vulnerabilities","score":0,"reason":"48 existing vulnerabilities detected","details":["Warn: Project is vulnerable to: GHSA-968p-4wvh-cqc8","Warn: Project is vulnerable to: GHSA-67hx-6x53-jw92","Warn: Project is vulnerable to: GHSA-6chw-6frg-f759","Warn: Project is vulnerable to: GHSA-v88g-cgmw-v5xw","Warn: Project is vulnerable to: GHSA-93q8-gq69-wqmw","Warn: Project is vulnerable to: GHSA-v6h2-p8h4-qcjw","Warn: Project is vulnerable to: GHSA-grv7-fg5c-xmjg","Warn: Project is vulnerable to: GHSA-w8qv-6jwh-64r5","Warn: Project is vulnerable to: GHSA-3xgq-45jj-v275","Warn: Project is vulnerable to: GHSA-gxpj-cx7g-858c","Warn: Project is vulnerable to: GHSA-w573-4hg7-7wgq","Warn: Project is vulnerable to: GHSA-fjxv-7rqg-78g4","Warn: Project is vulnerable to: GHSA-8r6j-v8pm-fqw3","Warn: Project is vulnerable to: MAL-2023-462","Warn: Project is vulnerable to: GHSA-765h-qjxv-5f44","Warn: Project is vulnerable to: GHSA-f2jv-r9rf-7988","Warn: Project is vulnerable to: GHSA-43f8-2h32-f4cj","Warn: Project is vulnerable to: GHSA-qqgx-2p2h-9c37","Warn: Project is vulnerable to: GHSA-896r-f27r-55mw","Warn: Project is vulnerable to: GHSA-9c47-m6qq-7p4h","Warn: Project is vulnerable to: GHSA-6c8f-qphg-qjgp","Warn: Project is vulnerable to: GHSA-p6mc-m468-83gw","Warn: Project is vulnerable to: GHSA-29mw-wpgm-hmr9","Warn: Project is vulnerable to: GHSA-35jh-r3h4-6jhm","Warn: Project is vulnerable to: GHSA-952p-6rrq-rcjv","Warn: Project is vulnerable to: GHSA-f8q6-p94x-37v3","Warn: Project is vulnerable to: GHSA-vh95-rmgr-6w4m","Warn: Project is vulnerable to: GHSA-xvch-5gv4-984h","Warn: Project is vulnerable to: GHSA-5fw9-fq32-wv5p","Warn: Project is vulnerable to: GHSA-hj48-42vr-x3v9","Warn: Project is vulnerable to: GHSA-hrpp-h998-j3pp","Warn: Project is vulnerable to: GHSA-p8p7-x288-28g6","Warn: Project is vulnerable to: GHSA-gcx4-mw62-g8wm","Warn: Project is vulnerable to: GHSA-c2qf-rxjj-qqgw","Warn: Project is vulnerable to: GHSA-hxcc-f52p-wc94","Warn: Project is vulnerable to: GHSA-3jfq-g458-7qm9","Warn: Project is vulnerable to: GHSA-r628-mhmh-qjhw","Warn: Project is vulnerable to: GHSA-9r2w-394v-53qc","Warn: Project is vulnerable to: GHSA-5955-9wpr-37jh","Warn: Project is vulnerable to: GHSA-qq89-hq3f-393p","Warn: Project is vulnerable to: GHSA-f5x3-32g6-xq36","Warn: Project is vulnerable to: GHSA-4wf5-vphf-c2xc","Warn: Project is vulnerable to: GHSA-jgrx-mgxx-jf9v","Warn: Project is vulnerable to: GHSA-72xf-g2v4-qvf3","Warn: Project is vulnerable to: GHSA-6fc8-4gx4-v693","Warn: Project is vulnerable to: GHSA-3h5v-q93c-6h6q","Warn: Project is vulnerable to: GHSA-c4w7-xm78-47vh","Warn: Project is vulnerable to: GHSA-p9pc-299p-vxgp"],"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}}]},"last_synced_at":"2025-08-21T10:31:50.970Z","repository_id":44074163,"created_at":"2025-08-21T10:31:50.970Z","updated_at":"2025-08-21T10:31:50.970Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33119989,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-16T18:38:32.183Z","status":"ssl_error","status_checked_at":"2026-05-16T18:38:29.903Z","response_time":115,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":["array","binning","bucketing","chunks","compression","iterable","quantization"],"created_at":"2024-11-25T01:09:58.238Z","updated_at":"2026-05-16T21:39:44.548Z","avatar_url":"https://github.com/mhyfritz.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Data binning\n\n\u003e Partition data into given number of chunks and pick a representative value for each chunk.\n\n## Installation\n\n```bash\nnpm install @mhyfritz/bin-data\n```\n\n## Usage\n\n[Try `bin-data` in your browser.](https://npm.runkit.com/@mhyfritz/bin-data)\n\nNode / module bundlers:\n\n```javascript\nconst binData = require(\"@mhyfritz/bin-data\");\n\n// or\n\nimport * as binData from \"@mhyfritz/bin-data\";\n```\n\nBrowser:\n\n```html\n\u003c!-- import from unpkg --\u003e\n\u003cscript src=\"https://unpkg.com/@mhyfritz/bin-data\"\u003e\u003c/script\u003e\n\n\u003c!-- import from jsdelivr --\u003e\n\u003cscript src=\"https://cdn.jsdelivr.net/npm/@mhyfritz/bin-data\"\u003e\u003c/script\u003e\n\n\u003c!-- usage; module is globally registered as `mhyfritzBinData` --\u003e\n\u003cscript\u003e\n  const { bin } = mhyfritzBinData;\n  bin([1, 2, 3, 4, 5], 2);\n\u003c/script\u003e\n```\n\nAPI:\n\n```javascript\nconst { bin, chunk, pick } = require(\"@mhyfritz/bin-data\");\n\n// data = [-10, -9, ..., -1, 0, 1, ..., 9, 10]\nconst data = Array.from({ length: 21 }, (_, i) =\u003e i - 10);\n\n// we can get the raw chunks if we want\nchunk(data, 4);\n// ==\u003e\n// [\n//   { start: 0, end: 4, data: [ -10, -9, -8, -7, -6 ] },\n//   { start: 5, end: 10, data: [ -5, -4, -3, -2, -1, 0 ] },\n//   { start: 11, end: 15, data: [ 1, 2, 3, 4, 5 ] },\n//   { start: 16, end: 20, data: [ 6, 7, 8, 9, 10 ] }\n// ]\n\n// bin the data; by default, the max. value is picked\nbin(data, 4);\n// ==\u003e [ -6, 0, 5, 10 ]\n\nbin(data, 4, pick.min);\n// ==\u003e [ -10, -5, 1, 6 ]\n\nbin(data, 4, pick.mean);\n// ==\u003e [ -8, -2.5, 3, 8 ]\n\nbin(data, 4, chunk =\u003e pick.quantile(chunk, 0.75));\n// ==\u003e [ -7, -1.25, 4, 9 ]\n\n// for complex, non-numeric data, specify an accessor function\n// objects = [{x: -10}, ..., {x: 0}, ..., {x: 10}]\nconst objects = data.map(value =\u003e ({ x: value }));\nbin(objects, 4, chunk =\u003e pick.max(chunk, d =\u003e d.x));\n// [ -6, 0, 5, 10 ]\n\n// for getting back the actual objects, one can use `pick.greatest()`\nbin(objects, 4, chunk =\u003e pick.greatest(chunk, d =\u003e d.x));\n// [ { x: -6 }, { x: 0 }, { x: 5 }, { x: 10 } ]\n\n// one can of course also provide a custom function\n// example: pick  maximum of the absolute values\nfunction absMax(chunk) {\n  let ret = chunk[0];\n  for (const x of chunk) {\n    if (Math.abs(x) \u003e Math.abs(ret)) {\n      ret = x;\n    }\n  }\n  return ret;\n}\n\nbin(data, 4, absMax);\n// ==\u003e [ -10, -5, 5, 10 ]\n```\n\n### `bin(data, numChunks, pickRepresentative)`\n\n- `data`: an array or other iterable\n- `numChunks`: the number of chunks to generate\n- `pickRepresentative [chunk =\u003e value]`: function to pick representative value of chunk; default: `pick.max` (see below)\n\nExample\n\n```javascript\nbin([1, 2, 3, 4, 5], 2);\n// ==\u003e [ 3, 5 ]\n```\n\n### `pick`\n\nObject holding pre-defined functions to pick chunk representative,\ne.g. `pick.min` to pick minimum value of chunk.\nSee [`d3-array`](https://github.com/d3/d3-array/blob/09b8ff21742b365a7090e728120640fb45464637/README.md)\nfor all options.\n\nExample\n\n```javascript\npick.mean([1, 2, 3]);\n// ==\u003e 2\npick.mean([4, 5]);\n// ==\u003e 4.5\nbin([1, 2, 3, 4, 5], 2, pick.mean);\n// ==\u003e [ 2, 4.5 ]\n```\n\n### `chunk(data, numChunks)`\n\nPartition `data` into `numChunks` chunks. Returns an array holding values of chunks plus start\nand end indices in `data`.\n\nExample\n\n```javascript\nchunk([1, 2, 3, 4, 5], 2);\n// ==\u003e\n// [\n//   { start: 0, end: 2, data: [ 1, 2, 3 ] },\n//   { start: 3, end: 4, data: [ 4, 5 ] }\n// ]\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmhyfritz%2Fbin-data","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmhyfritz%2Fbin-data","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmhyfritz%2Fbin-data/lists"}