From 7df26e69c78bd42607769234c5a2bb5bcc0d6f4d Mon Sep 17 00:00:00 2001 From: Shinigami92 Date: Mon, 21 Mar 2022 21:06:05 +0100 Subject: [PATCH 1/3] fix: solve various todos --- src/address.ts | 9 +-------- src/faker.ts | 2 -- src/internet.ts | 12 +++++++++++- src/lorem.ts | 9 +++------ 4 files changed, 15 insertions(+), 17 deletions(-) diff --git a/src/address.ts b/src/address.ts index eff72f2f58c..ec137ad27c7 100644 --- a/src/address.ts +++ b/src/address.ts @@ -171,10 +171,6 @@ export class Address { return result; } - // - // TODO: change all these methods that accept a boolean to instead accept an options hash. - // - /** * Generates a random localized street address. * @@ -308,13 +304,10 @@ export class Address { /** * Returns a random localized state from this country. * - * @param useAbbr This parameter does nothing. - * * @example * faker.address.state() // 'Georgia' */ - // TODO @Shinigami92 2022-01-13: useAbbr not in use - state(useAbbr?: boolean): string { + state(): string { return this.faker.random.arrayElement(this.faker.definitions.address.state); } diff --git a/src/faker.ts b/src/faker.ts index 83f59a06259..e2ec14a8cab 100644 --- a/src/faker.ts +++ b/src/faker.ts @@ -70,8 +70,6 @@ export class Faker { readonly finance = new Finance(this); readonly git: Git = new Git(this); readonly hacker: Hacker = new Hacker(this); - // TODO @Shinigami92 2022-01-12: iban was not used - // readonly iban = new (require('./iban'))(this); readonly image: Image = new Image(this); readonly internet: Internet = new Internet(this); readonly lorem: Lorem = new Lorem(this); diff --git a/src/internet.ts b/src/internet.ts index f80059f90ed..f247f06b4a9 100644 --- a/src/internet.ts +++ b/src/internet.ts @@ -203,8 +203,18 @@ export class Internet { * @example * faker.internet.ip() // '245.108.222.0' */ - // TODO @Shinigami92 2022-01-23: Add ipv4 alias ip(): string { + // TODO @Shinigami92 2022-03-21: We may want to return a IPv4 or IPv6 address here in a later major release + return this.ipv4(); + } + + /** + * Generates a random IPv4 address. + * + * @example + * faker.internet.ipv4() // '245.108.222.0' + */ + ipv4(): string { const randNum = () => { return this.faker.datatype.number(255).toFixed(0); }; diff --git a/src/lorem.ts b/src/lorem.ts index 296c88b50c0..13d51db0561 100644 --- a/src/lorem.ts +++ b/src/lorem.ts @@ -70,11 +70,11 @@ export class Lorem { * faker.lorem.sentence() // 'Voluptatum cupiditate suscipit autem eveniet aut dolorem aut officiis distinctio.' * faker.lorem.sentence(5) // 'Laborum voluptatem officiis est et.' */ - // TODO @Shinigami92 2022-01-11: `range` is not in use - sentence(wordCount?: number, range?: number): string { + sentence(wordCount?: number): string { if (typeof wordCount === 'undefined') { wordCount = this.faker.datatype.number({ min: 3, max: 10 }); } + // NOTE @Shinigami92 2022-03-21: `range` was a parameter for the original implementation. // if (typeof range == 'undefined') { range = 7; } // strange issue with the node_min_test failing for capitalize, please fix and add faker.lorem.back @@ -174,8 +174,6 @@ export class Lorem { /** * Generates a random text based on a random lorem method. * - * @param times This parameter does nothing. - * * @example * faker.lorem.text() // 'Doloribus autem non quis vero quia.' * faker.lorem.text() @@ -185,8 +183,7 @@ export class Lorem { * // Iure nam officia optio cumque. * // Dolor tempora iusto.' */ - // TODO @Shinigami92 2022-01-11: `times` is not in use - text(times?: number): string { + text(): string { const loremMethods = [ 'lorem.word', 'lorem.words', From 6d05f5b0b9ec8435b681eb89a426dd712f28575e Mon Sep 17 00:00:00 2001 From: Shinigami92 Date: Mon, 21 Mar 2022 21:52:09 +0100 Subject: [PATCH 2/3] chore: remove outcommented code --- src/lorem.ts | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/lorem.ts b/src/lorem.ts index 13d51db0561..8d4459b697b 100644 --- a/src/lorem.ts +++ b/src/lorem.ts @@ -74,11 +74,6 @@ export class Lorem { if (typeof wordCount === 'undefined') { wordCount = this.faker.datatype.number({ min: 3, max: 10 }); } - // NOTE @Shinigami92 2022-03-21: `range` was a parameter for the original implementation. - // if (typeof range == 'undefined') { range = 7; } - - // strange issue with the node_min_test failing for capitalize, please fix and add faker.lorem.back - //return faker.lorem.words(wordCount + Helpers.randomNumber(range)).join(' ').capitalize(); const sentence = this.faker.lorem.words(wordCount); return sentence.charAt(0).toUpperCase() + sentence.slice(1) + '.'; From 8c37f42f13bbad481148466da85751b13f5fc8df Mon Sep 17 00:00:00 2001 From: Shinigami92 Date: Mon, 21 Mar 2022 21:52:35 +0100 Subject: [PATCH 3/3] chore: remove JSDoc param --- src/lorem.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/src/lorem.ts b/src/lorem.ts index 8d4459b697b..4612fe2d1f6 100644 --- a/src/lorem.ts +++ b/src/lorem.ts @@ -64,7 +64,6 @@ export class Lorem { * Generates a space separated list of words beginning a capital letter and ending with a dot. * * @param wordCount The number of words, that should be in the sentence. Defaults to a random number between `3` and `10`. - * @param range Currently this parameter does nothing. * * @example * faker.lorem.sentence() // 'Voluptatum cupiditate suscipit autem eveniet aut dolorem aut officiis distinctio.'