faker icon indicating copy to clipboard operation
faker copied to clipboard

Always use max param as exclusive value

Open Shinigami92 opened this issue 3 years ago • 2 comments

Clear and concise description of the problem

All functions in JS uses a min or start value inclusive and an max or end value exclusive Faker doesn't respect this and uses max or end as inclusive A JS developer would not expect this behavior and would need to read the docs

Suggested solution

Use max as exclusive value

Alternative

No response

Additional context

Example: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/substring

Shinigami92 avatar Jan 29 '22 14:01 Shinigami92

I looked a bit into the code, and somehow applying this change feels wrong :thinking: I'm not so sure anymore if we want this

Some example usages like generating a color between 0 and 255 it feels more practical to just use int({ min: 0, max: 255 })

Shinigami92 avatar Aug 27 '22 11:08 Shinigami92

I looked a bit into the code, and somehow applying this change feels wrong 🤔 I'm not so sure anymore if we want this

Some example usages like generating a color between 0 and 255 it feels more practical to just use int({ min: 0, max: 255 })

It does feel more practical to me too, but it goes against JS conventions with what you said about the exclusive end value, so I'm not too sure, we should discuss this at the next meeting.

import-brain avatar Aug 27 '22 17:08 import-brain

Team decision

  • We don't see the necessity to change this atm.
  • We will reconsider it, if there is greater user interest.

ST-DDT avatar Oct 13 '22 15:10 ST-DDT