Team Ai
Apppublic

LiquidAI/LFM2-WebGPU

sourceHugging Faceapache-2.0updated 3mo agoView on Hugging Face
94likes
random_number.js52 linesDownload Raw Back to tools
1/**2 * Generate a random integer between min and max (inclusive).3 * @param {number} min - Minimum value (inclusive).4 * @param {number} max - Maximum value (inclusive).5 * @returns {number} A random integer.6 */7export function random_number(min, max) {8  min = Math.ceil(Number(min));9  max = Math.floor(Number(max));10  if (isNaN(min) || isNaN(max) || min > max) {11    throw new Error("Invalid min or max value.");12  }13  return Math.floor(Math.random() * (max - min + 1)) + min;14}15 16export default (input, output) =>17  React.createElement(18    "div",19    { className: "bg-indigo-50 border border-indigo-200 rounded-lg p-4" },20    React.createElement(21      "div",22      { className: "flex items-center mb-2" },23      React.createElement(24        "div",25        {26          className:27            "w-8 h-8 bg-indigo-100 rounded-full flex items-center justify-center mr-3",28        },29        "🎲",30      ),31      React.createElement(32        "h3",33        { className: "text-indigo-900 font-semibold" },34        "Random Number",35      ),36    ),37    React.createElement(38      "div",39      { className: "text-center" },40      React.createElement(41        "div",42        { className: "text-3xl font-bold text-indigo-600 mb-1" },43        output,44      ),45      React.createElement(46        "p",47        { className: "text-indigo-500 text-xs" },48        `Range: ${input.min || "?"} - ${input.max || "?"}`,49      ),50    ),51  );52