-
-
Notifications
You must be signed in to change notification settings - Fork 912
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: add option to exclude emoji #2851
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,16 @@ | ||
export default [ | ||
'{{person.bio_part}}', | ||
'{{person.bio_part}}, {{person.bio_part}}', | ||
'{{person.bio_part}}, {{person.bio_part}}, {{person.bio_part}}', | ||
'{{person.bio_part}}, {{person.bio_part}}, {{person.bio_part}} {{internet.emoji}}', | ||
'{{word.noun}} {{person.bio_supporter}}', | ||
'{{word.noun}} {{person.bio_supporter}} {{internet.emoji}}', | ||
'{{word.noun}} {{person.bio_supporter}}, {{person.bio_part}}', | ||
'{{word.noun}} {{person.bio_supporter}}, {{person.bio_part}} {{internet.emoji}}', | ||
]; | ||
export default { | ||
emoji: [ | ||
'{{person.bio_part}}, {{internet.emoji}}', | ||
'{{person.bio_part}}, {{person.bio_part}}, {{internet.emoji}}', | ||
'{{person.bio_part}}, {{person.bio_part}}, {{person.bio_part}} {{internet.emoji}}', | ||
'{{word.noun}} {{person.bio_supporter}} {{internet.emoji}}', | ||
'{{word.noun}} {{person.bio_supporter}}, {{person.bio_part}} {{internet.emoji}}', | ||
], | ||
text: [ | ||
'{{person.bio_part}}', | ||
'{{person.bio_part}}, {{person.bio_part}}', | ||
'{{person.bio_part}}, {{person.bio_part}}, {{person.bio_part}}', | ||
'{{word.noun}} {{person.bio_supporter}}', | ||
'{{word.noun}} {{person.bio_supporter}}, {{person.bio_part}}', | ||
], | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,12 @@ | ||
export default [ | ||
'{{person.bio_part}}', | ||
'{{person.bio_part}} {{internet.emoji}}', | ||
'{{person.bio_part}}, {{person.bio_part}}', | ||
'{{person.bio_part}}, {{person.bio_part}} {{internet.emoji}}', | ||
'{{person.bio_part}}, {{person.bio_part}}, {{person.bio_part}}', | ||
'{{person.bio_part}}, {{person.bio_part}}, {{person.bio_part}} {{internet.emoji}}', | ||
]; | ||
export default { | ||
emoji: [ | ||
'{{person.bio_part}} {{internet.emoji}}', | ||
'{{person.bio_part}}, {{person.bio_part}} {{internet.emoji}}', | ||
'{{person.bio_part}}, {{person.bio_part}}, {{person.bio_part}} {{internet.emoji}}', | ||
], | ||
text: [ | ||
'{{person.bio_part}}', | ||
'{{person.bio_part}}, {{person.bio_part}}', | ||
'{{person.bio_part}}, {{person.bio_part}}, {{person.bio_part}}', | ||
], | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,14 @@ | ||
export default [ | ||
'{{person.bio_part}}', | ||
'{{person.bio_part}},{{person.bio_part}}', | ||
'{{person.bio_part}},{{person.bio_part}},{{person.bio_part}}', | ||
'{{person.bio_part}},{{person.bio_part}},{{person.bio_part}}{{internet.emoji}}', | ||
'{{word.noun}}{{person.bio_supporter}}', | ||
'{{word.noun}}{{person.bio_supporter}}{{internet.emoji}}', | ||
'{{word.noun}}{{person.bio_supporter}},{{person.bio_part}}', | ||
'{{word.noun}}{{person.bio_supporter}},{{person.bio_part}}{{internet.emoji}}', | ||
]; | ||
export default { | ||
emoji: [ | ||
'{{person.bio_part}},{{person.bio_part}},{{person.bio_part}}{{internet.emoji}}', | ||
'{{word.noun}}{{person.bio_supporter}}{{internet.emoji}}', | ||
'{{word.noun}}{{person.bio_supporter}},{{person.bio_part}}{{internet.emoji}}', | ||
], | ||
text: [ | ||
'{{person.bio_part}}', | ||
'{{person.bio_part}},{{person.bio_part}}', | ||
'{{person.bio_part}},{{person.bio_part}},{{person.bio_part}}', | ||
'{{word.noun}}{{person.bio_supporter}}', | ||
'{{word.noun}}{{person.bio_supporter}},{{person.bio_part}}', | ||
], | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,6 +9,8 @@ export enum Sex { | |
|
||
export type SexType = `${Sex}`; | ||
|
||
export type BioType = 'emoji' | 'text'; | ||
|
||
/** | ||
* Select a definition based on given sex. | ||
* | ||
|
@@ -312,15 +314,34 @@ export class PersonModule extends ModuleBase { | |
/** | ||
* Returns a random short biography | ||
* | ||
* @param options Options object. | ||
* @param options.types A list of pattern types that can be generated. Possible values are `'emoji'`, `'text'`. By default, any pattern will be included. | ||
* | ||
* @example | ||
* faker.person.bio() // 'oatmeal advocate, veteran 🐠' | ||
* faker.person.bio({ types: ['text'] }) // 'oatmeal advocate, veteran' | ||
* | ||
* @since 8.0.0 | ||
*/ | ||
bio(): string { | ||
const { bio_pattern } = this.faker.definitions.person; | ||
|
||
return this.faker.helpers.fake(bio_pattern); | ||
bio( | ||
options: { | ||
/** | ||
* A list of the bio pattern types that should be used. | ||
* | ||
* @default Object.keys(faker.definitions.person.bio_pattern) | ||
*/ | ||
types?: ReadonlyArray<BioType>; | ||
} = {} | ||
): string { | ||
const { | ||
types = Object.keys( | ||
this.faker.definitions.person.bio_pattern | ||
) as BioType[], | ||
} = options; | ||
const bioType = this.faker.helpers.arrayElement(types); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Couldn't we simply get rid of There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe lets check the requirements and intentions behind including emojis in the next team meeting. |
||
return this.faker.helpers.fake( | ||
this.faker.definitions.person.bio_pattern[bioType] | ||
); | ||
} | ||
|
||
/** | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Method options usally not provide extra or even replacement locale data. We usually allow users to control the method outcome through flags. In this case I could see such an option being named "includeEmojis" or "allowEmojis". We have similar options for:
internet.email
string.numeric
system.cron