Comments (6)
@soanvig Well, generally speaking, this is kind of a misuse, but I do agree that this shouldn't result in a stack overflow.
I have some code lying around that should prevent this in TS level by preventing you from passing this kind of configuration, I can add it.
But we still need to support cases where this isn't consumed as part of a TS project so if you want to open a PR for it go ahead ๐
from falso.
@shaharkazaz this is definitely not misuse. Min/max range is inclusive. Therefore min: X, max: X
should produce X, because Xโ<X;X>
from falso.
@soanvig can you share your use case where you use a random range function where the minimum and maximum are the same and not just use the value itself?
From the use cases I've encountered with Falso I never needed anything like that that's why I'm asking :)
from falso.
I don't see the reason to give the use case, because that's clearly a bug if there is inconsistency in how Falso works.
I use falso
in production code actually. I'm writing a library that generates random data, including numbers.
- One case is that I receive min/max range from the libary's user input
- Second case is that I simply do some calculations before using
falso
, and for whatever reason these calculations finish with the result min=max, which is perfectly valid.
I have nothing against falso
not working for min=max
, but it simply doesn't make sense, and is misleading, because min and max are inclusive ranges (telling from the results produced by Falso). Even if different error is thrown it's still incosistency, and honestly I don't see any reason to not support min=max
.
from falso.
I don't see the reason to give the use case, because that's clearly a bug
It's okay to have a conversation over things, I find the tone of your comment a bit aggressive even though there is no real reason for it. you could have just dropped the intro and written whatever you wrote anyway, I was just interested in your use case. You and I both want to make this OS better.
You are welcome to open a PR to support use cases where the min & max inputs are equal and return this value, make sure you make the change across all functions (if we have any more cases like this)
from falso.
@shaharkazaz don't worry, I'm never aggressive. After all I answered the question. It's just I feel that the if there is a bug (I think we all agree incosistency is a bug), there is a bug, and talking about use cases dilutes the conversation and diverges from the main topic. Probably if you answered "yeah, that's OK if you open PR", and then asked about use cases out of curiosity, then I wouldn't add that line. That's all :)
I plan to send PR in 2 weeks then.
from falso.
Related Issues (20)
- core/getRandomInRange accepts Min option greater than Max option
- randUuid returns the same id multiple times with the length parameter HOT 2
- Add uniqueness to certain random values HOT 7
- JSON files for Food and Sports not deployed HOT 1
- spec with randNumber failed randomly HOT 2
- randAvatar is not so random? HOT 1
- UUID and random dates doesnยดt respect the seed HOT 4
- Make falso instantiable HOT 1
- Falso attempts to import the built-in Node.js `crypto` module in the browser HOT 1
- `randFloat({ min: 0, max: 0 })` causes stack overflow HOT 2
- Can you add a CHANGELOG.md/releases? HOT 1
- 7.0.0: Incorrect `main` value in `package.json` HOT 2
- Non-uniform distribution of `randNumber` generation HOT 2
- Invalid 'main' field in '/Users/<projectDir>/node_modules/@ngneat/falso/i18n/de/package.json' of './index.cjs.js'.
- (love) Just to tell you how great your software is HOT 2
- Why can toCollection return a non-array? HOT 2
- Locale support, any ideas when that might be released? HOT 1
- randPhoneNumber will generate invalid US phone numbers HOT 1
- Schedule of the new features (PRs and locale basic structure)? HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. ๐๐๐
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google โค๏ธ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from falso.