diff options
| author | Joscha Feth <[email protected]> | 2024-10-12 14:39:42 +0100 |
|---|---|---|
| committer | GitHub <[email protected]> | 2024-10-12 15:39:42 +0200 |
| commit | 4056ab09c64be40d41562284ec64e7531fbaff41 (patch) | |
| tree | f33217e1fb0d98b52f6076421aaca98757d52aac /src | |
| parent | 033c23b109de18dcfaf8abeab4e134a47c57b460 (diff) | |
| download | faker-4056ab09c64be40d41562284ec64e7531fbaff41.tar.xz faker-4056ab09c64be40d41562284ec64e7531fbaff41.zip | |
feat(location): add `continent` method (#3162)
Diffstat (limited to 'src')
| -rw-r--r-- | src/definitions/location.ts | 5 | ||||
| -rw-r--r-- | src/locales/en/location/continent.ts | 9 | ||||
| -rw-r--r-- | src/locales/en/location/index.ts | 2 | ||||
| -rw-r--r-- | src/modules/location/index.ts | 14 |
4 files changed, 30 insertions, 0 deletions
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 @@ -37,6 +37,11 @@ export type LocationDefinition = LocaleEntry<{ city_suffix: string[]; /** + * The names of all continents. + */ + continent: string[]; + + /** * The names of all countries. */ country: string[]; 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 @@ -217,6 +217,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. * * @param options The code to return or an options object. |
