{"id":19932714,"url":"https://github.com/mixmaxhq/detonate-object","last_synced_at":"2025-08-02T13:06:46.321Z","repository":{"id":27358938,"uuid":"113622477","full_name":"mixmaxhq/detonate-object","owner":"mixmaxhq","description":"Generate object copies combinatorially","archived":false,"fork":false,"pushed_at":"2023-11-20T18:47:32.000Z","size":96,"stargazers_count":2,"open_issues_count":2,"forks_count":1,"subscribers_count":26,"default_branch":"master","last_synced_at":"2025-07-26T11:54:48.010Z","etag":null,"topics":["supported"],"latest_commit_sha":null,"homepage":"https://www.mixmax.com/careers","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/mixmaxhq.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2017-12-08T22:20:27.000Z","updated_at":"2023-07-18T09:08:18.000Z","dependencies_parsed_at":"2023-11-20T20:01:52.329Z","dependency_job_id":null,"html_url":"https://github.com/mixmaxhq/detonate-object","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/mixmaxhq/detonate-object","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mixmaxhq%2Fdetonate-object","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mixmaxhq%2Fdetonate-object/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mixmaxhq%2Fdetonate-object/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mixmaxhq%2Fdetonate-object/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mixmaxhq","download_url":"https://codeload.github.com/mixmaxhq/detonate-object/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mixmaxhq%2Fdetonate-object/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":268393880,"owners_count":24243315,"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-08-02T02:00:12.353Z","response_time":74,"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":["supported"],"created_at":"2024-11-12T23:11:20.318Z","updated_at":"2025-08-02T13:06:46.277Z","avatar_url":"https://github.com/mixmaxhq.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"detonate-object\n===============\n\n[![Build Status](https://travis-ci.org/mixmaxhq/detonate-object.svg?branch=master)](https://travis-ci.org/mixmaxhq/detonate-object)\n\nGenerates objects from an object with `$each` declarations in a combinatorial manner.\n\nHas nothing to do with destroying objects.\n\nNot particularly fast, but aims to be correct and unsurprising. Comparable to a\n[naïve implementation][naive] with an incrementing variation offset.\n\nRelies on language features available in Node from v6 on.\n\nInstall\n-------\n\n```sh\n$ yarn add detonate-object\n# or\n$ npm install --save detonate-object\n```\n\nUsage\n-----\n\n```js\nconst detonate = require('detonate-object');\n\n// We return an iterator from detonate. If you want an array, pass it to `Array.from`.\nconst iter = detonate({\n  $each: [{\n    browserName: 'safari',\n    platform: 'macOS',\n    version: {$each: [10, 11]}\n  }, {\n    browserName: {$each: ['firefox', 'chrome']},\n    version: {$each: ['latest', 'latest-1']}\n  }],\n  platform: {$each: ['linux', 'macOS', 'windows']},\n  build: 14\n});\n\nfor (const obj of iter) {\n  // loops over the following objects, in no particular order:\n  { platform: 'linux',   browserName: 'chrome',  version: 'latest',   build: 14}\n  { platform: 'linux',   browserName: 'chrome',  version: 'latest-1', build: 14}\n  { platform: 'linux',   browserName: 'firefox', version: 'latest',   build: 14}\n  { platform: 'linux',   browserName: 'firefox', version: 'latest-1', build: 14}\n  { platform: 'macOS',   browserName: 'chrome',  version: 'latest',   build: 14}\n  { platform: 'macOS',   browserName: 'chrome',  version: 'latest-1', build: 14}\n  { platform: 'macOS',   browserName: 'firefox', version: 'latest',   build: 14}\n  { platform: 'macOS',   browserName: 'firefox', version: 'latest-1', build: 14}\n  { platform: 'macOS',   browserName: 'safari',  version: 10,         build: 14}\n  { platform: 'macOS',   browserName: 'safari',  version: 11,         build: 14}\n  { platform: 'windows', browserName: 'chrome',  version: 'latest',   build: 14}\n  { platform: 'windows', browserName: 'chrome',  version: 'latest-1', build: 14}\n  { platform: 'windows', browserName: 'firefox', version: 'latest',   build: 14}\n  { platform: 'windows', browserName: 'firefox', version: 'latest-1', build: 14}\n}\n```\n\n### Merge conflicts\n\ndetonate-object does guarantees that fields will be taken first from a top-level `$each` declaration, and then from the body.\n\n```js\ndetonate({\n  {$each: [{name: 'abc'}]},\n  name: 'def'\n});\n// From the above, detonate-object will only produce this:\n// {name: 'abc'}\n// It will not produce this:\n// {name: 'def'}\n```\n\n### Custom iterables\n\nWe can also use custom iterables:\n\n```js\nfunction* generator() {\n  yield 'hello';\n  yield 'world';\n}\n\nconst iterable = {\n  [Symbol.iterator]() {\n    return generator();\n  }\n};\n\nArray.from(detonate({\n  msg: {$each: iterable},\n  extra: 'data'\n}));\n// =\u003e [\n//   {msg: 'hello', extra: 'data'},\n//   {msg: 'world', extra: 'data'}\n// ]\n```\n\n[naive]: https://github.com/mixmaxhq/detonate-object/blob/master/benchmarks/naive.js\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmixmaxhq%2Fdetonate-object","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmixmaxhq%2Fdetonate-object","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmixmaxhq%2Fdetonate-object/lists"}