{"id":19332457,"url":"https://github.com/yuchi/combinatorial-explosion","last_synced_at":"2025-10-07T17:03:12.754Z","repository":{"id":28066563,"uuid":"31563512","full_name":"yuchi/combinatorial-explosion","owner":"yuchi","description":"Combinatorial explosion for arrays and trees","archived":false,"fork":false,"pushed_at":"2015-03-03T08:33:04.000Z","size":152,"stargazers_count":4,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-19T03:12:53.596Z","etag":null,"topics":["combinatorial","tree"],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"lgpl-2.1","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/yuchi.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}},"created_at":"2015-03-02T21:13:44.000Z","updated_at":"2022-02-19T14:43:18.000Z","dependencies_parsed_at":"2022-07-17T21:46:10.906Z","dependency_job_id":null,"html_url":"https://github.com/yuchi/combinatorial-explosion","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yuchi%2Fcombinatorial-explosion","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yuchi%2Fcombinatorial-explosion/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yuchi%2Fcombinatorial-explosion/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yuchi%2Fcombinatorial-explosion/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/yuchi","download_url":"https://codeload.github.com/yuchi/combinatorial-explosion/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250340626,"owners_count":21414600,"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":["combinatorial","tree"],"created_at":"2024-11-10T02:45:55.489Z","updated_at":"2025-10-07T17:03:12.745Z","avatar_url":"https://github.com/yuchi.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"combinatorial-explosion\n=======================\n\n\u003e Boom.\n\n[![Build Status](https://img.shields.io/travis/yuchi/combinatorial-explosion.svg?style=flat-square)](https://travis-ci.org/yuchi/combinatorial-explosion)\n[![Dev Dependencies](https://david-dm.org/yuchi/combinatorial-explosion/dev-status.svg?style=flat-square)](https://david-dm.org/yuchi/combinatorial-explosion#info=devDependencies)\n[![Available on NPM](https://img.shields.io/npm/v/combinatorial-explosion.svg?style=flat-square)](https://www.npmjs.org/package/combinatorial-explosion)\n\nInstall it with:\n\n```prompt\nnpm install --save combinatorial-explosion\n```\n\nUsage\n-----\n\nImport it in your favourite way:\n\n```js\n// be it ES2015\nimport { explode, explodeTree } from 'combinatorial-explosion';\n// or CommonJS\nvar combExpl = require('combinatorial-explosion');\nvar explode = combExpl.explode;\nvar explodeTree = combExpl.explodeTree;\n```\n\nthen you can use it to blow up lists:\n\n```js\nconsole.dir(explode([\n  [ 'a1', 'a2' ],\n  [ 'b' ],\n  [ 'c1', 'c2' ]\n]));\n\n// outputs:\n\n[ [ 'a1', 'b', 'c1' ],\n  [ 'a1', 'b', 'c2' ],\n  [ 'a2', 'b', 'c1' ],\n  [ 'a2', 'b', 'c2' ] ]\n```\n\nand trees (procedurally):\n\n```js\nconst tree = {\n  id: 'a',\n  children: [\n    { id: 'b', children: [] },\n    { id: 'c', children: [] }\n  ]\n};\n\n// Get a list of possible nodes out of a single one\n// fork :: Node =\u003e [ Node ]\nfunction fork(node) {\n  if (node.id === 'c') {\n    // as an example 'c' will be split in two\n    return [ { ...node, id: 'c1' }, { ...node, id: 'c2' } ];\n  }\n  else {\n    // everything else will return a single path\n    return [ node ];\n  }\n}\n\n// Extract the children\n// extract :: Node =\u003e [ Node ]\nfunction extract(node) {\n  return node.children;\n}\n\n// Create a **new** node for the given base node and children\n// compose :: (NodeAttrs, [ Node ]) =\u003e Node\nfunction compose(node, children) {\n  return { ...node, children };\n}\n\nconsole.dir(explodeTree(tree, { fork, extract, compose }));\n\n// outputs:\n\n// a list…\n[\n  // of trees…\n  {\n    id: 'a',\n    children: [\n      { id: 'b', children: [] },\n      // with every ‘fork’ you made, here’s `c1`\n      { id: 'c1', children: [] }\n    ]\n  },\n  {\n    id: 'a',\n    children: [\n      { id: 'b', children: [] },\n      // and here’s `c2`!\n      { id: 'c2', children: [] }\n    ]\n  }\n]\n```\n\n\nLicense\n-------\n\nThis library, *combinatorial-explosion*, is free software (\"Licensed Software\"); you can\nredistribute it and/or modify it under the terms of the [GNU Lesser General\nPublic License](http://www.gnu.org/licenses/lgpl-2.1.html) as published by the\nFree Software Foundation; either version 2.1 of the License, or (at your\noption) any later version.\n\nThis library is distributed in the hope that it will be useful, but WITHOUT ANY\nWARRANTY; including but not limited to, the implied warranty of MERCHANTABILITY,\nNONINFRINGEMENT, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General\nPublic License for more details.\n\nYou should have received a copy of the [GNU Lesser General Public\nLicense](http://www.gnu.org/licenses/lgpl-2.1.html) along with this library; if\nnot, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth\nFloor, Boston, MA 02110-1301 USA\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyuchi%2Fcombinatorial-explosion","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fyuchi%2Fcombinatorial-explosion","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyuchi%2Fcombinatorial-explosion/lists"}