chancejs / chancejs

Chance - Random generator helper for JavaScript
http://chancejs.com
MIT License
6.46k stars 452 forks source link

[Suggestion] Separate the main library into region specific components #346

Open mihail-petrov opened 7 years ago

mihail-petrov commented 7 years ago

Hi. I would like to make a suggestion regarding the general structure of the project. The current state of the library provide a full set of random generators that sutes the general neads of the consumers.

But next there are country specific generators that are related to application specific context. For example phone numbers of Brazilian citizens etc.

I would like to suggest for us as a community to separate the region specific generator data into a separate components ( in a general programming term not in JS specific term).

Furthermore the citizens of some specific countries have additional information that does not have direct equivalent in another. We could create a separate packages for every single country that contains specific data or functions for fetching specific data.

So the user of the library will have something line a chancejs-core and chancejs-us or chancejs-uk for example. This will create a way for the users to plug a new data providers on the fly related to the specific scenario that there are testing or developing.

The major benefit for the core library is going to be related to its size.

If you like the idea I am wiling to prepare some code and to discuss some ideas.

Thank you

victorquinn commented 7 years ago

Hey @mihail-petrov yes, this is something I've been meaning to tackle for awhile. There are multiple open issues related to this:

It's something I've started once or twice but never totally finished. Problem being that the dependency graph/tree isn't entirely clear so it necessitates a ton of work to pull apart. At its most core is the random number generator (based on the Mersenne Twister) and some of the building blocks like the numbers, characters, words, etc. but there is a lot of mixing between them.

But yes particularly the internationalization aspect has led to a ton of bloat and mess that I'd like to clean up.

And that was also part of the rationale behind moving Chance to an org from my own personal account -- so that it could be split up into nice tidy logic pieces like that.

Would love to hear ideas if you have 'em!