Skip to content

Commit 4c56f18

Browse files
committed
refactor: transform word
1 parent 93637dc commit 4c56f18

1 file changed

Lines changed: 16 additions & 9 deletions

File tree

src/modules/word/sample.ts

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
11
import { FakerError } from '../../errors/faker-error';
22
import type { FakerCore } from '../../faker-core';
33
import { shuffle } from '../helpers/shuffle';
4+
import { adjective } from './adjective';
5+
import { adverb } from './adverb';
6+
import { conjunction } from './conjunction';
7+
import { interjection } from './interjection';
8+
import { noun } from './noun';
9+
import { preposition } from './preposition';
10+
import { verb } from './verb';
411

512
/**
613
* Returns a random word, that can be an adjective, adverb, conjunction, interjection, noun, preposition, or verb.
@@ -63,18 +70,18 @@ export function sample(
6370
} = {}
6471
): string {
6572
const wordMethods = shuffle(fakerCore, [
66-
this.adjective,
67-
this.adverb,
68-
this.conjunction,
69-
this.interjection,
70-
this.noun,
71-
this.preposition,
72-
this.verb,
73-
]);
73+
adjective,
74+
adverb,
75+
conjunction,
76+
interjection,
77+
noun,
78+
preposition,
79+
verb,
80+
] satisfies Array<typeof sample>);
7481

7582
for (const randomWordMethod of wordMethods) {
7683
try {
77-
return randomWordMethod(options);
84+
return randomWordMethod(fakerCore, options);
7885
} catch {
7986
// catch missing locale data potentially required by randomWordMethod
8087
continue;

0 commit comments

Comments
 (0)