Skip to content

2.0.0-alpha.6

Pre-release
Pre-release
Compare
Choose a tag to compare
@okwolf okwolf released this 26 Apr 07:19

What's new?

Random learned some new tricks. It can now handle generating random integers:

Random({
  min: 1,
  max: 6,
  int: true,
  action: (state, roll) => {
    // roll will be an int from 1-6
  }
})

booleans:

Random({
  bool: true,
  action: (state, value) => {
    // value will be true or false
  }
})

and arrays of values:

Random({
  values: [
    {},
    { min: 2, max: 5 },
    { int: true, min: 1, max: 3 },
    { bool: true }
  ],
  action: (state, values) => {
    // values[0] will be a floating point number in the default range of [0, 1)
    // values[1] will be a floating point number in the range [2, 5)
    // values[2] will be one of the following integers: [1, 2, 3]
    // values[3] will be true or false
  }
})