{"id":24837221,"url":"https://github.com/letieu/chance-percent","last_synced_at":"2025-03-26T04:14:03.216Z","repository":{"id":57196826,"uuid":"468209515","full_name":"letieu/chance-percent","owner":"letieu","description":null,"archived":false,"fork":false,"pushed_at":"2022-09-03T08:01:50.000Z","size":4266,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-03-01T14:06:52.104Z","etag":null,"topics":["change","percent","random-generation"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/chance-percent","language":"JavaScript","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/letieu.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2022-03-10T05:42:18.000Z","updated_at":"2022-03-14T01:40:38.000Z","dependencies_parsed_at":"2022-09-16T12:12:42.652Z","dependency_job_id":null,"html_url":"https://github.com/letieu/chance-percent","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/letieu%2Fchance-percent","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/letieu%2Fchance-percent/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/letieu%2Fchance-percent/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/letieu%2Fchance-percent/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/letieu","download_url":"https://codeload.github.com/letieu/chance-percent/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245585813,"owners_count":20639671,"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":["change","percent","random-generation"],"created_at":"2025-01-31T05:53:35.766Z","updated_at":"2025-03-26T04:14:03.197Z","avatar_url":"https://github.com/letieu.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Get random item base on percentage\n\n\n## Simple usage\n```javascript\nimport { random } from 'chance-percent';\n\nconst options = [\n  {value: 1, percentage: 10},\n  {value: 3, percentage: 60},\n  {value: 2, percentage: 30},\n]\n\nconst value = random(options); // return 1, 2, 3\n\n```\n\n## Typescript usage\n\n```typescript\nimport { random, ChanceOption } from 'chance-percent';\n\ninterface User {\n    age: number;\n    name: string;\n}\n\nconst users = [{ age: 20, name: 'bob' }, { age: 40, name: 'jonh' }]\n\nconst options: ChanceOption\u003cUser\u003e[] = [\n  {value: users[1], percentage: 40},\n  {value: users[2], percentage: 60},\n]\n\nconst winner: User = random\u003cUser\u003e(options);\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fletieu%2Fchance-percent","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fletieu%2Fchance-percent","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fletieu%2Fchance-percent/lists"}