diff --git a/docs/.vitepress/api-pages.ts b/docs/.vitepress/api-pages.ts index 7df42281564..3a4144123d5 100644 --- a/docs/.vitepress/api-pages.ts +++ b/docs/.vitepress/api-pages.ts @@ -11,6 +11,7 @@ export const apiPages = [ items: [ { text: 'Airline', link: '/api/airline.html' }, { text: 'Animal', link: '/api/animal.html' }, + { text: 'Book', link: '/api/book.html' }, { text: 'Color', link: '/api/color.html' }, { text: 'Commerce', link: '/api/commerce.html' }, { text: 'Company', link: '/api/company.html' }, diff --git a/scripts/generate-locales.ts b/scripts/generate-locales.ts index 7172ea892f5..e18bdb716fd 100644 --- a/scripts/generate-locales.ts +++ b/scripts/generate-locales.ts @@ -52,6 +52,7 @@ type DefinitionType = { const definitionsTypes: DefinitionType = { airline: 'AirlineDefinition', animal: 'AnimalDefinition', + book: 'BookDefinition', color: 'ColorDefinition', commerce: 'CommerceDefinition', company: 'CompanyDefinition', diff --git a/src/definitions/book.ts b/src/definitions/book.ts new file mode 100644 index 00000000000..c10e530cc71 --- /dev/null +++ b/src/definitions/book.ts @@ -0,0 +1,36 @@ +import type { LocaleEntry } from './definitions'; + +/** + * The possible definitions related to books. + */ +export type BookDefinition = LocaleEntry<{ + /** + * The names of actual book authors. + */ + author: string[]; + + /** + * The formats of a book. + */ + format: string[]; + + /** + * The names of some book genres. + */ + genre: string[]; + + /** + * The names of actual book series. + */ + series: string[]; + + /** + * The names of actual book titles. + */ + title: string[]; + + /** + * The names of actual book publishers. + */ + publisher: string[]; +}>; diff --git a/src/definitions/definitions.ts b/src/definitions/definitions.ts index cf760f0bcf0..d207ec123f3 100644 --- a/src/definitions/definitions.ts +++ b/src/definitions/definitions.ts @@ -1,5 +1,6 @@ import type { AirlineDefinition } from './airline'; import type { AnimalDefinition } from './animal'; +import type { BookDefinition } from './book'; import type { ColorDefinition } from './color'; import type { CommerceDefinition } from './commerce'; import type { CompanyDefinition } from './company'; @@ -34,6 +35,7 @@ export type LocaleDefinition = { metadata?: MetadataDefinition; airline?: AirlineDefinition; animal?: AnimalDefinition; + book?: BookDefinition; color?: ColorDefinition; commerce?: CommerceDefinition; company?: CompanyDefinition; diff --git a/src/definitions/index.ts b/src/definitions/index.ts index 367892b7b47..68ac04011f1 100644 --- a/src/definitions/index.ts +++ b/src/definitions/index.ts @@ -1,5 +1,6 @@ export type { AirlineDefinition } from './airline'; export type { AnimalDefinition } from './animal'; +export type { BookDefinition } from './book'; export type { ColorDefinition } from './color'; export type { CommerceDefinition, diff --git a/src/faker.ts b/src/faker.ts index 5f5e14ce392..d54a6793a12 100644 --- a/src/faker.ts +++ b/src/faker.ts @@ -5,6 +5,7 @@ import type { LocaleProxy } from './locale-proxy'; import { createLocaleProxy } from './locale-proxy'; import { AirlineModule } from './modules/airline'; import { AnimalModule } from './modules/animal'; +import { BookModule } from './modules/book'; import { ColorModule } from './modules/color'; import { CommerceModule } from './modules/commerce'; import { CompanyModule } from './modules/company'; @@ -63,6 +64,7 @@ export class Faker extends SimpleFaker { readonly airline: AirlineModule = new AirlineModule(this); readonly animal: AnimalModule = new AnimalModule(this); + readonly book: BookModule = new BookModule(this); readonly color: ColorModule = new ColorModule(this); readonly commerce: CommerceModule = new CommerceModule(this); readonly company: CompanyModule = new CompanyModule(this); diff --git a/src/index.ts b/src/index.ts index 0b5903408da..bcf5f008b12 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,6 +1,7 @@ export type { AirlineDefinition, AnimalDefinition, + BookDefinition, ColorDefinition, CommerceDefinition, CommerceProductNameDefinition, @@ -40,6 +41,7 @@ export * from './locales'; export { Aircraft } from './modules/airline'; export type { AircraftType, AirlineModule } from './modules/airline'; export type { AnimalModule } from './modules/animal'; +export type { BookModule } from './modules/book'; export { CssFunction, CssSpace } from './modules/color'; export type { Casing, diff --git a/src/locales/en/book/author.ts b/src/locales/en/book/author.ts new file mode 100644 index 00000000000..c2483428260 --- /dev/null +++ b/src/locales/en/book/author.ts @@ -0,0 +1,229 @@ +export default [ + 'A.A. Milne', + 'Agatha Christie', + 'Alan Moore and Dave Gibbons', + 'Albert Camus', + 'Aldous Huxley', + 'Alexander Pope', + 'Alexandre Dumas', + 'Alice Walker', + 'Andrew Lang', + 'Anne Frank', + 'Anthony Burgess', + 'Anthony Trollope', + 'Antoine de Saint-Exupéry', + 'Anton Chekhov', + 'Anton Pavlovich Chekhov', + 'Arthur Conan Doyle', + 'Arthur Schopenhauer', + 'Aylmer Maude', + 'Ayn Rand', + 'Beatrix Potter', + 'Benjamin Disraeli', + 'Benjamin Jowett', + 'Bernard Shaw', + 'Bertrand Russell', + 'Bhagavanlal Indrajit', + 'Boris Pasternak', + 'Bram Stoker', + 'Brian Evenson', + 'C.E. Brock', + 'C.S. Lewis', + 'Carson McCallers', + 'Charles Dickens', + 'Charles E. Derbyshire', + 'Charlotte Brontë', + 'Charlotte Perkins Gilman', + 'Chinua Achebe', + 'Clifford R. Adams', + 'Constance Garnett', + 'Cormac McCarthy', + 'D.H. Lawrence', + 'Dan Brown', + 'Daniel Defoe', + 'Dante Alighieri', + 'Dashiell Hammett', + 'David Widger', + 'David Wyllie', + 'Dean Koontz', + 'Don DeLillo', + 'E.M. Forster', + 'Edgar Allan Poe', + 'Edgar Rice Burroughs', + 'Elizabeth Cleghorn Gaskell', + 'Elizabeth Von Arnim', + 'Emily Brontë', + 'Erich Remarque', + 'Ernest Hemingway', + 'Evelyn Waugh', + 'F. Scott Fitzgerald', + 'Ford Madox Ford', + 'Frances Hodgson Burnett', + 'Frank Herbert', + 'Frank T. Merrill', + 'Franz Kafka', + 'Friedrich Wilhelm Nietzsche', + 'Fyodor Dostoyevsky', + 'G.K. Chesterton', + 'Gabriel Garcia Marquez', + 'Geoffrey Chaucer', + 'George Eliot', + 'George Grossmith', + 'George Orwell', + 'George R. R. Martin', + 'George Saunders', + 'Grady Ward', + 'Graham Greene', + 'Gustave Doré', + 'Gustave Flaubert', + 'Guy de Maupassant', + 'Günter Grass', + 'H.G. Wells', + 'H.P. Lovecraft', + 'Harper Lee', + 'Harriet Beecher Stowe', + 'Haruki Murakami', + 'Henrik Ibsen', + 'Henry David Thoreau', + 'Henry Fielding', + 'Henry James', + 'Henry Miller', + 'Henry Morley', + 'Herman Melville', + 'Hermann Broch', + 'Homer', + 'Honoré de Balzac', + 'Ian McEwan', + 'Isabel Florence Hapgood', + 'Italo Calvino', + 'J.D. Salinger', + 'J.K. Rowling', + 'J.M. Barrie', + 'J.R.R. Tolkien', + 'Jack Kerouac', + 'Jack London', + 'Jacob Grimm', + 'Jacqueline Crooks', + 'James Baldwin', + 'James Dickey', + 'James Ellroy', + 'James Joyce', + 'James Patterson', + 'Jane Austen', + 'Johann Wolfgang von Goethe', + 'John Bunyan', + 'John Camden Hotten', + 'John Dos Passos', + 'John Green', + 'John Grisham', + 'John Kennedy Toole', + 'John Milton', + 'John Ormsby', + 'John Steinbeck', + 'John Updike', + 'Jonathan Franzen', + 'Jonathan Swift', + 'Joseph Conrad', + 'Joseph Heller', + 'José Rizal', + 'Judy Blume', + 'Jules Verne', + 'Junot Diaz', + 'Karl Marx', + 'Kazuo Ishiguro', + 'Ken Follett', + 'Ken Kesey', + 'Kenneth Grahame', + 'Khaled Hosseini', + 'Kingsley Amis', + 'Kurt Vonnegut', + 'L. Frank Baum', + 'L.M. Montgomery', + 'Laurence Sterne', + 'Leo Tolstoy', + 'Lewis Carroll', + 'Louisa May Alcott', + 'Louise Maude', + 'Malcolm Lowry', + 'Marcel Proust', + 'Margaret Atwood', + 'Margaret Mitchell', + 'Marilynne Robinson', + 'Mark Twain', + 'Martin Amis', + 'Mary Shelley', + 'Michael Chabon', + 'Miguel de Cervantes', + 'Mikhail Bulgakov', + 'Muriel Spark', + 'Nancy Mitford', + 'Nathanael West', + 'Nathaniel Hawthorne', + 'Neil Gaiman', + 'Niccolo Machiavelli', + 'Norman Mailer', + 'Oscar Levy', + 'Oscar Wilde', + 'P.G. Wodehouse', + 'Paulo Coelho', + 'Peter Carey', + 'Philip Pullman', + 'Philip Roth', + 'Plato', + 'R.L. Stine', + 'Rachel Kushner', + 'Ralph Ellison', + 'Ray Bradbury', + 'Raymond Chandler', + 'Richard Wagner', + 'Richard Wright', + 'Richard Yates', + 'Roald Dahl', + 'Robert Graves', + 'Robert Louis Stevenson', + 'Robert Penn Warren', + 'Rudyard Kipling', + 'Salman Rushdie', + 'Samuel Beckett', + 'Samuel Butler', + 'Samuel Richardson', + 'Saul Bellow', + 'Shivaram Parashuram Bhide', + 'Sir Arthur Conan Doyle', + 'Sir Richard Francis Burton', + 'Stendhal', + 'Stephen Hawking', + 'Stephen King', + 'Sun Tzu', + 'Suzanne Collins', + 'T. Smollett', + 'T.S. Eliot', + 'Theodore Alois Buckley', + 'Theodore Dreiser', + 'Thomas Hardy', + 'Thomas Love Peacock', + 'Thomas Mann', + 'Toni Morrison', + 'Truman Capote', + 'V.S. Naipaul', + 'Vance Packard', + 'Vatsyayana', + 'Victor Hugo', + 'Virgil', + 'Virginia Woolf', + 'Vladimir Nabokov', + 'Voltaire', + 'W.G. Sebald', + 'W.K. Marriott', + 'Walker Percy', + 'Walt Whitman', + 'Walter Scott', + 'Wilhelm Grimm', + 'Wilkie Collins', + 'William Faulkner', + 'William Gibson', + 'William Golding', + 'William Makepeace Thackeray', + 'William Shakespeare', + 'Zadie Smith', +]; diff --git a/src/locales/en/book/format.ts b/src/locales/en/book/format.ts new file mode 100644 index 00000000000..44dcc1fbc4a --- /dev/null +++ b/src/locales/en/book/format.ts @@ -0,0 +1 @@ +export default ['Audiobook', 'Ebook', 'Hardcover', 'Paperback']; diff --git a/src/locales/en/book/genre.ts b/src/locales/en/book/genre.ts new file mode 100644 index 00000000000..d0f26aee2fb --- /dev/null +++ b/src/locales/en/book/genre.ts @@ -0,0 +1,27 @@ +export default [ + 'Adventure', + 'Biography', + 'Business', + "Children's Literature", + 'Classic', + 'Comedy', + 'Comic', + 'Detective', + 'Drama', + 'Fantasy', + 'Graphic Novel', + 'Historical Fiction', + 'Horror', + 'Memoir', + 'Mystery', + 'Mythology', + 'Philosophy', + 'Poetry', + 'Psychology', + 'Religion', + 'Romance', + 'Science Fiction', + 'Thriller', + 'Western', + 'Young Adult', +]; diff --git a/src/locales/en/book/index.ts b/src/locales/en/book/index.ts new file mode 100644 index 00000000000..43ead3988d5 --- /dev/null +++ b/src/locales/en/book/index.ts @@ -0,0 +1,22 @@ +/* + * This file is automatically generated. + * Run 'pnpm run generate:locales' to update. + */ +import type { BookDefinition } from '../../..'; +import author from './author'; +import format from './format'; +import genre from './genre'; +import publisher from './publisher'; +import series from './series'; +import title from './title'; + +const book: BookDefinition = { + author, + format, + genre, + publisher, + series, + title, +}; + +export default book; diff --git a/src/locales/en/book/publisher.ts b/src/locales/en/book/publisher.ts new file mode 100644 index 00000000000..e80102bb744 --- /dev/null +++ b/src/locales/en/book/publisher.ts @@ -0,0 +1,262 @@ +export default [ + 'Academic Press', + 'Ace Books', + 'Addison-Wesley', + 'Adis International', + 'Airiti Press', + 'Allen Ltd', + 'Andrews McMeel Publishing', + 'Anova Books', + 'Anvil Press Poetry', + 'Applewood Books', + 'Apress', + 'Athabasca University Press', + 'Atheneum Books', + 'Atheneum Publishers', + 'Atlantic Books', + 'Atlas Press', + 'BBC Books', + 'Ballantine Books', + 'Banner of Truth Trust', + 'Bantam Books', + 'Bantam Spectra', + 'Barrie & Jenkins', + 'Basic Books', + 'Belknap Press', + 'Bella Books', + 'Bellevue Literary Press', + 'Berg Publishers', + 'Berkley Books', + 'Bison Books', + 'Black Dog Publishing', + 'Black Library', + 'Black Sparrow Books', + 'Blackie and Son Limited', + 'Blackstaff Press', + 'Blackwell Publishing', + 'Bloodaxe Books', + 'Bloomsbury Publishing Plc', + 'Blue Ribbon Books', + 'Book League of America', + 'Book Works', + 'Booktrope', + 'Borgo Press', + 'Bowes & Bowes', + 'Boydell & Brewer', + 'Breslov Research Institute', + 'Brill', + 'Brimstone Press', + 'Broadview Press', + 'Burns & Oates', + 'Butterworth-Heinemann', + 'Caister Academic Press', + 'Cambridge University Press', + 'Candlewick Press', + 'Canongate Books', + 'Carcanet Press', + 'Carlton Books', + 'Carlton Publishing Group', + 'Carnegie Mellon University Press', + 'Casemate Publishers', + 'Cengage Learning', + 'Central European University Press', + 'Chambers Harrap', + "Charles Scribner's Sons", + 'Chatto and Windus', + 'Chick Publications', + 'Chronicle Books', + 'Churchill Livingstone', + 'Cisco Press', + 'City Lights Publishers', + 'Cloverdale Corporation', + 'D. Appleton & Company', + 'D. Reidel', + 'DAW Books', + 'Da Capo Press', + 'Daedalus Publishing', + 'Dalkey Archive Press', + 'Darakwon Press', + 'David & Charles', + 'Dedalus Books', + 'Del Rey Books', + 'E. P. Dutton', + 'ECW Press', + 'Earthscan', + 'Edupedia Publications', + 'Eel Pie Publishing', + 'Eerdmans Publishing', + "Ellora's Cave", + 'Elsevier', + 'Emerald Group Publishing', + 'Etruscan Press', + 'FabJob', + 'Faber and Faber', + 'Fairview Press', + 'Farrar, Straus & Giroux', + 'Fearless Books', + 'Felony & Mayhem Press', + 'Firebrand Books', + 'Flame Tree Publishing', + 'Focal Press', + 'G-Unit Books', + "G. P. Putnam's Sons", + 'Gaspereau Press', + "Gay Men's Press", + 'Gefen Publishing House', + 'George H. Doran Company', + 'George Newnes', + 'George Routledge & Sons', + 'Godwit Press', + 'Golden Cockerel Press', + 'HMSO', + 'Hachette Book Group USA', + 'Hackett Publishing Company', + 'Hamish Hamilton', + 'Happy House', + 'Harcourt Assessment', + 'Harcourt Trade Publishers', + 'Harlequin Enterprises Ltd', + 'Harper & Brothers', + 'Harper & Row', + 'HarperCollins', + 'HarperPrism', + 'HarperTrophy', + 'Harry N. Abrams, Inc.', + 'Harvard University Press', + 'Harvest House', + 'Harvill Press at Random House', + 'Hawthorne Books', + 'Hay House', + 'Haynes Manuals', + 'Heyday Books', + 'Hodder & Stoughton', + 'Hodder Headline', + 'Hogarth Press', + 'Holland Park Press', + 'Holt McDougal', + 'Horizon Scientific Press', + 'Ian Allan Publishing', + 'Ignatius Press', + 'Imperial War Museum', + 'Indiana University Press', + 'J. M. Dent', + 'Jaico Publishing House', + 'Jarrolds Publishing', + 'John Blake Publishing', + 'Karadi Tales', + 'Kensington Books', + 'Kessinger Publishing', + 'Kodansha', + 'Kogan Page', + 'Koren Publishers Jerusalem', + 'Ladybird Books', + 'Leaf Books', + 'Leafwood Publishers', + 'Left Book Club', + 'Legend Books', + 'Lethe Press', + 'Libertas Academica', + 'Liberty Fund', + 'Library of America', + 'Lion Hudson', + 'Macmillan Publishers', + 'Mainstream Publishing', + 'Manchester University Press', + 'Mandrake Press', + 'Mandrake of Oxford', + 'Manning Publications', + 'Manor House Publishing', + 'Mapin Publishing', + 'Marion Boyars Publishers', + 'Mark Batty Publisher', + 'Marshall Cavendish', + 'Marshall Pickering', + 'Martinus Nijhoff Publishers', + 'Mascot Books', + 'Matthias Media', + 'McClelland and Stewart', + 'McFarland & Company', + 'McGraw Hill Financial', + 'McGraw-Hill Education', + 'Medknow Publications', + 'Naiad Press', + 'Nauka', + 'NavPress', + 'New Directions Publishing', + 'New English Library', + 'New Holland Publishers', + 'New Village Press', + 'Newnes', + 'No Starch Press', + 'Nonesuch Press', + "O'Reilly Media", + 'Oberon Books', + 'Open Court Publishing Company', + 'Open University Press', + 'Orchard Books', + 'Orion Books', + 'Packt Publishing', + 'Palgrave Macmillan', + 'Pan Books', + 'Pantheon Books at Random House', + 'Papadakis Publisher', + 'Parachute Publishing', + 'Parragon', + 'Pathfinder Press', + 'Paulist Press', + 'Pavilion Books', + 'Peace Hill Press', + 'Pecan Grove Press', + 'Pen and Sword Books', + 'Penguin Books', + 'Random House', + 'Reed Elsevier', + 'Reed Publishing', + 'SAGE Publications', + 'Salt Publishing', + 'Sams Publishing', + 'Schocken Books', + 'Scholastic Press', + 'Seagull Books', + 'Secker & Warburg', + 'Shambhala Publications', + 'Shire Books', + 'Shoemaker & Hoard Publishers', + 'Shuter & Shooter Publishers', + 'Sidgwick & Jackson', + 'Signet Books', + 'Simon & Schuster', + "St. Martin's Press", + 'T & T Clark', + 'Tachyon Publications', + 'Tammi', + 'Target Books', + 'Tarpaulin Sky Press', + 'Tartarus Press', + 'Tate Publishing & Enterprises', + 'Taunton Press', + 'Taylor & Francis', + 'Ten Speed Press', + 'UCL Press', + 'Unfinished Monument Press', + 'United States Government Publishing Office', + 'University of Akron Press', + 'University of Alaska Press', + 'University of California Press', + 'University of Chicago Press', + 'University of Michigan Press', + 'University of Minnesota Press', + 'University of Nebraska Press', + 'Velazquez Press', + 'Verso Books', + 'Victor Gollancz Ltd', + 'Viking Press', + 'Vintage Books', + 'Vintage Books at Random House', + 'Virago Press', + 'Virgin Publishing', + 'Voyager Books', + 'Zed Books', + 'Ziff Davis Media', + 'Zondervan', +]; diff --git a/src/locales/en/book/series.ts b/src/locales/en/book/series.ts new file mode 100644 index 00000000000..2326397b1db --- /dev/null +++ b/src/locales/en/book/series.ts @@ -0,0 +1,36 @@ +export default [ + 'A Song of Ice and Fire', + 'Anna Karenina', + 'Colonel Race', + 'Discworld', + 'Dune', + 'Harry Potter', + 'Hercule Poirot', + 'His Dark Materials', + 'Jane Austen Murder Mysteries', + 'Little Women', + 'Outlander', + 'Percy Jackson', + 'Sherlock Holmes', + 'The Arc of a Scythe', + 'The Bartimaeus Trilogy', + 'The Border Trilogy', + 'The Chronicles of Narnia', + 'The Dark Tower', + 'The Dresden Files', + 'The Eighth Life', + 'The Foundation Series', + "The Hitchhiker's Guide to the Galaxy", + 'The Hunger Games', + 'The Infinity Cycle', + 'The Inheritance Cycle', + 'The Lord of the Rings', + 'The Maze Runner', + 'The Prison Healer', + 'The Red Rising Saga', + 'The Southern Reach', + 'The Wheel of Time', + 'Thursday Next Series', + 'Twilight', + 'War and Peace', +]; diff --git a/src/locales/en/book/title.ts b/src/locales/en/book/title.ts new file mode 100644 index 00000000000..e94437d57f6 --- /dev/null +++ b/src/locales/en/book/title.ts @@ -0,0 +1,243 @@ +export default [ + '1984', + '20,000 Leagues Under the Sea', + 'A Bend in the River', + 'A Brief History of Time', + 'A Clockwork Orange', + 'A Confederacy of Dunces', + "A Doll's House", + 'A Handful of Dust', + 'A Modest Proposal', + 'A Passage to India', + 'A Portrait of the Artist as a Young Man', + 'A Room with a View', + 'A Study in Scarlet', + 'A Tale of Two Cities', + 'A Wrinkle in Time', + 'Absalom, Absalom!', + 'Adventures of Huckleberry Finn', + "Alice's Adventures in Wonderland", + 'All Quiet on the Western Front', + "All the King's Men", + 'American Pastoral', + 'An American Tragedy', + 'And Then There Were None', + 'Animal Farm', + 'Anna Karenina', + 'Anne of Green Gables', + "Are You There God? It's Me, Margaret", + 'As I Lay Dying', + 'Atlas Shrugged', + 'Atonement', + 'Austerlitz', + 'Beloved', + 'Beyond Good and Evil', + 'Bible', + 'Bleak House', + 'Blood Meridian', + 'Brave New World', + 'Brideshead Revisited', + 'Candide', + 'Carmilla', + 'Catch-22', + 'Charlie and the Chocolate Factory', + "Charlotte's Web", + 'Clarissa', + 'Cranford', + 'Crime and Punishment', + 'Dao De Jing: A Minimalist Translation', + 'David Copperfield', + 'Deliverance', + 'Don Quixote', + 'Dora', + 'Dr. Zhivago', + 'Dracula', + 'Dubliners', + 'Dune', + 'East of Eden', + 'Emma', + 'Fahrenheit 451', + 'Faust', + 'For Whom the Bell Tolls', + 'Frankenstein', + 'Freakonomics', + 'Go Tell It on the Mountain', + 'Gone with the Wind', + 'Great Expectations', + "Grimms' Fairy Tales", + "Gulliver's Travels", + 'Hamlet', + "Harry Potter and the Sorcerer's Stone", + 'Heart of Darkness', + 'Herzog', + 'His Dark Materials', + 'Hitting the line', + 'Housekeeping', + 'I, Claudius', + "If on a Winter's Night a Traveler", + 'In Cold Blood', + 'In Search of Lost Time', + 'Invisible Man', + 'It', + 'Jane Eyre', + 'Josefine Mutzenbacher', + 'Jude the Obscure', + 'L.A. Confidential', + 'Leaves of Grass', + 'Les Miserables', + 'Life of Pi', + 'Little Women', + 'Lolita', + 'Long Walk to Freedom', + 'Lord Jim', + 'Lord of the Flies', + 'Lucky Jim', + 'Madame Bovary', + 'Malone Dies', + 'Meditations', + 'Men Without Women', + 'Metamorphosis', + 'Middlemarch', + "Midnight's Children", + 'Moby Dick', + 'Money', + 'Mrs. Dalloway', + 'My Bondage and My Freedom', + 'My Life', + 'Native Son', + 'Neuromancer', + 'Never Let Me Go', + 'Nightmare Abbey', + 'Nineteen Eighty Four', + 'Nostromo', + 'Notes from the Underground ', + 'Of Mice and Men', + 'Oliver Twist', + 'On the Duty of Civil Disobedience', + 'On the Road', + "One Flew Over the Cuckoo's Nest", + 'One Hundred Years of Solitude', + 'One Thousand and One Nights', + 'Oscar and Lucinda', + 'Pale Fire', + 'Paradise Lost', + 'Peter Pan', + "Portnoy's Complaint", + 'Pride and Prejudice', + 'Rabbit, Run', + 'Republic', + 'Revolutionary Road', + 'Robinson Crusoe', + 'Romeo and Juliet', + 'Ruth Fielding in Alaska', + 'Scoop', + 'Second Treatise of Government', + 'Slaughterhouse Five', + 'Stories of Anton Chekhov', + 'Sybil', + "Tess of the d'Urbervilles", + 'The Adventures of Augie March', + 'The Adventures of Huckleberry Finn', + 'The Adventures of Sherlock Holmes', + 'The Adventures of Tom Sawyer', + 'The Aeneid', + 'The Alchemist', + 'The Ambassadors', + 'The Art of War', + 'The Big Sleep', + 'The Black Sheep', + 'The Blue Castle', + 'The Brief Wondrous Life of Oscar Wao', + 'The Brothers Karamazov', + 'The Call of the Wild', + 'The Canterbury Tales', + 'The Catcher in the Rye', + 'The Color Purple', + 'The Complete Works of Edgar Allen Poe', + 'The Corrections', + 'The Count of Monte Cristo', + 'The Day of the Locust', + 'The Diary of a Nobody', + 'The Diary of a Young Girl', + 'The Divine Comedy', + 'The Enchanted April', + 'The Fountainhead', + 'The Golden Bowl', + 'The Golden Notebook', + 'The Good Soldier', + 'The Grapes of Wrath', + 'The Great Gatsby', + "The Handmaid's Tale", + 'The Heart is a Lonely Hunter', + 'The Heart of the Matter', + 'The Hobbit', + 'The Hound of the Baskervilles', + 'The Idiot', + 'The Iliad', + 'The King in Yellow', + 'The Kite Runner', + 'The Lion, the Witch, and the Wardrobe', + 'The Little Prince', + 'The Lord of the Rings', + 'The Magic Mountain', + 'The Maltese Falcon', + 'The Master and Margarita', + 'The Moviegoer', + 'The Naked and the Dead', + 'The Odyssey', + 'The Old Man and the Sea', + 'The Pickwick Papers', + 'The Picture of Dorian Gray', + "The Pilgrim's Progress", + 'The Pillars of the Earth', + 'The Plague', + 'The Portrait of a Lady', + 'The Prime of Miss Jean Brodie', + 'The Prince', + 'The Problems of Philosophy', + 'The Prophet', + 'The Pursuit of Love', + 'The Rainbow', + 'The Red and the Black', + 'The Remains of the Day', + 'The Republic', + 'The Scarlet Letter', + 'The Sleepwalkers', + 'The Sound and the Fury', + 'The Stand', + 'The Strange Case of Dr. Jekyll and Mr. Hyde', + 'The Stranger', + 'The Sun Also Rises', + 'The Thirty-Nine Steps', + 'The Three Musketeers', + 'The Time Machine', + 'The Tin Drum', + 'The Trial', + 'The War of the Worlds', + 'The Waste Land', + 'The Way We Live Now', + 'The Wind in the Willows', + 'The Woman in White', + 'The Wonderful Wizard of Oz', + 'The Works of Edgar Allan Poe', + 'The Yellow Wallpaper', + 'Things Fall Apart', + 'Tinker, Tailor, Soldier, Spy', + 'To Kill a Mockingbird', + 'To the Lighthouse', + 'Tom Jones', + 'Treasure Island', + 'Tristram Shandy', + 'Tropic of Cancer', + 'U.S.A. Trilogy', + 'Ulysses', + "Uncle Tom's Cabin", + 'Under the Volcano', + 'Underworld', + 'Vanity Fair', + 'Walden', + 'War and Peace', + 'Watchmen', + 'Winnie-the-Pooh', + 'Wuthering Heights', +]; diff --git a/src/locales/en/index.ts b/src/locales/en/index.ts index e325d91a6d9..7c932075665 100644 --- a/src/locales/en/index.ts +++ b/src/locales/en/index.ts @@ -6,6 +6,7 @@ import type { LocaleDefinition } from '../..'; import airline from './airline'; import animal from './animal'; import app from './app'; +import book from './book'; import cell_phone from './cell_phone'; import color from './color'; import commerce from './commerce'; @@ -31,6 +32,7 @@ const en: LocaleDefinition = { airline, animal, app, + book, cell_phone, color, commerce, diff --git a/src/locales/pl/book/author.ts b/src/locales/pl/book/author.ts new file mode 100644 index 00000000000..78c3a2a66c6 --- /dev/null +++ b/src/locales/pl/book/author.ts @@ -0,0 +1,34 @@ +export default [ + 'Andrzej Maleszka', + 'Andrzej Pilipiuk', + 'Andrzej Sapkowski', + 'Anita Głowińska', + 'Ałbena Grabowska', + 'Czesław Miłosz', + 'Grzegorz Kasdepke', + 'Henryk Sienkiewicz', + 'Jacek Dukaj', + 'Jacek Piekara', + 'Jakub Żulczyk', + 'Jarosław Grzędowicz', + 'Jerzy Pilch', + 'Joanna Bator', + 'Katarzyna Bonda', + 'Katarzyna Michalak', + 'Krzysztof Kamil Baczyński', + 'Leopold Tyrmand', + 'Mariusz Szczygieł', + 'Marta Galewska-Kustra', + 'Olga Tokarczuk', + 'Paulina Świst', + 'Remigiusz Mróz', + 'Stanisław Lem', + 'Sylwia Chutnik', + 'Szczepan Twardoch', + 'Tadeusz Konwicki', + 'Wiesław Myśliwski', + 'Wisława Szymborska', + 'Wojciech Chmielarz', + 'Zbigniew Herbert', + 'Zygmunt Miłoszewski', +]; diff --git a/src/locales/pl/book/format.ts b/src/locales/pl/book/format.ts new file mode 100644 index 00000000000..b1ff4aeb303 --- /dev/null +++ b/src/locales/pl/book/format.ts @@ -0,0 +1 @@ +export default ['Audiobook', 'Ebook', 'Miękka okładka', 'Twarda okładka']; diff --git a/src/locales/pl/book/genre.ts b/src/locales/pl/book/genre.ts new file mode 100644 index 00000000000..39397fca864 --- /dev/null +++ b/src/locales/pl/book/genre.ts @@ -0,0 +1,20 @@ +export default [ + 'Beletrystyka', + 'Biografia', + 'Fantastyka', + 'Fantastyka naukowa', + 'Kryminał', + 'Książka kucharska', + 'Literatura dziecięca', + 'Literatura faktu', + 'Literatura młodzieżowa', + 'Literatura naukowa', + 'Literatura piękna', + 'Literatura podróżnicza', + 'Literatura popularnonaukowa', + 'Poezja', + 'Powieść historyczna', + 'Powieść przygodowa', + 'Reportaż', + 'Rozwój osobisty', +]; diff --git a/src/locales/pl/book/index.ts b/src/locales/pl/book/index.ts new file mode 100644 index 00000000000..43ead3988d5 --- /dev/null +++ b/src/locales/pl/book/index.ts @@ -0,0 +1,22 @@ +/* + * This file is automatically generated. + * Run 'pnpm run generate:locales' to update. + */ +import type { BookDefinition } from '../../..'; +import author from './author'; +import format from './format'; +import genre from './genre'; +import publisher from './publisher'; +import series from './series'; +import title from './title'; + +const book: BookDefinition = { + author, + format, + genre, + publisher, + series, + title, +}; + +export default book; diff --git a/src/locales/pl/book/publisher.ts b/src/locales/pl/book/publisher.ts new file mode 100644 index 00000000000..2b319f31758 --- /dev/null +++ b/src/locales/pl/book/publisher.ts @@ -0,0 +1,12 @@ +export default [ + 'Czarne', + 'Dom Wydawniczy Rebis', + 'Muza', + 'PWN', + 'W.A.B.', + 'Wydawnictwo Agora', + 'Wydawnictwo Literackie', + 'Wydawnictwo Świat Książki', + 'Znak', + 'Zysk i S-ka Wydawnictwo', +]; diff --git a/src/locales/pl/book/series.ts b/src/locales/pl/book/series.ts new file mode 100644 index 00000000000..98082cfb685 --- /dev/null +++ b/src/locales/pl/book/series.ts @@ -0,0 +1,23 @@ +export default [ + 'Archiwum Burzowego Światła', + 'Cykl Inkwizytorski', + 'Diuna', + 'Dziedzictwo', + 'Harry Potter', + 'Igrzyska Śmierci', + 'Jakub Wędrowycz', + 'Koło Czasu', + 'Malazańska Księga Poległych', + 'Mroczna Wieża', + 'Mroczne Materie', + 'Opowieści z Narnii', + 'Pan Lodowego Ogrodu', + 'Percy Jackson', + 'Pieśń lodu i ognia', + 'Saga o Ludziach Lodu', + 'Sherlock Holmes', + 'Wiedźmin', + 'Władca Pierścieni', + 'Zwiadowcy', + 'Świat Dysku', +]; diff --git a/src/locales/pl/book/title.ts b/src/locales/pl/book/title.ts new file mode 100644 index 00000000000..72131fba205 --- /dev/null +++ b/src/locales/pl/book/title.ts @@ -0,0 +1,101 @@ +export default [ + 'Aria z kurantem', + 'Arytmia', + 'Austeria', + 'Bal w operze', + 'Barbarzyńca w ogrodzie', + 'Bitwa o Monte Cassino', + 'Bramy raju', + 'Cantus', + 'Cesarz', + 'Cudzoziemka', + 'Czarny polonez', + 'Czarny potok', + 'Do piachu', + 'Droga donikąd', + 'Dziennik', + 'Dziennik 1954', + 'Dziennik bez samogłosek', + 'Dziennik pisany nocą', + 'Eseje dla Kasandry', + 'Ferdydurke', + 'Generał Barcz', + 'Granica', + 'Imperium', + 'Inny świat', + 'Jezioro Bodeńskie', + 'Kamień na kamieniu', + 'Kariera Nikodema Dyzmy', + 'Karmazynowy poemat', + 'Kartoteka', + 'Konopielka', + 'Lato 1932', + 'Lekcja martwego języka', + 'Ludzie na moście', + 'Madame', + 'Mała apokalipsa', + 'Medaliony', + 'Miazga', + 'Myśli nieuczesane', + 'Mój wiek. Pamiętnik mówiony', + 'Na nieludzkiej ziemi', + 'Na wysokiej połoninie', + 'Nadberezyńcy', + 'Napój cienisty', + 'Nie trzeba głośno mówić', + 'Nienasycenie', + 'Niepokój', + 'Noce i dnie', + 'Nuta człowiecza', + 'Obroty rzeczy', + 'Ocalenie', + 'Oktostychy', + 'Pamiętnik z Powstania Warszawskiego', + 'Pan Cogito', + 'Panny z Wilka', + 'Pierwszy krok w chmurach', + 'Pierścień z papieru', + 'Podróże do piekieł', + 'Pożegnanie jesieni', + 'Pożegnanie z Marią', + 'Pożoga', + 'Przed Nieznanym Trybunałem', + 'Przedwiośnie', + 'Przemija postać świata', + 'Raport o stanie wojennym', + 'Raport z oblężonego miasta', + 'Rodzinna Europa', + 'Rozmowy polskie latem roku 1983', + 'Rzeczpospolita Obojga Narodów', + 'Równanie serca', + 'Sanatorium pod klepsydrą', + 'Sennik współczesny', + 'Sklepy cynamonowe', + 'Sokrates tańczący', + 'Solaris', + 'Srebrne orły', + 'Szewcy', + 'Szkice piórkiem', + 'Sól ziemi', + 'Tango', + 'Trans-Atlantyk', + 'Trzy zimy', + 'Utwory poetyckie', + 'W polu', + 'Wariacje pocztowe', + 'Widnokrąg', + 'Widokówka z tego świata', + 'Wiersze', + 'Wieszanie', + 'Wiosna i wino', + 'Wołanie do Yeti', + 'Zachód słońca w Milanówku', + 'Zasypie wszystko, zawieje…', + 'Zdążyć przed Panem Bogiem', + 'Ziemia Urlo', + 'Zimne kraje', + 'Zniewolony umysł', + 'Zostało z uczty bogów', + 'Łąka', + 'Ślub', +]; diff --git a/src/locales/pl/index.ts b/src/locales/pl/index.ts index bdb734e2576..b05c5f4eb31 100644 --- a/src/locales/pl/index.ts +++ b/src/locales/pl/index.ts @@ -4,6 +4,7 @@ */ import type { LocaleDefinition } from '../..'; import animal from './animal'; +import book from './book'; import cell_phone from './cell_phone'; import color from './color'; import company from './company'; @@ -19,6 +20,7 @@ import team from './team'; const pl: LocaleDefinition = { animal, + book, cell_phone, color, company, diff --git a/src/modules/book/index.ts b/src/modules/book/index.ts new file mode 100644 index 00000000000..86e168d2ad4 --- /dev/null +++ b/src/modules/book/index.ts @@ -0,0 +1,93 @@ +import { ModuleBase } from '../../internal/module-base'; + +/** + * Module to generate book related entries. + * + * ### Overview + * + * - For a random title, use [`title()`](https://fakerjs.dev/api/book.html#title). + * - For a random existing author name, use [`author()`](https://fakerjs.dev/api/book.html#author). + * - For a random non-existing author name, use [`faker.person.fullName()`](https://fakerjs.dev/api/person.html#fullname). + * - For a random genre, use [`genre()`](https://fakerjs.dev/api/book.html#genre). + * - For a random series, use [`series()`](https://fakerjs.dev/api/book.html#series). + * - For a random publisher, use [`publisher()`](https://fakerjs.dev/api/book.html#publisher). + * - For a random book format, use [`format()`](https://fakerjs.dev/api/book.html#format). + * - For a random isbn, use [`faker.commerce.isbn()`](https://fakerjs.dev/api/commerce.html#isbn) + * + * All values may be localized. + */ +export class BookModule extends ModuleBase { + /** + * Returns a random author name. + * + * @example + * faker.book.author() // 'William Shakespeare' + * + * @since 9.1.0 + */ + author(): string { + return this.faker.helpers.arrayElement(this.faker.definitions.book.author); + } + + /** + * Returns a random book format. + * + * @example + * faker.book.format() // 'Hardcover' + * + * @since 9.1.0 + */ + format(): string { + return this.faker.helpers.arrayElement(this.faker.definitions.book.format); + } + + /** + * Returns a random genre. + * + * @example + * faker.book.genre() // 'Fantasy' + * + * @since 9.1.0 + */ + genre(): string { + return this.faker.helpers.arrayElement(this.faker.definitions.book.genre); + } + + /** + * Returns a random publisher. + * + * @example + * faker.book.publisher() // 'Addison-Wesley' + * + * @since 9.1.0 + */ + publisher(): string { + return this.faker.helpers.arrayElement( + this.faker.definitions.book.publisher + ); + } + + /** + * Returns a random series. + * + * @example + * faker.book.series() // 'Harry Potter' + * + * @since 9.1.0 + */ + series(): string { + return this.faker.helpers.arrayElement(this.faker.definitions.book.series); + } + + /** + * Returns a random title. + * + * @example + * faker.book.title() // 'Romeo and Juliet' + * + * @since 9.1.0 + */ + title(): string { + return this.faker.helpers.arrayElement(this.faker.definitions.book.title); + } +} diff --git a/test/modules/__snapshots__/book.spec.ts.snap b/test/modules/__snapshots__/book.spec.ts.snap new file mode 100644 index 00000000000..9a31406dcd8 --- /dev/null +++ b/test/modules/__snapshots__/book.spec.ts.snap @@ -0,0 +1,37 @@ +// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html + +exports[`book > 42 > author 1`] = `"Henry David Thoreau"`; + +exports[`book > 42 > format 1`] = `"Ebook"`; + +exports[`book > 42 > genre 1`] = `"Fantasy"`; + +exports[`book > 42 > publisher 1`] = `"Flame Tree Publishing"`; + +exports[`book > 42 > series 1`] = `"Sherlock Holmes"`; + +exports[`book > 42 > title 1`] = `"Lord Jim"`; + +exports[`book > 1211 > author 1`] = `"Virgil"`; + +exports[`book > 1211 > format 1`] = `"Paperback"`; + +exports[`book > 1211 > genre 1`] = `"Western"`; + +exports[`book > 1211 > publisher 1`] = `"University of Akron Press"`; + +exports[`book > 1211 > series 1`] = `"Thursday Next Series"`; + +exports[`book > 1211 > title 1`] = `"Tinker, Tailor, Soldier, Spy"`; + +exports[`book > 1337 > author 1`] = `"Frances Hodgson Burnett"`; + +exports[`book > 1337 > format 1`] = `"Ebook"`; + +exports[`book > 1337 > genre 1`] = `"Comic"`; + +exports[`book > 1337 > publisher 1`] = `"City Lights Publishers"`; + +exports[`book > 1337 > series 1`] = `"Jane Austen Murder Mysteries"`; + +exports[`book > 1337 > title 1`] = `"Gone with the Wind"`; diff --git a/test/modules/book.spec.ts b/test/modules/book.spec.ts new file mode 100644 index 00000000000..4da4a410b51 --- /dev/null +++ b/test/modules/book.spec.ts @@ -0,0 +1,77 @@ +import { describe, expect, it } from 'vitest'; +import { faker } from '../../src'; +import { seededTests } from '../support/seeded-runs'; +import { times } from '../support/times'; + +const NON_SEEDED_BASED_RUN = 5; + +describe('book', () => { + seededTests(faker, 'book', (t) => { + t.itEach('author', 'format', 'genre', 'publisher', 'series', 'title'); + }); + + describe.each(times(NON_SEEDED_BASED_RUN).map(() => faker.seed()))( + 'random seeded tests for seed %i', + () => { + describe('author()', () => { + it('should return an author name', () => { + const author = faker.book.author(); + + expect(author).toBeTruthy(); + expect(author).toBeTypeOf('string'); + expect(faker.definitions.book.author).toContain(author); + }); + }); + + describe('format()', () => { + it('should return a book format', () => { + const format = faker.book.format(); + + expect(format).toBeTruthy(); + expect(format).toBeTypeOf('string'); + expect(faker.definitions.book.format).toContain(format); + }); + }); + + describe('genre()', () => { + it('should return a genre', () => { + const genre = faker.book.genre(); + + expect(genre).toBeTruthy(); + expect(genre).toBeTypeOf('string'); + expect(faker.definitions.book.genre).toContain(genre); + }); + }); + + describe('publisher()', () => { + it('should return a publisher', () => { + const publisher = faker.book.publisher(); + + expect(publisher).toBeTruthy(); + expect(publisher).toBeTypeOf('string'); + expect(faker.definitions.book.publisher).toContain(publisher); + }); + }); + + describe('series()', () => { + it('should return a series', () => { + const series = faker.book.series(); + + expect(series).toBeTruthy(); + expect(series).toBeTypeOf('string'); + expect(faker.definitions.book.series).toContain(series); + }); + }); + + describe('title()', () => { + it('should return a title', () => { + const title = faker.book.title(); + + expect(title).toBeTruthy(); + expect(title).toBeTypeOf('string'); + expect(faker.definitions.book.title).toContain(title); + }); + }); + } + ); +});