Skip to content

Commit 9daa184

Browse files
authored
Merge pull request #373 from kabrunko-dev/randFirstName-refact
refactor(randFirstName): 💡 improve names variable ternary operator readabilty
2 parents 37cdf01 + cd1cbf9 commit 9daa184

File tree

1 file changed

+3
-7
lines changed

1 file changed

+3
-7
lines changed

packages/falso/src/lib/first-name.ts

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { fake } from './core/core';
2-
import { data } from './first-name.json';
2+
import { data as localeDefault } from './first-name.json';
33
import { NameOptions } from './full-name';
44
import { rand } from './rand';
55

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

3535
const names: string[] = withAccents
36-
? locale
37-
? locale?.withAccents[gender]
38-
: data.withAccents[gender]
39-
: locale
40-
? locale?.withoutAccents[gender]
36+
? data.withAccents[gender]
4137
: data.withoutAccents[gender];
4238

4339
return fake(names, options);

0 commit comments

Comments
 (0)