@prefecthq/prefect-ui-library
Version:
This library is the Vue and Typescript component library for [Prefect 2](https://github.com/PrefectHQ/prefect) and [Prefect Cloud 2](https://www.prefect.io/cloud/). _The components and utilities in this project are not meant to be used independently_.
27 lines (19 loc) • 559 B
text/typescript
import { choice, range } from '@/utilities/arrays'
export const { random, floor, ceil } = Math
const uniform = (min: number, max: number): number => floor(random() * (max - min + 1) + min)
const coinflip = (weight: number): boolean => uniform(0, 1) < weight
const weightedNumber = (): number => {
const seed = uniform(1, 3)
if (seed == 1) {
return choice(range(10, 100))
}
return choice(range(101, 1000))
}
export function countDigits(value: number): number {
return `${value}`.length
}
export {
uniform,
coinflip,
weightedNumber
}