From 18957fa01d5023a50080c5602276eae3475c2db3 Mon Sep 17 00:00:00 2001 From: kobenguyent Date: Wed, 8 Jan 2025 13:29:52 +0100 Subject: [PATCH] feat: add randNoun and randAdjective --- README.md | 2 +- docs/docs/getting-started.mdx | 2 +- packages/falso/src/index.ts | 2 + packages/falso/src/lib/adjective.json | 203 +++++++++++++++++++++ packages/falso/src/lib/adjective.ts | 22 +++ packages/falso/src/lib/noun.json | 196 ++++++++++++++++++++ packages/falso/src/lib/noun.ts | 22 +++ packages/falso/src/tests/adjective.spec.ts | 13 ++ packages/falso/src/tests/noun.spec.ts | 13 ++ 9 files changed, 473 insertions(+), 2 deletions(-) create mode 100644 packages/falso/src/lib/adjective.json create mode 100644 packages/falso/src/lib/adjective.ts create mode 100644 packages/falso/src/lib/noun.json create mode 100644 packages/falso/src/lib/noun.ts create mode 100644 packages/falso/src/tests/adjective.spec.ts create mode 100644 packages/falso/src/tests/noun.spec.ts diff --git a/README.md b/README.md index 7d3d67c10..7dab7c0b6 100644 --- a/README.md +++ b/README.md @@ -19,7 +19,7 @@ Create massive amounts of fake data in the browser and NodeJS. Tree Shakeable &

-✅  203 Functions +✅  205 Functions ✅  Tree Shakable ✅  Fully Typed ✅  Factory Functions diff --git a/docs/docs/getting-started.mdx b/docs/docs/getting-started.mdx index b34d42bc9..b3674902f 100644 --- a/docs/docs/getting-started.mdx +++ b/docs/docs/getting-started.mdx @@ -13,7 +13,7 @@ title: Getting Started />

-✅  203 Functions +✅  205 Functions ✅  Tree Shakable ✅  Fully Typed ✅  Entity Functions diff --git a/packages/falso/src/index.ts b/packages/falso/src/index.ts index e29adeafd..9ddf5657e 100644 --- a/packages/falso/src/index.ts +++ b/packages/falso/src/index.ts @@ -1,6 +1,7 @@ export { randAbbreviation } from './lib/abbreviation'; export { randAccessory } from './lib/accessory'; export { randAccount } from './lib/account'; +export { randAdjective } from './lib/adjective'; export { randAlpha } from './lib/alpha'; export { randAlphaNumeric } from './lib/alpha-numeric'; export { randAmericanFootballTeam } from './lib/american-football-team'; @@ -116,6 +117,7 @@ export { randMovieCharacter } from './lib/movie-character'; export { randMusicGenre } from './lib/music-genre'; export { randNearbyGPSCoordinate } from './lib/nearby-gpscoordinate'; export { randNumber } from './lib/number'; +export { randNoun } from './lib/noun'; export { randOAuthProvider } from './lib/oauth-provider'; export { randOctal } from './lib/octal'; export { randOrdinalDirection } from './lib/ordinal-direction'; diff --git a/packages/falso/src/lib/adjective.json b/packages/falso/src/lib/adjective.json new file mode 100644 index 000000000..4ec41243a --- /dev/null +++ b/packages/falso/src/lib/adjective.json @@ -0,0 +1,203 @@ +{ + "data": [ + "Awesome", + "Rustic", + "Small", + "Gorgeous", + "Fantastic", + "Sleek", + "Intelligent", + "Unbranded", + "Refined", + "Licensed", + "Generic", + "Practical", + "Ergonomic", + "Handcrafted", + "Tasty", + "Handmade", + "Incredible", + "Delightful", + "Unique", + "Stylish", + "Modern", + "Sophisticated", + "Charming", + "Classic", + "Innovative", + "Elegant", + "Compact", + "Durable", + "Vivid", + "Reliable", + "Bright", + "Versatile", + "Bold", + "Simple", + "Luxurious", + "Warm", + "Cozy", + "Magical", + "Sturdy", + "Trendy", + "Efficient", + "Powerful", + "Vibrant", + "Graceful", + "Flawless", + "Distinctive", + "Lively", + "Dynamic", + "Alluring", + "Captivating", + "Radiant", + "Cheerful", + "Playful", + "Breathtaking", + "Inviting", + "Serene", + "Crisp", + "Soft", + "Smooth", + "Harmonious", + "Precise", + "Delicate", + "Exquisite", + "Majestic", + "Coherent", + "Polished", + "Peaceful", + "Luminous", + "Timeless", + "Rustic", + "Venerable", + "Sparkling", + "Futuristic", + "Creative", + "Bold", + "Zesty", + "Artistic", + "Cheery", + "Optimistic", + "Glowing", + "Dramatic", + "Mysterious", + "Rich", + "Intriguing", + "Robust", + "Neat", + "Whimsical", + "Unusual", + "Chic", + "Deliberate", + "Inspired", + "Fanciful", + "Energetic", + "Remarkable", + "Distinguished", + "Zany", + "Eclectic", + "Adaptable", + "Comfortable", + "Healthy", + "Affordable", + "Reliable", + "Artful", + "Focused", + "Minimalist", + "Groundbreaking", + "Subtle", + "Enduring", + "Mature", + "Sensible", + "Essential", + "Dependable", + "Thrifty", + "Meticulous", + "Balanced", + "Graceful", + "Adorable", + "Quaint", + "Lush", + "Bubbly", + "Vast", + "Energetic", + "Imaginative", + "Transparent", + "Natural", + "Classic", + "Festive", + "Dynamic", + "Tough", + "Inspired", + "Adaptive", + "Inventive", + "Clever", + "Witty", + "Youthful", + "Empowering", + "Amusing", + "Relaxing", + "Wholesome", + "Bold", + "Charismatic", + "Comprehensive", + "Savvy", + "Indulgent", + "Spontaneous", + "Exceptional", + "Opulent", + "Thorough", + "Precious", + "Astounding", + "Radiant", + "Dashing", + "Profound", + "Ethical", + "Magnetic", + "Exuberant", + "Refreshing", + "Breezy", + "Humble", + "Organic", + "Friendly", + "Loyal", + "Motivated", + "Enthusiastic", + "Insightful", + "Holistic", + "Jubilant", + "Vigorous", + "Inventive", + "Unstoppable", + "Intuitive", + "Flexible", + "Courageous", + "Magnetic", + "Fair", + "Precious", + "Charming", + "Diligent", + "Vivid", + "Earthy", + "Ample", + "Stunning", + "Introspective", + "Gleaming", + "Innovative", + "Nostalgic", + "Lavish", + "Sublime", + "Hearty", + "Posh", + "Graceful", + "Uplifting", + "Heroic", + "Ambitious", + "Plush", + "Affable", + "Brilliant", + "Endearing", + "Genuine" + ] +} diff --git a/packages/falso/src/lib/adjective.ts b/packages/falso/src/lib/adjective.ts new file mode 100644 index 000000000..ecd85eb8a --- /dev/null +++ b/packages/falso/src/lib/adjective.ts @@ -0,0 +1,22 @@ +import { FakeOptions, fake } from './core/core'; +import { data } from './adjective.json'; + +/** + * Generate a random adjective. + * + * @category text + * + * @example + * + * randAdjective() + * + * @example + * + * randAdjective({ length: 10 }) + * + */ +export function randAdjective( + options?: Options +) { + return fake(data, options); +} diff --git a/packages/falso/src/lib/noun.json b/packages/falso/src/lib/noun.json new file mode 100644 index 000000000..c918f9b4d --- /dev/null +++ b/packages/falso/src/lib/noun.json @@ -0,0 +1,196 @@ +{ + "data": [ + "Apple", + "Car", + "House", + "Book", + "Tree", + "River", + "Mountain", + "Dog", + "Cat", + "Bird", + "Chair", + "Table", + "Computer", + "Phone", + "Bottle", + "Key", + "Bag", + "Flower", + "Sun", + "Moon", + "Star", + "Cloud", + "Rain", + "Snow", + "Wind", + "Ocean", + "Beach", + "Forest", + "Garden", + "Bridge", + "City", + "Village", + "Road", + "Train", + "Bus", + "Plane", + "Ship", + "Boat", + "Clock", + "Watch", + "Pen", + "Pencil", + "Brush", + "Canvas", + "Picture", + "Painting", + "Statue", + "Monument", + "Tower", + "Castle", + "Palace", + "King", + "Queen", + "Prince", + "Princess", + "Hero", + "Villain", + "Soldier", + "Warrior", + "Teacher", + "Student", + "Doctor", + "Nurse", + "Engineer", + "Scientist", + "Artist", + "Writer", + "Singer", + "Actor", + "Dancer", + "Athlete", + "Farmer", + "Chef", + "Pilot", + "Driver", + "Builder", + "Manager", + "Leader", + "Friend", + "Family", + "Child", + "Parent", + "Sibling", + "Neighbor", + "Stranger", + "Guest", + "Customer", + "Worker", + "Boss", + "Owner", + "Creator", + "Inventor", + "Explorer", + "Discoverer", + "Guardian", + "Protector", + "Advocate", + "Volunteer", + "Helper", + "Partner", + "Companion", + "Ally", + "Enemy", + "Competitor", + "Supporter", + "Fan", + "Critic", + "Advisor", + "Consultant", + "Judge", + "Lawyer", + "Defendant", + "Witness", + "Author", + "Poet", + "Journalist", + "Reporter", + "Editor", + "Publisher", + "Photographer", + "Designer", + "Craftsman", + "Carpenter", + "Blacksmith", + "Mechanic", + "Scientist", + "Biologist", + "Chemist", + "Physicist", + "Astronomer", + "Geologist", + "Historian", + "Philosopher", + "Mathematician", + "Librarian", + "Archivist", + "Curator", + "Archaeologist", + "Psychologist", + "Therapist", + "Counselor", + "Coach", + "Trainer", + "Leader", + "Follower", + "Mentor", + "Guide", + "Explorer", + "Innovator", + "Pioneer", + "Inventor", + "Entrepreneur", + "Investor", + "Merchant", + "Trader", + "Buyer", + "Seller", + "Manufacturer", + "Producer", + "Distributor", + "Consumer", + "Customer", + "Passenger", + "Traveler", + "Tourist", + "Adventurer", + "Observer", + "Participant", + "Speaker", + "Listener", + "Reader", + "Writer", + "Artist", + "Performer", + "Musician", + "Composer", + "Singer", + "Dancer", + "Actor", + "Director", + "Filmmaker", + "Photographer", + "Painter", + "Sculptor", + "Architect", + "Engineer", + "Scientist", + "Technician", + "Specialist", + "Expert", + "Scholar", + "Researcher" + ] +} diff --git a/packages/falso/src/lib/noun.ts b/packages/falso/src/lib/noun.ts new file mode 100644 index 000000000..ca21223d5 --- /dev/null +++ b/packages/falso/src/lib/noun.ts @@ -0,0 +1,22 @@ +import { FakeOptions, fake } from './core/core'; +import { data } from './noun.json'; + +/** + * Generate a random noun. + * + * @category text + * + * @example + * + * randNoun() + * + * @example + * + * randNoun({ length: 10 }) + * + */ +export function randNoun( + options?: Options +) { + return fake(data, options); +} diff --git a/packages/falso/src/tests/adjective.spec.ts b/packages/falso/src/tests/adjective.spec.ts new file mode 100644 index 000000000..d18add66e --- /dev/null +++ b/packages/falso/src/tests/adjective.spec.ts @@ -0,0 +1,13 @@ +import { randAdjective } from '../lib/adjective'; + +describe(' adjective', () => { + it('should return a random adjective (type string)', () => { + expect(typeof randAdjective()).toEqual('string'); + }); + + it('should return a list of adjectives', () => { + const adjectives = randAdjective({ length: 4 }); + + expect(adjectives.length).toEqual(4); + }); +}); diff --git a/packages/falso/src/tests/noun.spec.ts b/packages/falso/src/tests/noun.spec.ts new file mode 100644 index 000000000..34bbec5dd --- /dev/null +++ b/packages/falso/src/tests/noun.spec.ts @@ -0,0 +1,13 @@ +import { randNoun } from '../lib/noun'; + +describe(' noun', () => { + it('should return a random noun (type string)', () => { + expect(typeof randNoun()).toEqual('string'); + }); + + it('should return a list of nouns', () => { + const adjectives = randNoun({ length: 4 }); + + expect(adjectives.length).toEqual(4); + }); +});