feat: casing for random words (lorem.word / lorem.words casing option) - #3960
feat: casing for random words (lorem.word / lorem.words casing option)#3960hazrid93 wants to merge 1 commit into
Conversation
✅ Deploy Preview for fakerjs ready!Built without sensitive environment variables
To edit notification comments on pull requests, go to your Netlify project configuration. |
ST-DDT
left a comment
There was a problem hiding this comment.
CI is failing. Please run pnpn run preflight before commiting.
78da7a2 to
be4f019
Compare
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## next #3960 +/- ##
==========================================
- Coverage 98.91% 98.88% -0.03%
==========================================
Files 923 924 +1
Lines 3223 3232 +9
Branches 567 588 +21
==========================================
+ Hits 3188 3196 +8
- Misses 31 32 +1
Partials 4 4
🚀 New features to boost your workflow:
|
Closes faker-js#2165. Add a `casing?: 'lower' | 'upper' | 'capital' | 'mixed'` option to lorem.word (and a matching options param to lorem.words that threads it to each generated word). 'mixed' (the default) leaves the word's original casing unchanged, so existing default behavior (and snapshots) are unaffected. 'lower'/'upper'/'capital' apply lower/upper/capitalize.
be4f019 to
bae1aa8
Compare
There was a problem hiding this comment.
Pull request overview
This PR adds a casing option to lorem.word() and threads a matching option through lorem.words(), enabling callers to request 'lower', 'upper', 'capital', or 'mixed' casing while preserving the existing default behavior.
Changes:
- Introduces an
applyCasing()helper and acasingoption forlorem.word(). - Extends
lorem.words()with an optionaloptionsparameter and applies casing per generated word. - Updates JSDoc to document the new casing behavior and examples.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| * | ||
| * @default 'mixed' | ||
| */ | ||
| casing?: 'lower' | 'upper' | 'capital' | 'mixed'; |
| * | ||
| * @default 'mixed' | ||
| */ | ||
| casing?: 'lower' | 'upper' | 'capital' | 'mixed'; |
| wordList: this.faker.definitions.lorem.word, | ||
| }) | ||
| ); | ||
| return applyCasing(word, options.casing); |
Closes #2165.
Add a
casing?: 'lower' | 'upper' | 'capital' | 'mixed'option to lorem.word (and a matching options param to lorem.words that threads it to each generated word). 'mixed' (the default) leaves the word's original casing unchanged, so existing default behavior (and snapshots) are unaffected. 'lower'/'upper'/'capital' apply lower/upper/capitalize.