datum-focus
Version:
Data shape, model, metadata, JSON, JSON Schema, GraphQL, MongoDB query and aggregations, iterator generators
23 lines (21 loc) • 443 B
text/typescript
import { format } from '../../decimal';
export default function decimal(
{
fixed,
label,
max,
min,
}: {
fixed?: number;
label?: string;
max?: number;
min?: number;
} = {
max: Number.MAX_SAFE_INTEGER,
min: Number.MIN_SAFE_INTEGER,
}
) {
const _min = min || Number.MIN_SAFE_INTEGER;
const _max = max || Number.MAX_SAFE_INTEGER;
return format(_min + (_max - _min) * Math.random(), fixed);
}