{"id":31425033,"url":"https://github.com/es-shims/array.prototype.grouptomap","last_synced_at":"2025-09-30T04:54:58.329Z","repository":{"id":57184211,"uuid":"438381590","full_name":"es-shims/Array.prototype.groupToMap","owner":"es-shims","description":"An ESnext spec-compliant `Array.prototype.groupToMap` shim/polyfill/replacement that works as far down as ES3.","archived":false,"fork":false,"pushed_at":"2024-02-10T21:43:38.000Z","size":60,"stargazers_count":9,"open_issues_count":1,"forks_count":1,"subscribers_count":4,"default_branch":"main","last_synced_at":"2025-09-29T06:43:07.434Z","etag":null,"topics":["array","ecmascript","group","groupby","groupbytomap","grouping","javascript","polyfill","shim"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/es-shims.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":".github/FUNDING.yml","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},"funding":{"github":["ljharb"],"patreon":null,"open_collective":null,"ko_fi":null,"tidelift":"npm/array.prototype.groupToMap","community_bridge":null,"liberapay":null,"issuehunt":null,"otechie":null,"custom":null}},"created_at":"2021-12-14T19:52:10.000Z","updated_at":"2023-07-30T19:44:38.000Z","dependencies_parsed_at":"2024-02-06T22:33:46.251Z","dependency_job_id":null,"html_url":"https://github.com/es-shims/Array.prototype.groupToMap","commit_stats":{"total_commits":20,"total_committers":1,"mean_commits":20.0,"dds":0.0,"last_synced_commit":"8841a6f9dabcaf3f5c10679defeea7628d536486"},"previous_names":["es-shims/array.prototype.groupbytomap"],"tags_count":4,"template":false,"template_full_name":null,"purl":"pkg:github/es-shims/Array.prototype.groupToMap","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/es-shims%2FArray.prototype.groupToMap","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/es-shims%2FArray.prototype.groupToMap/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/es-shims%2FArray.prototype.groupToMap/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/es-shims%2FArray.prototype.groupToMap/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/es-shims","download_url":"https://codeload.github.com/es-shims/Array.prototype.groupToMap/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/es-shims%2FArray.prototype.groupToMap/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":277632369,"owners_count":25850734,"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","status":"online","status_checked_at":"2025-09-30T02:00:09.208Z","response_time":75,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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","ecmascript","group","groupby","groupbytomap","grouping","javascript","polyfill","shim"],"created_at":"2025-09-30T04:54:56.519Z","updated_at":"2025-09-30T04:54:58.323Z","avatar_url":"https://github.com/es-shims.png","language":"JavaScript","funding_links":["https://github.com/sponsors/ljharb","https://tidelift.com/funding/github/npm/array.prototype.groupToMap"],"categories":[],"sub_categories":[],"readme":"# array.prototype.groupToMap \u003csup\u003e[![Version Badge][npm-version-svg]][package-url]\u003c/sup\u003e\n\n[![dependency status][deps-svg]][deps-url]\n[![dev dependency status][dev-deps-svg]][dev-deps-url]\n[![License][license-image]][license-url]\n[![Downloads][downloads-image]][downloads-url]\n\n[![npm badge][npm-badge-png]][package-url]\n\nAn ESnext spec-compliant `Array.prototype.groupToMap` shim/polyfill/replacement that works as far down as ES3.\n\nThis package implements the [es-shim API](https://github.com/es-shims/api) interface. It works in an ES3-supported environment and complies with the proposed [spec](https://tc39.github.io/proposal-array-grouping/).\n\nBecause `Array.prototype.groupToMap` depends on a receiver (the `this` value), the main export takes the array to operate on as the first argument.\n\n## Getting started\n\n```sh\nnpm install --save array.prototype.grouptomap\n```\n\n## Usage/Examples\n\n```js\nvar groupToMap = require('array.prototype.grouptomap');\nvar assert = require('assert');\n\nvar arr = [0, 1, 2, 3, 4, 5];\nvar parity = function (x) { return x % 2 === 0 ? 'even' : 'odd'; };\n\nvar results = groupToMap(arr, function (x, i, a) {\n    assert.equal(x, arr[i]);\n    assert.equal(a, arr);\n    return parity(x);\n});\n\nassert.deepEqual(results, new Map([\n    ['even', [0, 2, 4]],\n    ['odd', [1, 3, 5]],\n]));\n```\n\n```js\nvar groupToMap = require('array.prototype.grouptomap');\nvar assert = require('assert');\n/* when Array#groupToMap is not present */\ndelete Array.prototype.groupToMap;\nvar shimmed = groupToMap.shim();\n\nassert.equal(shimmed, groupToMap.getPolyfill());\nassert.deepEqual(arr.groupToMap(parity), groupToMap(arr, parity));\n```\n\n```js\nvar groupToMap = require('array.prototype.grouptomap');\nvar assert = require('assert');\n/* when Array#groupToMap is present */\nvar shimmed = groupToMap.shim();\n\nassert.equal(shimmed, Array.prototype.groupToMap);\nassert.deepEqual(arr.groupToMap(parity), groupToMap(arr, parity));\n```\n\n## Tests\nSimply clone the repo, `npm install`, and run `npm test`\n\n[package-url]: https://npmjs.org/package/array.prototype.grouptomap\n[npm-version-svg]: https://versionbadg.es/es-shims/Array.prototype.groupToMap.svg\n[deps-svg]: https://david-dm.org/es-shims/Array.prototype.groupToMap.svg\n[deps-url]: https://david-dm.org/es-shims/Array.prototype.groupToMap\n[dev-deps-svg]: https://david-dm.org/es-shims/Array.prototype.groupToMap/dev-status.svg\n[dev-deps-url]: https://david-dm.org/es-shims/Array.prototype.groupToMap#info=devDependencies\n[npm-badge-png]: https://nodei.co/npm/array.prototype.grouptomap.png?downloads=true\u0026stars=true\n[license-image]: https://img.shields.io/npm/l/array.prototype.grouptomap.svg\n[license-url]: LICENSE\n[downloads-image]: https://img.shields.io/npm/dm/array.prototype.grouptomap.svg\n[downloads-url]: https://npm-stat.com/charts.html?package=array.prototype.grouptomap\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fes-shims%2Farray.prototype.grouptomap","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fes-shims%2Farray.prototype.grouptomap","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fes-shims%2Farray.prototype.grouptomap/lists"}