faker
faker copied to clipboard
feat: add binary and octal random number generation
Clear and concise description of the problem
faker.random.[...] already generates random number, bigInt, float, hexadecimal, etc. But it lacks octal and binary numbers. This can be added.
Suggested solution
This is an easy task. Either use the faker.datatype.hexadecimal() method as a reference or generate a random number using faker.datatype.number() and convert it into binary or octal.
A simple way to convert decimal to binary is:
console.log(Number((128).toString(2))) // 10000000
Similarly decimal to octal conversion is:
console.log(Number((128).toString(8))) // 200
(this is just one method to do so)
Alternative
No response
Additional context
No response
Can I work on this?
Also, I believe the title should be edited to read "add binary and octal random number generation"
Needs to wait on the string module: #1341
(length: number) -> string
I saw that the open PR was closed, is @mbokinala going to work on this feature? Can I work on it?
Either way please wait for the StringModule before you start with the implementation.
Any updates regarding the state of this issue? if the StringModule update is live then this would be a useful addition. If possible, I would like to champion the issue as well
We are currently updating and reviewing the string module PR. It will probably take a few more days before this can be started. https://github.com/faker-js/faker/pull/1155
@Minozzzi asked first. Are you still interested in this or can @SamRett take your spot?
If @Minozzzi would still like to champion it, that's perfectly okay as well :). Wanted to throw my name in the metaphorical hat, so let me know what you guys think! He bid first so I don't want to unduly take away the right.
Hi @SamRett I've been very busy the last few days. So, you can have fun with this task ;)
Thank you! Please let me know when the StringModule update is ready. Once it is out, I can begin development/testing!
Until then, thank you both!
@xDivisionByZerox can you provide info about how the progress of #1155 is going? If you do not have the time currently, also let us know and someone else can take it over
@xDivisionByZerox can you provide info about how the progress of #1155 is going? If you do not have the time currently, also let us know and someone else can take it over
Feel free to take #1155 if you have time on your hand.
Feel free to take #1155 if you have time on your hand.
Yeah, thx for letting me know Will take it over immediately
@SamRett you can start
Faker Team, and @Shinigami92 (tagging so this gets seen)
So, a quick explanation. I have had difficulties testing as well as other issues regarding simply time so I devoted as much time and work as I could, however, I am not personally satisfied with the final result of my work. This is due to the fact that I have been unable to test my code, thus leaving a large question mark regarding its implementation and working status. Regardless, I tried my best to stick to the conventions that you guys have laid out so it could potentially be used in the final implementation.
Due to this, I have decided to simply link my forked version of Faker so that whoever is assigned the issue after me can see what I wrote, and simply take that to reduce their own workload. Normally I would make a Pull Request, however, in light of my own dissatisfaction with the work I do not wish to make more work on your end.
Working with you all was an amazing experience and I really enjoyed learning about Faker! This is truly an amazing project, and I wish you all the best, especially with version 8 looming over the horizon. It will be really cool to see how Faker evolves from here.
Thanks for letting us know. And thanks for the time you put into it.
Hi, can I be assigned to this issue? I already did it locally and would like to create the PR
Sure, go ahead.
Unless I am missing something, I think this can be closed now. It was great contributing here, thanks !
Fixed via #1710 and #1708