{"id":27958907,"url":"https://github.com/janmalch/collections-commons","last_synced_at":"2026-04-27T20:31:42.255Z","repository":{"id":59443647,"uuid":"440809339","full_name":"JanMalch/collections-commons","owner":"JanMalch","description":"Extensions, data structures, and utilities built on top of them, for your every-day needs.","archived":false,"fork":false,"pushed_at":"2024-03-16T09:30:03.000Z","size":3211,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-05-07T18:36:27.349Z","etag":null,"topics":["collections","javascript","library","typescript","utils"],"latest_commit_sha":null,"homepage":"https://janmalch.github.io/collections-commons/","language":"TypeScript","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/JanMalch.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2021-12-22T09:49:46.000Z","updated_at":"2023-06-04T04:07:24.000Z","dependencies_parsed_at":"2024-03-16T10:42:45.518Z","dependency_job_id":"d036936f-afc9-4dba-9deb-9ad72d29cd0e","html_url":"https://github.com/JanMalch/collections-commons","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/JanMalch/collections-commons","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JanMalch%2Fcollections-commons","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JanMalch%2Fcollections-commons/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JanMalch%2Fcollections-commons/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JanMalch%2Fcollections-commons/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/JanMalch","download_url":"https://codeload.github.com/JanMalch/collections-commons/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JanMalch%2Fcollections-commons/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32354566,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-27T20:07:02.737Z","status":"ssl_error","status_checked_at":"2026-04-27T20:07:00.910Z","response_time":128,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: 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":["collections","javascript","library","typescript","utils"],"created_at":"2025-05-07T18:26:52.044Z","updated_at":"2026-04-27T20:31:42.232Z","avatar_url":"https://github.com/JanMalch.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"**⚠ THIS PROJECT IS STILL IN DEVELOPMENT. WHILE IT'S DESIGNED AS A LIBRARY IT IS NOT RELEASED YET AND THERE'S NO GUARANTEE THAT IT WILL BE IN THE FUTURE.\nALSO, IMPLEMENTATION STYLE AND DETAILS MAY STILL CHANGE.**\n\n\n# collections-commons \u003ca href=\"https://www.github.com/JanMalch/collections-commons\"\u003e\u003cimg src=\"https://raw.githubusercontent.com/JanMalch/collections-commons/master/.github/assets/logo.png\" width=\"90\" height=\"90\" align=\"right\" /\u003e\u003c/a\u003e\n\n[![npm](https://img.shields.io/npm/v/collections-commons)][npm-url]\n[![documentation](https://img.shields.io/badge/docs-available-success)][docs-url]\n[![minified + gzip](https://badgen.net/bundlephobia/minzip/collections-commons)][bundlephobia-url]\n[![Build](https://github.com/JanMalch/collections-commons/workflows/Build/badge.svg)][build-url]\n[![codecov](https://codecov.io/gh/JanMalch/collections-commons/branch/master/graph/badge.svg)][codecov-url]\n\n\u003ci\u003eExtensions, data structures, and utilities built on top of them, for your every-day needs.\u003c/i\u003e\n\n## Installation\n\n```\nnpm install collections-commons\n```\n\nSome classes extend `Map`, which requires the browser to support es6 features.\n\n[![Can I use - 96%](https://img.shields.io/badge/Can%20I%20use...-~96%25-brightgreen)](https://caniuse.com/es6)\n\n## What's in this library?\n\nThis library main goal is to provide a toolbox for your every-day needs.\nAs such it provides a lot of different extensions to the data structures you already know and use\nlike Maps and Arrays. Beyond that, there a few custom data structures like `Queue` or `Bag`,\nand also utilities like `lazy` or `lateInit` that built on top of these structures.\n\nIt is strongly recommended to enable strict TypeScript rules, especially null checks.\nFor example [`getOrElse`, `getOrDefault`, and `getOrThrow`](https://janmalch.github.io/collections-commons/modules/extensions_map.html#:~:text=Functions%20-%20Get)\nwill make your life easier by explicitly handling missing keys in Maps, instead of (not) doing `undefined` checks.\n\n### Highlights\n\nThe following categories should give you a sense of what the library has to offer:\n\n- [Map factories](https://janmalch.github.io/collections-commons/modules/extensions_iterable.html#:~:text=Functions%20%2D%20Lookup)\n  like [`associateWith`](https://janmalch.github.io/collections-commons/functions/extensions_iterable.associateWith.html) and\n  [`groupBy`](https://janmalch.github.io/collections-commons/functions/extensions_iterable.groupBy.html)\n- [Get from Map extensions](https://janmalch.github.io/collections-commons/modules/extensions_map.html#:~:text=Functions%20-%20Get) like `getOrDefault`\n- [Lazy behaviours](https://janmalch.github.io/collections-commons/modules/lazy.html)\n- [Common data structures](https://janmalch.github.io/collections-commons/modules/data_structures.html) like Bag, Queue, or `LateInit`\n\n## Usage\n\n```typescript\nimport { getOrThrow, getInBounds } from 'collections-commons';\n\nconst map = new Map\u003cnumber, string\u003e();\nconst value: string = getOrThrow(map, 5); // throws because map has no value for 5\n\nconst array = ['0', '1', '2'];\nconst item: string = getInBounds(array, 5); // throws because index 5 is out of bounds\n``` \n\n### Namespacing\n\nIf you prefer, you can create namespaces by using the `import * as identifier` syntax,\nwhich is still tree-shakable by all modern bundlers.\n\n```typescript\nimport * as Extensions from 'collections-commons/extensions';\n\n// values are arrays, so this is considered a multi-value Map (no need for extra classes)\nconst map = new Map\u003cstring, number[]\u003e([\n  ['a', [0, 1, 2]],\n  ['b', []],\n]);\nExtensions.addAll(map, 'a', [3, 4]); // addAll is an extension for multi-value Maps\nExtensions.setAll(map, [ // setAll works for any Map\n  ['b', [5, 6]],\n  ['c', [7, 8]],\n]);\nexpect(map.get('a')).toEqual([0, 1, 2, 3, 4]);\nexpect(map.get('b')).toEqual([5, 6]);\nexpect(map.get('c')).toEqual([7, 8]);\n```\n\n[docs-url]: https://janmalch.github.io/collections-commons/\n[npm-url]: https://www.npmjs.com/package/collections-commons\n[build-url]: https://github.com/JanMalch/collections-commons/actions?query=workflow%3ABuild\n[codecov-url]: https://codecov.io/gh/JanMalch/collections-commons\n[bundlephobia-url]: https://bundlephobia.com/result?p=collections-commons\n[map-mdn-url]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjanmalch%2Fcollections-commons","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjanmalch%2Fcollections-commons","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjanmalch%2Fcollections-commons/lists"}