Skip to content

Commit

Permalink
Merge pull request #373 from kabrunko-dev/randFirstName-refact
Browse files Browse the repository at this point in the history
refactor(randFirstName): 💡 improve names variable ternary operator readabilty
  • Loading branch information
NetanelBasal authored Dec 22, 2023
2 parents 37cdf01 + cd1cbf9 commit 9daa184
Showing 1 changed file with 3 additions and 7 deletions.
10 changes: 3 additions & 7 deletions packages/falso/src/lib/first-name.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { fake } from './core/core';
import { data } from './first-name.json';
import { data as localeDefault } from './first-name.json';
import { NameOptions } from './full-name';
import { rand } from './rand';

Expand Down Expand Up @@ -30,14 +30,10 @@ export function randFirstName<Options extends NameOptions = never>(
) {
const withAccents = options?.withAccents ?? false;
const gender = options?.gender ?? rand(['male', 'female']);
const locale = options?.locale;
const data = options?.locale || localeDefault;

const names: string[] = withAccents
? locale
? locale?.withAccents[gender]
: data.withAccents[gender]
: locale
? locale?.withoutAccents[gender]
? data.withAccents[gender]
: data.withoutAccents[gender];

return fake(names, options);
Expand Down

0 comments on commit 9daa184

Please sign in to comment.