faker
faker copied to clipboard
Add books module
Clear and concise description of the problem
Add a faker.books module which allows for generating random titles, genres and publishers for books.
Suggested solution
We could add a faker.books module similar to the one provided by faker-ruby. The module could export the following methods:
title: returns a random book titlepublisher: returns a random publishergenre: returns a random genreauthor: returns a random author
Alternative
I am not sure if author would be necessary since we already have faker.person.fullName.
Additional context
If the feature is accepted, I would like to work on it.
Thank you for your feature proposal.
We marked it as "waiting for user interest" for now to gather some feedback from our community:
- If you would like to see this feature be implemented, please react to the description with an up-vote (:+1:).
- If you have a suggestion or want to point out some special cases that need to be considered, please leave a comment, so we are aware about them.
We would also like to hear about other community members' use cases for the feature to give us a better understanding of their potential implicit or explicit requirements.
We will start the implementation based on:
- the number of votes (:+1:) and comments
- the relevance for the ecosystem
- availability of alternatives and workarounds
- and the complexity of the requested feature
We do this because:
- There are plenty of languages/countries out there and we would like to ensure that every method can cover all or almost all of them.
- Every feature we add to faker has "costs" associated to it:
- initial costs: design, implementation, reviews, documentation
- running costs: awareness of the feature itself, more complex module structure, increased bundle size, more work during refactors
What about ISBN which is currently located in the CommerceModule.
https://github.com/faker-js/faker/blob/24415ee993a9c6e3c8f0dffa544f492dcb29463c/src/modules/commerce/index.ts#L335-L353
Would that get relocated here as well?
What is the status of this request? I could use something like this now
What is the status of this request? I could use something like this now
This is currently waiting for user intrest so unfortunately this wont make it into the code in the next few months. Please upvote the issue to make it easier for us to measure the community's intrest in it.
Could you please also detail which properties you need for the books?
It's waiting for 10 upvotes
Where faker doesn't provide the exact data you need you can generally get a good result by just using faker.helpers.arrayElement with an array of static data. Faker-Ruby has a book module so you could grab the data from there https://github.com/faker-ruby/faker/blob/main/lib/locales/en/book.yml
Team Decision
This issue has gathered enough user interest to be considered for inclusion. Currently, v9.0 is already big enough so we would like to delay this until v9.1+.
@inkedtree are you still interested in working on this? I would like to work on this as well :)
Hi @cieslarmichal, We appreciate your willingness to contribute to this issue. Please keep in mind that we are currently doing major restructures in our codebase. This may result in numerous merge conflicts with any work you undertake. Consequently, we've scheduled this issue for v9.x (subsequent to 9.0). If you remain interested despite these considerations, I would be more than happy to assign this issue to you.
Ok thanks, I will wait then, I would appreciate if you ping me when I can start working on this :)
While the implementation cannot start right now, you could already make suggestions on how you want each method to behave and which methods to have exactly.
Like will book.title return a random elememt from a fixed list such as Harry Potter or will it use patterns like The {{word.noun}} of the {{animal.type}} or The adventures of {{person.firstName}} {{person.lastName}}
I am actually developing book application so I know which methods could be useful, I would add methods as follows (open for more suggestions):
- title (fixed list)
- isbn (fixed list or generating valid isbns)
- author (fixed list)
- genre (fixed list)
- publisher (fixed list)
- translator (alias for person fullName)
- format (paperback, hardcover or ebook)
- pages (integer in range 50 - 1500)
- releaseYear (integer in range 1940 - 2024)
- series (fixed list like Harry Potter series)
Generally sounds good to me!
Note isbn already appears in the faker.commerce module. We could probably make that a deprecated alias and move the implementation here
Id probably remove translator if it's just a random person name, doesn't add much (and if translator, why not illustrator, reviewer, etc)
Also not sure releaseYear is needed, too similar to faker.date.past() - which already has the ability to have a full release date, and to have the years be relative to current date.
Any methods we choose not to add to books for the MVP because there are too similar methods in other modules could still be referenced via see also and the module introduction. Eg if "author()" only has real authors we can cross reference faker.person.fullName() for people who want fake authors.
Sounds good :) can't wait to start working on this!
Is this comming any time soon? :)
I am ready to implement that, but we are waiting for version v9 to be done (major refactor)
@xDivisionByZerox do you have any planned date for v9 release?
@xDivisionByZerox do you have any planned date for v9 release?
Sorry for the late reply. We sadly dont have a fixed release date planed. We will put some more focus on this topic on thursdays, tho. I understand that this might not be what you was hoping for. All I can do is thank you for your patience.
Ok I will wait.
@cieslarmichal In today's meeting we made a new announcement regarding v9 progress. This means that you can technically start with the implementation of the book module if you wish to do so. Please keep in mind that the module itself will not be included in the v9 release, but can be the first thing for v9.1.
Hello, nice! One question: should I create my branch from default branch (next) and then make a pull request to it? Asking that because I can see there is a v9 branch and I am not sure about that situation with release.
I will start working on it this week :smile:
'next' is perfectly fine. The v9 branch is the latest v9 release. In this case v9.0.0-alpha.1.
Ok thanks :)
I am starting to work on it, planning to add following methods to MVP:
- title
- author
- genre
- publisher
- format
- series
I will also add a note that isbn can be generated with commerce module.
created a PR with changes https://github.com/faker-js/faker/pull/2949
Just commenting here to get some more visibility
Should author() return
Shakespeare, William
Or
William Shakespeare
I will probably go with William Shakespeare as it is more readable and natural in my opinion.