Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/richie-south/chances
https://github.com/richie-south/chances
Last synced: about 5 hours ago
JSON representation
- Host: GitHub
- URL: https://github.com/richie-south/chances
- Owner: richie-south
- License: mit
- Created: 2022-07-14T12:02:35.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2022-07-18T16:45:30.000Z (over 2 years ago)
- Last Synced: 2023-02-26T20:03:36.813Z (over 1 year ago)
- Language: TypeScript
- Size: 64.5 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# chances
Helper function to build percentage chance options. e.g. You want something to happen 10% of times and another thing 60% of the times.
Got to think of this while riding my bike and later wrote down almost line by line in my tent. Lots of improvements can be made but its a good start.
````typescript
import {chance} from 'not on npm :P..'const event = chance([10, '10% event'], [40, '40% event'])
console.log(event) // '10% event' or '40% event' or undefined if no event should match
```