typia
Version:
Superfast runtime validators with only one line
26 lines (25 loc) • 853 B
JavaScript
import { _randomString } from "./_randomString.mjs";
import { _RANDOM_LENGTH_ERROR, _randomLengthPick, _randomLengthWindow } from "./_randomStringLength.mjs";
//#region src/internal/_randomFormatByte.ts
const _randomFormatByte = (props) => {
if (props?.minLength === void 0 && props?.maxLength === void 0) return FIXED;
const window = _randomLengthWindow(props, {
minimum: 0,
spread: 16
});
const low = Math.ceil(window.low / 4) * 4;
if (low > window.high) throw new Error(_RANDOM_LENGTH_ERROR);
const length = low + 4 * _randomLengthPick({
low: 0,
high: Math.floor((window.high - low) / 4)
});
return _randomString({
type: "string",
minLength: length,
maxLength: length
});
};
const FIXED = "vt7ekz4lIoNTTS9sDQYdWKharxIFAR54+z/umIxSgUM=";
//#endregion
export { _randomFormatByte };
//# sourceMappingURL=_randomFormatByte.mjs.map