{"id":17254291,"url":"https://github.com/waynevanson/generator","last_synced_at":"2025-06-10T14:12:04.292Z","repository":{"id":196459544,"uuid":"696150367","full_name":"waynevanson/generator","owner":"waynevanson","description":null,"archived":false,"fork":false,"pushed_at":"2023-11-23T04:34:49.000Z","size":235,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-06-09T22:58:31.964Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/waynevanson.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","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}},"created_at":"2023-09-25T07:32:05.000Z","updated_at":"2023-09-25T07:32:22.000Z","dependencies_parsed_at":"2023-11-23T05:41:07.031Z","dependency_job_id":"86da45ef-4999-4ba3-ade4-234ad99e5b36","html_url":"https://github.com/waynevanson/generator","commit_stats":null,"previous_names":["waynevanson/generator"],"tags_count":26,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/waynevanson%2Fgenerator","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/waynevanson%2Fgenerator/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/waynevanson%2Fgenerator/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/waynevanson%2Fgenerator/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/waynevanson","download_url":"https://codeload.github.com/waynevanson/generator/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/waynevanson%2Fgenerator/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":259090392,"owners_count":22803672,"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":[],"created_at":"2024-10-15T07:08:14.981Z","updated_at":"2025-06-10T14:12:04.275Z","avatar_url":"https://github.com/waynevanson.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# @waynevanson/generator\n\nGenerate data using simple stuctures and beautiful combinators.\n\n## Installation\n\n```sh\nnpm install @waynevanson/generator\nyarn add @waynevanson/generator\npnpm add @waynevanson/generator\n```\n\n## Quickstart\n\n```ts\nimport * as gen from \"@waynevanson/generator\"\n\ninterface Person {\n  name: string\n  age: number\n  friendly: boolean\n  // some people don't have eyes due to accidents and some could be albino\n  eyes?: \"green\" | \"hazel\" | \"brown\" | \"blue\" | \"red\"\n  foods: Array\u003cstring\u003e\n}\n\ninterface Food {\n  name: string\n  category: string\n}\n\nconst name = gen\n  .tuple([\n    gen.constants([\"james\", \"gregory\"]),\n    gen.constants([\"bond\", \"house\"]),\n  ])\n  .map(([first, last]) =\u003e [first, last].join(\" \"))\n\nconst person = gen.intersect([\n  gen.required({\n    name,\n    age: gen.integer({ min: 0, max: 100 }),\n    friendly: gen.boolean,\n    // we can use generators that are not yet defined using the `lazy` combinator\n    foods: gen.array(\n      gen.lazy(() =\u003e food),\n      { min: 1, max: 2 }\n    ),\n  }),\n  gen.partial({\n    eyes: gen.constants([\"green\", \"hazel\", \"brown\", \"blue\", \"red\"]),\n  }),\n])\n\n// defined after `person.foods`\nconst food = gen.constants([\"sultanas\", \"apricot\", \"wheat\"])\n\nconst people = gen.array(person, { min: 5, max: 5 })\n\n// 0 \u003c= seed \u003c (2**32)\nconst data = people.run(0)\n\nconsole.log(JSON.stringify(data, null, 2))\n```\n\nThe above prints the following:\n\n```json\n[\n  {\n    \"name\": \"james house\",\n    \"age\": 67,\n    \"friendly\": true,\n    \"foods\": [\"apricot\", \"apricot\"],\n    \"eyes\": \"blue\"\n  },\n  {\n    \"name\": \"gregory house\",\n    \"age\": 89,\n    \"friendly\": false,\n    \"foods\": [\"sultanas\", \"apricot\"],\n    \"eyes\": \"brown\"\n  },\n  {\n    \"name\": \"gregory bond\",\n    \"age\": 25,\n    \"friendly\": true,\n    \"foods\": [\"apricot\"]\n  },\n  {\n    \"name\": \"james bond\",\n    \"age\": 2,\n    \"friendly\": true,\n    \"foods\": [\"apricot\"],\n    \"eyes\": \"green\"\n  },\n  {\n    \"name\": \"gregory house\",\n    \"age\": 23,\n    \"friendly\": true,\n    \"foods\": [\"sultanas\", \"sultanas\"]\n  }\n]\n```\n\n## Docs\n\nPlease visit the code for more information.\nThe code has docs and the code examples are the tests.\n\n## Upcoming\n\n- Distribution options for all applicable generators (about half are done)\n- Use new distrubtion pattern for integer values\n- 100% test coverage and carefully considered tests\n- Generated documents from code\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwaynevanson%2Fgenerator","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwaynevanson%2Fgenerator","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwaynevanson%2Fgenerator/lists"}