{"id":20642400,"url":"https://github.com/ipld/js-ipld-garbage","last_synced_at":"2026-05-07T06:04:35.986Z","repository":{"id":37935725,"uuid":"322264935","full_name":"ipld/js-ipld-garbage","owner":"ipld","description":"Generate garbage objects conformant with the IPLD Data Model","archived":false,"fork":false,"pushed_at":"2025-06-04T10:34:51.000Z","size":377,"stargazers_count":2,"open_issues_count":0,"forks_count":1,"subscribers_count":17,"default_branch":"master","last_synced_at":"2025-08-08T18:09:41.011Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ipld.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","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":"2020-12-17T10:50:40.000Z","updated_at":"2025-06-04T10:34:51.000Z","dependencies_parsed_at":"2023-09-24T18:10:44.252Z","dependency_job_id":"6badbefd-3be4-4626-aca3-b7e264d5b5e6","html_url":"https://github.com/ipld/js-ipld-garbage","commit_stats":{"total_commits":100,"total_committers":6,"mean_commits":"16.666666666666668","dds":0.6599999999999999,"last_synced_commit":"387ad612450cccd2094998d6ea1248a993fce8b1"},"previous_names":["rvagg/js-ipld-garbage"],"tags_count":34,"template":false,"template_full_name":null,"purl":"pkg:github/ipld/js-ipld-garbage","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ipld%2Fjs-ipld-garbage","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ipld%2Fjs-ipld-garbage/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ipld%2Fjs-ipld-garbage/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ipld%2Fjs-ipld-garbage/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ipld","download_url":"https://codeload.github.com/ipld/js-ipld-garbage/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ipld%2Fjs-ipld-garbage/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":270610499,"owners_count":24615809,"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-15T02:00:12.559Z","response_time":110,"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":[],"created_at":"2024-11-16T16:08:58.049Z","updated_at":"2026-05-07T06:04:30.950Z","avatar_url":"https://github.com/ipld.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# @ipld/garbage \u003c!-- omit in toc --\u003e\n\n[![codecov](https://img.shields.io/codecov/c/github/ipld/js-ipld-garbage.svg?style=flat-square)](https://codecov.io/gh/ipld/js-ipld-garbage)\n[![CI](https://img.shields.io/github/workflow/status/ipld/js-ipld-garbage/test%20\u0026%20maybe%20release/master?style=flat-square)](https://github.com/ipld/js-ipld-garbage/actions/workflows/js-test-and-release.yml)\n\n\u003e Garbage data generator for the IPLD Data Model\n\n## Table of contents \u003c!-- omit in toc --\u003e\n\n- [Install](#install)\n- [API](#api)\n  - [`options`](#options)\n- [License](#license)\n- [Contribute](#contribute)\n\n## Install\n\n```console\n$ npm i @ipld/garbage\n```\n\nBased on [substack's \"garbage\"](https://github.com/substack/node-garbage).\n\n## API\n\n`garbage(count = 200, options)`\n\nWhere `count` determines the approximate target number of bytes a garbage object should consume. And `options` allows for a `weight` object that allows you to provide a number for each object type to weight the random garbage generator. By default, all object types are weighted equally (with a value of `1`), providing a number (\u003e= `0`), you can adjust the liklihood that particular types will appear relative to the weights of the other types. A weighting of `0` will turn off that type entirely.\n\n### `options`\n\n- `options.weights` an object with properties matching the IPLD data model types (see below) with numbers (\u003e= `0`) that will weight randomness selection. Default: `{ list: 1, map: 1, string: 1, bytes: 1, boolean: 1, integer: 1, float: 1, null: 1, CID: 1 }`.\n- `options.initialWeights` an object, similar to `options.weights`, that only applies to the initial object. Subsequent object creation will use `options.weights`. This allows for weighting of the container object to be more typical of IPLD data, which is typically some kind of map or list. Default `{ list: 10, map: 10, string: 1, bytes: 1, boolean: 1, integer: 1, float: 1, null: 1, CID: 1 }`.\n\nWhere you provide a custom `weights`, it will override `initialWeights`. e.g. `{ weights: { float: 0 } }` will result in no floats at all, even for the initial object.\n\n```js\nimport { garbage } from '@ipld/garbage'\n\nconsole.log(garbage(100, { weights: { float: 0, object: 0 }}))\n```\n\nMight yield:\n\n```js\n{\n  'QbN/}`EO\\tb6\u003e\\tI,`': 7827882605575541,\n  \"~'wD!☺S}\u003cQ|d1$☺\": Uint8Array(12) [\n    116,  12, 191, 180, 214,\n      0,  88,  26, 116, 213,\n     88, 109\n  ],\n  'q\u003c': CID(baguqefrapdjrz7rknhnokqxo75ogs2hfpmdqiy7weez55ezaoyh63sd22n4q)\n}\n```\n\nAll IPLD Data Model types are within range for random creation, including top-level returns (a single call to `garbage()` might just return a `null`):\n\n- null\n- boolean\n- integer\n- float\n- string\n- bytes\n- list\n- map\n- CID\n\nUse `import { toString } from '@ipld/garbage/to-string'` to import a function that can turn an object returned by `garbage()` to a JavaScript string. This may be useful for generating a fixed set of test fixtures rather than relying on randomness during each run.\n\n## License\n\nLicensed under either of\n\n- Apache 2.0, ([LICENSE-APACHE](LICENSE-APACHE) / \u003chttp://www.apache.org/licenses/LICENSE-2.0\u003e)\n- MIT ([LICENSE-MIT](LICENSE-MIT) / \u003chttp://opensource.org/licenses/MIT\u003e)\n\n## Contribute\n\nUnless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fipld%2Fjs-ipld-garbage","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fipld%2Fjs-ipld-garbage","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fipld%2Fjs-ipld-garbage/lists"}