@jsonjoy.com/json-random
Version:
Random JSON generation, structured JSON by schema generation, no dependencies.
19 lines • 638 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.int64 = exports.int = void 0;
const int = (min, max) => {
let int = Math.round(Math.random() * (max - min) + min);
int = Math.max(min, Math.min(max, int));
return int;
};
exports.int = int;
const int64 = (min, max) => {
const range = max - min;
const randomFloat = Math.random();
const randomBigInt = BigInt(Math.floor(Number(range) * randomFloat));
let result = min + randomBigInt;
result = result < min ? min : result > max ? max : result;
return result;
};
exports.int64 = int64;
//# sourceMappingURL=number.js.map