MCPcopy Create free account
hub / github.com/cryptii/cryptii / randomizeValue

Method randomizeValue

src/Field/Number.js:291–302  ·  view source on GitHub ↗

* Returns a randomly chosen value or null if not applicable. * @param {Random} random Random number generator * @return {mixed} Randomly chosen value

(random)

Source from the content-addressed store, hash-verified

289 * @return {mixed} Randomly chosen value
290 */
291 randomizeValue (random) {
292 const value = super.randomizeValue(random)
293 if (value !== null) {
294 return value
295 }
296 if (this._min !== null && this._max !== null) {
297 return this._integer
298 ? random.nextInteger(this._min, Math.ceil(this._max) - 1)
299 : random.nextFloat(this._min, this._max)
300 }
301 return null
302 }
303
304 /**
305 * Serializes the field value to a JSON serializable value.

Callers

nothing calls this directly

Calls 2

nextIntegerMethod · 0.80
nextFloatMethod · 0.80

Tested by

no test coverage detected