{"id":16208483,"url":"https://github.com/ehmicky/fast-cartesian","last_synced_at":"2025-04-10T01:09:20.248Z","repository":{"id":40589241,"uuid":"188844132","full_name":"ehmicky/fast-cartesian","owner":"ehmicky","description":"Fast cartesian product","archived":false,"fork":false,"pushed_at":"2025-03-29T02:39:33.000Z","size":10653,"stargazers_count":70,"open_issues_count":0,"forks_count":5,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-04-10T01:09:13.895Z","etag":null,"topics":["algorithm","cartesian","cartesian-product","cartesian-products","combinations","combinatorics","data-structures","es6","functional","functional-programming","iterable","javascript","library","lodash","lodash-fp","nodejs","performance","product","sets","typescript"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ehmicky.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","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":"2019-05-27T13:00:17.000Z","updated_at":"2025-03-29T02:39:37.000Z","dependencies_parsed_at":"2024-06-07T03:40:13.948Z","dependency_job_id":"0e1efc3e-b3a1-4bda-9db5-60101436eaa1","html_url":"https://github.com/ehmicky/fast-cartesian","commit_stats":{"total_commits":835,"total_committers":5,"mean_commits":167.0,"dds":0.02035928143712573,"last_synced_commit":"bf6be38f5964b07d617525dab1be1ab234e2015d"},"previous_names":[],"tags_count":28,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ehmicky%2Ffast-cartesian","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ehmicky%2Ffast-cartesian/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ehmicky%2Ffast-cartesian/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ehmicky%2Ffast-cartesian/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ehmicky","download_url":"https://codeload.github.com/ehmicky/fast-cartesian/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248137886,"owners_count":21053775,"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","cartesian","cartesian-product","cartesian-products","combinations","combinatorics","data-structures","es6","functional","functional-programming","iterable","javascript","library","lodash","lodash-fp","nodejs","performance","product","sets","typescript"],"created_at":"2024-10-10T10:17:13.671Z","updated_at":"2025-04-10T01:09:20.224Z","avatar_url":"https://github.com/ehmicky.png","language":"TypeScript","readme":"[![Node](https://img.shields.io/badge/-Node.js-808080?logo=node.js\u0026colorA=404040\u0026logoColor=66cc33)](https://www.npmjs.com/package/fast-cartesian)\n[![Browsers](https://img.shields.io/badge/-Browsers-808080?logo=firefox\u0026colorA=404040)](https://unpkg.com/fast-cartesian?module)\n[![TypeScript](https://img.shields.io/badge/-Typed-808080?logo=typescript\u0026colorA=404040\u0026logoColor=0096ff)](/src/main.ts)\n[![Codecov](https://img.shields.io/badge/-Tested%20100%25-808080?logo=codecov\u0026colorA=404040)](https://codecov.io/gh/ehmicky/fast-cartesian)\n[![Minified size](https://img.shields.io/bundlephobia/minzip/fast-cartesian?label\u0026colorA=404040\u0026colorB=808080\u0026logo=webpack)](https://bundlephobia.com/package/fast-cartesian)\n[![Mastodon](https://img.shields.io/badge/-Mastodon-808080.svg?logo=mastodon\u0026colorA=404040\u0026logoColor=9590F9)](https://fosstodon.org/@ehmicky)\n[![Medium](https://img.shields.io/badge/-Medium-808080.svg?logo=medium\u0026colorA=404040)](https://medium.com/@ehmicky)\n\nFast cartesian product.\n\nRetrieves every possible combination between several arrays\n([cartesian product](https://en.wikipedia.org/wiki/Cartesian_product)).\n\n[Fastest](#benchmarks) available library in JavaScript.\n\nWhen producing millions of combinations or combining hundreds of arrays,\n[`big-cartesian`](https://github.com/ehmicky/big-cartesian) should be used\ninstead.\n\n# Testimonials\n\n\u003e We are now using this library for ourworldindata.org and have seen an almost\n\u003e 50-fold performance increase from the naive method we used before!\n\u003e\n\u003e @MarcelGerber\n\n# Example\n\n```js\nimport fastCartesian from 'fast-cartesian'\n\nconsole.log(\n  fastCartesian([\n    ['red', 'blue'],\n    ['circle', 'square'],\n  ]),\n)\n// [\n//   [ 'red', 'circle' ],\n//   [ 'red', 'square' ],\n//   [ 'blue', 'circle' ],\n//   [ 'blue', 'square' ]\n// ]\n\n// Return initial indexes\nconsole.log(\n  fastCartesian(\n    [\n      ['red', 'blue'],\n      ['circle', 'square'],\n    ].map(Object.entries),\n  ),\n)\n// [\n//   [ [ '0', 'red' ], [ '0', 'circle' ] ],\n//   [ [ '0', 'red' ], [ '1', 'square' ] ],\n//   [ [ '1', 'blue' ], [ '0', 'circle' ] ],\n//   [ [ '1', 'blue' ], [ '1', 'square' ] ]\n// ]\n```\n\n# Install\n\n```\nnpm install fast-cartesian\n```\n\nThis package works in both Node.js \u003e=18.18.0 and\n[browsers](https://raw.githubusercontent.com/ehmicky/dev-tasks/main/src/browserslist).\n\nThis is an ES module. It must be loaded using\n[an `import` or `import()` statement](https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c),\nnot `require()`. If TypeScript is used, it must be configured to\n[output ES modules](https://www.typescriptlang.org/docs/handbook/esm-node.html),\nnot CommonJS.\n\n# API\n\n## fastCartesian(inputs)\n\n`inputs`: `Array\u003cArray\u003e`\\\n_Return value_: `Array\u003cArray\u003e`\n\nReturns a two-dimensional `Array` where each row is a combination of `inputs`.\n\n# Benchmarks\n\nThe following [benchmarks](benchmark/tasks.js) compare the performance of this\nlibrary against alternatives\n([`big-cartesian`](https://github.com/ehmicky/big-cartesian),\n[`cx-product`](https://github.com/anywhichway/cxproduct),\n[`cartesian-product`](https://github.com/izaakschroeder/cartesian-product),\n[`fast-cartesian-product`](https://github.com/fisker/fast-cartesian-product),\n[`power-cartesian-product`](https://github.com/fisker/power-cartesian-product),\n[`cartesian`](https://github.com/alexindigo/cartesian) and\n[`lodash.product`](https://github.com/SeregPie/lodash.product)).\n\n```\n## fast-cartesian ######################\n1 array                           1.22ms\n2 arrays                          1.82ms\n4 arrays                          3.12ms\n8 arrays                          1.87ms\n16 arrays                         4.82ms\n\n## cxproduct ###########################\n1 array                           1.91ms\n2 arrays                          3.47ms\n4 arrays                          3.62ms\n8 arrays                          2.39ms\n16 arrays                         5.05ms\n\n## cartesian-product ###################\n1 array                           4.61ms\n2 arrays                          2.92ms\n4 arrays                         11.80ms\n8 arrays                         14.78ms\n16 arrays                        21.00ms\n\n## big-cartesian #######################\n1 array                           7.21ms\n2 arrays                          6.68ms\n4 arrays                          8.53ms\n8 arrays                          7.80ms\n16 arrays                        18.30ms\n\n## power-cartesian-product #############\n1 array                           6.84ms\n2 arrays                          8.54ms\n4 arrays                         12.35ms\n8 arrays                         11.78ms\n16 arrays                        18.98ms\n\n## cartesian ###########################\n1 array                           3.44ms\n2 arrays                         11.12ms\n4 arrays                         13.27ms\n8 arrays                         16.11ms\n16 arrays                        22.90ms\n\n## fast-cartesian-product ##############\n1 array                          23.04ms\n2 arrays                         24.11ms\n4 arrays                         30.46ms\n8 arrays                         45.65ms\n16 arrays                        65.12ms\n\n## lodash.product ######################\n1 array                          36.51ms\n2 arrays                         37.89ms\n4 arrays                         41.71ms\n8 arrays                         52.72ms\n16 arrays                        80.84ms\n```\n\n# Support\n\nFor any question, _don't hesitate_ to [submit an issue on GitHub](../../issues).\n\nEveryone is welcome regardless of personal background. We enforce a\n[Code of conduct](CODE_OF_CONDUCT.md) in order to promote a positive and\ninclusive environment.\n\n# Contributing\n\nThis project was made with ❤️. The simplest way to give back is by starring and\nsharing it online.\n\nIf the documentation is unclear or has a typo, please click on the page's `Edit`\nbutton (pencil icon) and suggest a correction.\n\nIf you would like to help us fix a bug or add a new feature, please check our\n[guidelines](CONTRIBUTING.md). Pull requests are welcome!\n\n\u003c!-- Thanks go to our wonderful contributors: --\u003e\n\n\u003c!-- ALL-CONTRIBUTORS-LIST:START --\u003e\n\u003c!-- prettier-ignore-start --\u003e\n\u003c!-- markdownlint-disable --\u003e\n\u003ctable\u003e\n  \u003ctr\u003e\n    \u003ctd align=\"center\"\u003e\u003ca href=\"https://fosstodon.org/@ehmicky\"\u003e\u003cimg src=\"https://avatars2.githubusercontent.com/u/8136211?v=4?s=100\" width=\"100px;\" alt=\"\"/\u003e\u003cbr /\u003e\u003csub\u003e\u003cb\u003eehmicky\u003c/b\u003e\u003c/sub\u003e\u003c/a\u003e\u003cbr /\u003e\u003ca href=\"https://github.com/ehmicky/fast-cartesian/commits?author=ehmicky\" title=\"Code\"\u003e💻\u003c/a\u003e \u003ca href=\"#design-ehmicky\" title=\"Design\"\u003e🎨\u003c/a\u003e \u003ca href=\"#ideas-ehmicky\" title=\"Ideas, Planning, \u0026 Feedback\"\u003e🤔\u003c/a\u003e \u003ca href=\"https://github.com/ehmicky/fast-cartesian/commits?author=ehmicky\" title=\"Documentation\"\u003e📖\u003c/a\u003e\u003c/td\u003e\n    \u003ctd align=\"center\"\u003e\u003ca href=\"https://marcelgerber.de\"\u003e\u003cimg src=\"https://avatars0.githubusercontent.com/u/2641501?v=4?s=100\" width=\"100px;\" alt=\"\"/\u003e\u003cbr /\u003e\u003csub\u003e\u003cb\u003eMarcel Gerber\u003c/b\u003e\u003c/sub\u003e\u003c/a\u003e\u003cbr /\u003e\u003ca href=\"https://github.com/ehmicky/fast-cartesian/commits?author=MarcelGerber\" title=\"Code\"\u003e💻\u003c/a\u003e\u003c/td\u003e\n    \u003ctd align=\"center\"\u003e\u003ca href=\"https://github.com/Paulomart\"\u003e\u003cimg src=\"https://avatars.githubusercontent.com/u/4148404?v=4?s=100\" width=\"100px;\" alt=\"\"/\u003e\u003cbr /\u003e\u003csub\u003e\u003cb\u003ePaul Heidenreich\u003c/b\u003e\u003c/sub\u003e\u003c/a\u003e\u003cbr /\u003e\u003ca href=\"https://github.com/ehmicky/fast-cartesian/commits?author=Paulomart\" title=\"Code\"\u003e💻\u003c/a\u003e\u003c/td\u003e\n  \u003c/tr\u003e\n\u003c/table\u003e\n\n\u003c!-- markdownlint-restore --\u003e\n\u003c!-- prettier-ignore-end --\u003e\n\n\u003c!-- ALL-CONTRIBUTORS-LIST:END --\u003e\n","funding_links":[],"categories":["Modules"],"sub_categories":["Array"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fehmicky%2Ffast-cartesian","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fehmicky%2Ffast-cartesian","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fehmicky%2Ffast-cartesian/lists"}