coffee-gen
Version:
One more cup of coffee for the road
20 lines (16 loc) • 655 B
text/typescript
import { GenerateValueFunction } from "../domain/generateValueFunction";
import * as uuid from "uuid";
export class FunctionGenerators {
public static getRandomIntFunction(min: number = 1, max: number = 10): GenerateValueFunction {
const low = Math.floor(min);
const high = Math.floor(max);
return () => low + Math.floor(Math.random() * (high - low));
}
public static getRandomIntStringFunction(min: number = 1, max: number = 10): GenerateValueFunction {
const f = this.getRandomIntFunction(min, max);
return () => f().toString();
}
public static getRandomUUID(): GenerateValueFunction {
return () => uuid.v4();
}
}