MCPcopy
hub / github.com/clientIO/joint / random

Function random

packages/joint-core/src/g/geometry.helpers.mjs:42–57  ·  view source on GitHub ↗
(min, max)

Source from the content-addressed store, hash-verified

40
41// Return a random integer from the interval [min,max], inclusive.
42export const random = function(min, max) {
43
44 if (max === undefined) {
45 // use first argument as max, min is 0
46 max = (min === undefined) ? 1 : min;
47 min = 0;
48
49 } else if (max < min) {
50 // switch max and min
51 const temp = min;
52 min = max;
53 max = temp;
54 }
55
56 return floor((Math.random() * (max - min + 1)) + min);
57};
58

Callers 1

point.mjsFile · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected