Skip to content

chore: fix JSDoc comments in word.ts #273

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

Merged
merged 1 commit into from
Jan 24, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 17 additions & 14 deletions src/word.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,11 @@ export class Word {
* Returns an adjective of random or optionally specified length.
* If specified length is unresolvable, returns random adjective.
*
* @method faker.word.adjective
* @param optional length of word to return
* @returns a random adjective
*/
adjective(length?: number): string {
var wordList = this.faker.definitions.word.adjective;

if (length) {
wordList = this.faker.definitions.word.adjective.filter(
(word: string) => word.length == length
Expand All @@ -39,17 +38,17 @@ export class Word {
* Returns an adverb of random or optionally specified length.
* If specified length is unresolvable, returns random adverb.
*
* @method faker.word.adverb
* @param optional length of word to return
* @returns random adverb
*/
adverb(length?: number): string {
var wordList = this.faker.definitions.word.adverb;

if (length) {
wordList = this.faker.definitions.word.adverb.filter(
(word: string) => word.length == length
);
}

// If result of filtered word list is undefined, return an element
// from the unfiltered list.
return (
Expand All @@ -62,105 +61,109 @@ export class Word {
* Returns a conjunction of random or optionally specified length.
* If specified length is unresolvable, returns random conjunction.
*
* @method faker.word.conjunction
* @param optional length of word to return
* @returns random conjunction
*/
conjunction(length?: number): string {
var wordList = this.faker.definitions.word.conjunction;

if (length) {
wordList = this.faker.definitions.word.conjunction.filter(
(word: string) => word.length == length
);
}

// If result of filtered word list is undefined, return an element
// from the unfiltered list.
return (
this.faker.random.arrayElement(wordList) ||
this.faker.random.arrayElement(this.faker.definitions.word.conjunction)
);
}

/**
* Returns an interjection of random or optionally specified length.
* If specified length is unresolvable, returns random interjection.
*
* @method faker.word.interjection
* @param optional length of word to return
* @returns random interjection
*/
interjection(length?: number): string {
var wordList = this.faker.definitions.word.interjection;

if (length) {
wordList = this.faker.definitions.word.interjection.filter(
(word: string) => word.length == length
);
}

// If result of filtered word list is undefined, return an element
// from the unfiltered list.
return (
this.faker.random.arrayElement(wordList) ||
this.faker.random.arrayElement(this.faker.definitions.word.interjection)
);
}

/**
* Returns a noun of random or optionally specified length.
* If specified length is unresolvable, returns random noun.
*
* @method faker.word.noun
* @param optional length of word to return
* @returns random noun
*/
noun(length?: number): string {
var wordList = this.faker.definitions.word.noun;

if (length) {
wordList = this.faker.definitions.word.noun.filter(
(word: string) => word.length == length
);
}

// If result of filtered word list is undefined, return an element
// from the unfiltered list.
return (
this.faker.random.arrayElement(wordList) ||
this.faker.random.arrayElement(this.faker.definitions.word.noun)
);
}

/**
* Returns a preposition of random or optionally specified length.
* If specified length is unresolvable, returns random preposition.
*
* @method faker.word.preposition
* @param optional length of word to return
* @returns random preposition
*/
preposition(length?: number): string {
var wordList = this.faker.definitions.word.preposition;

if (length) {
wordList = this.faker.definitions.word.preposition.filter(
(word: string) => word.length == length
);
}

// If result of filtered word list is undefined, return an element
// from the unfiltered list.
return (
this.faker.random.arrayElement(wordList) ||
this.faker.random.arrayElement(this.faker.definitions.word.preposition)
);
}

/**
* Returns a verb of random or optionally specified length.
* If specified length is unresolvable, returns random verb.
*
* @method faker.word.verb
* @param optional length of word to return
* @returns random verb
*/
verb(length?: number): string {
var wordList = this.faker.definitions.word.verb;

if (length) {
wordList = this.faker.definitions.word.verb.filter(
(word: string) => word.length == length
);
}

// If result of filtered word list is undefined, return an element
// from the unfiltered list.
return (
Expand Down