@hotmeshio/hotmesh
Version:
Serverless Workflow
17 lines (16 loc) • 625 B
JavaScript
Object.defineProperty(exports, "__esModule", { value: true });
exports.random = void 0;
const common_1 = require("./common");
/**
* Returns a deterministic random number between 0 and 1. The number is derived from the
* current execution index, ensuring deterministic replay.
* @returns {number} A deterministic pseudo-random number between 0 and 1.
*/
function random() {
const store = common_1.asyncLocalStorage.getStore();
const COUNTER = store.get('counter');
const seed = COUNTER.counter = COUNTER.counter + 1;
return (0, common_1.deterministicRandom)(seed);
}
exports.random = random;
;