ngneat/falso

`randFloat({ min: 0, max: 0 })` causes stack overflow

srmagura opened this issue · 2 comments

Is this a regression?

No

Description

Calling randFloat with the same value for the min and max results in infinite recursion.

Please provide a link to a minimal reproduction of the bug

https://github.com/srmagura/falso-rand-float-repro

Please provide the exception or error you saw

/Users/srmagura/Documents/oss/bugs/falso-rand-float-repro/node_modules/seedrandom/seedrandom.js:58
  var prng = function() {
                     ^

RangeError: Maximum call stack size exceeded
    at prng (/Users/srmagura/Documents/oss/bugs/falso-rand-float-repro/node_modules/seedrandom/seedrandom.js:58:22)
    at n (/Users/srmagura/Documents/oss/bugs/falso-rand-float-repro/node_modules/@ngneat/falso/index.cjs.js:1:236)
    at l (/Users/srmagura/Documents/oss/bugs/falso-rand-float-repro/node_modules/@ngneat/falso/index.cjs.js:1:553)
    at e (/Users/srmagura/Documents/oss/bugs/falso-rand-float-repro/node_modules/@ngneat/falso/index.cjs.js:1:115474)
    at e (/Users/srmagura/Documents/oss/bugs/falso-rand-float-repro/node_modules/@ngneat/falso/index.cjs.js:1:115553)
    at e (/Users/srmagura/Documents/oss/bugs/falso-rand-float-repro/node_modules/@ngneat/falso/index.cjs.js:1:115553)
    at e (/Users/srmagura/Documents/oss/bugs/falso-rand-float-repro/node_modules/@ngneat/falso/index.cjs.js:1:115553)
    at e (/Users/srmagura/Documents/oss/bugs/falso-rand-float-repro/node_modules/@ngneat/falso/index.cjs.js:1:115553)
    at e (/Users/srmagura/Documents/oss/bugs/falso-rand-float-repro/node_modules/@ngneat/falso/index.cjs.js:1:115553)
    at e (/Users/srmagura/Documents/oss/bugs/falso-rand-float-repro/node_modules/@ngneat/falso/index.cjs.js:1:115553)

Node.js v18.15.0

Please provide the environment you discovered this bug in

macOS 13.3.1, Node 18.15.0

Anything else?

No response

Do you want to create a pull request?

Yes

@srmagura I'm guessing this happens for every equal values right?
You are welcome to open a PR

Yes, it happens whenever the min and max are equal.