andrewMacmurray/elm-concurrent-task/2.0.0

ConcurrentTask.Random

Generate random values based on an elm/random Generator.

This Task uses a builtin randomSeed task from the JavaScript runner (the same seed elm/random uses - Date.now()).

If needed you can override the randomSeed task like so (e.g. use node or web crypto module to generate secure randomness):

import * as ConcurrentTask from "@andrewmacmurray/elm-concurrent-task"
import crypto from "node:crypto"


ConcurrentTask.register({
  tasks: {},
  ports: app.ports,
  builtins: {
    randomSeed: customRandomSeed,
  },
});


function customRandomSeed(): number {
  return crypto.getRandomValues(new Uint32Array(1))[0];
}
generate : Generator a -> ConcurrentTask x a

Generate a random value based on an elm/random Generator.