faker-js / faker

Generate massive amounts of fake data in the browser and node.js
https://fakerjs.dev
Other
12.68k stars 912 forks source link

Add support for generating Roman Numerals #2649

Open matthewmayer opened 8 months ago

matthewmayer commented 8 months ago

Clear and concise description of the problem

It would be useful to be able to generate roman numerals, e.g. for sections of a fake document, or as a fake pattern to be used in another pattern like "Super Bowl XXVII".

Suggested solution

faker.number.romanNumeral({min:1, max: 100}) //XVII

min would default to 1 (you can't write 0 in roman numerals). max would probably be limited to 4999 as roman numerals are not as well-defined above 5000. Maybe lowercase/uppercase options?

Not localizable. Since roman numerals are always written in latin script.

Alternative

write custom conversion code eg.

convertToRomanNumerals(faker.number.int({min:1, max:4999}))

where convertToRomanNumerals is a suitable implementation from https://stackoverflow.com/questions/9083037/convert-a-number-into-a-roman-numeral-in-javascript

Additional context

No response

github-actions[bot] commented 8 months ago

Thank you for your feature proposal.

We marked it as "waiting for user interest" for now to gather some feedback from our community:

WikiRik commented 8 months ago

Would indeed be interesting at times to have this. I personally see no need for numerals above 4999 or lowercases ones. Min/max is indeed good to have.

AmaanRS commented 2 months ago

Should i implement this feature ?

matthewmayer commented 2 months ago

Should i implement this feature ?

We normally wait until a feature has 10 GitHub upvotes. It's nearly there 😀

ST-DDT commented 2 months ago

@AmaanRS Do you need roman numerals by string length (range) or by value range?

AmaanRS commented 2 months ago

Yes, I need it by value range (eg: from 1 to 100)

ST-DDT commented 2 months ago

@AmaanRS Could you please describe your usecase? What will you use the output of the method for?

AmaanRS commented 2 months ago

I have to number the recipe in cookbook by roman numbers, and for that function i am writing tests, which needs random roman numbers

AmaanRS commented 2 months ago

So..., should i create it ?

matthewmayer commented 2 months ago

So..., should i create it ?

Since there are now 10 upvotes, I think you could go ahead and start working on it to aid with discussion. Be sure to read the Contributing guide for advice.

Be aware it will likely take some time to review and merge as the maintainers are busy getting v9 ready for release.

AmaanRS commented 2 months ago

So should i create a function named convertToRomanNumerals or a function on the property number named romanNumeral

ST-DDT commented 2 months ago

Please create a function in the number module, so that you can call it like this:

faker.number.romanNumerals()
matthewmayer commented 2 months ago

Maybe singular romanNumeral rather than plural romanNumerals

AmaanRS commented 2 months ago

@ST-DDT I have written the function (draft) #3070