From 4056ab09c64be40d41562284ec64e7531fbaff41 Mon Sep 17 00:00:00 2001 From: Joscha Feth Date: Sat, 12 Oct 2024 14:39:42 +0100 Subject: feat(location): add `continent` method (#3162) --- src/definitions/location.ts | 5 +++++ src/locales/en/location/continent.ts | 9 +++++++++ src/locales/en/location/index.ts | 2 ++ src/modules/location/index.ts | 14 ++++++++++++++ 4 files changed, 30 insertions(+) create mode 100644 src/locales/en/location/continent.ts (limited to 'src') diff --git a/src/definitions/location.ts b/src/definitions/location.ts index 5aee4e79..9fbda95f 100644 --- a/src/definitions/location.ts +++ b/src/definitions/location.ts @@ -36,6 +36,11 @@ export type LocationDefinition = LocaleEntry<{ */ city_suffix: string[]; + /** + * The names of all continents. + */ + continent: string[]; + /** * The names of all countries. */ diff --git a/src/locales/en/location/continent.ts b/src/locales/en/location/continent.ts new file mode 100644 index 00000000..379b4601 --- /dev/null +++ b/src/locales/en/location/continent.ts @@ -0,0 +1,9 @@ +export default [ + 'Africa', + 'Antarctica', + 'Asia', + 'Australia', + 'Europe', + 'North America', + 'South America', +]; diff --git a/src/locales/en/location/index.ts b/src/locales/en/location/index.ts index 7938321d..64ca3268 100644 --- a/src/locales/en/location/index.ts +++ b/src/locales/en/location/index.ts @@ -8,6 +8,7 @@ import city_name from './city_name'; import city_pattern from './city_pattern'; import city_prefix from './city_prefix'; import city_suffix from './city_suffix'; +import continent from './continent'; import country from './country'; import county from './county'; import direction from './direction'; @@ -26,6 +27,7 @@ const location: LocationDefinition = { city_pattern, city_prefix, city_suffix, + continent, country, county, direction, diff --git a/src/modules/location/index.ts b/src/modules/location/index.ts index 4aabdd8d..4a49e029 100644 --- a/src/modules/location/index.ts +++ b/src/modules/location/index.ts @@ -216,6 +216,20 @@ export class LocationModule extends ModuleBase { ); } + /** + * Returns a random continent name. + * + * @example + * faker.location.continent() // 'Asia' + * + * @since 9.1.0 + */ + continent(): string { + return this.faker.helpers.arrayElement( + this.faker.definitions.location.continent + ); + } + /** * Returns a random [ISO_3166-1](https://en.wikipedia.org/wiki/ISO_3166-1) country code. * -- cgit v1.2.3