aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/definitions/address.ts35
-rw-r--r--src/definitions/animal.ts22
-rw-r--r--src/definitions/commerce.ts12
-rw-r--r--src/definitions/company.ts17
-rw-r--r--src/definitions/database.ts12
-rw-r--r--src/definitions/date.ts7
-rw-r--r--src/definitions/definitions.ts42
-rw-r--r--src/definitions/finance.ts12
-rw-r--r--src/definitions/hacker.ts14
-rw-r--r--src/definitions/index.ts1
-rw-r--r--src/definitions/internet.ts11
-rw-r--r--src/definitions/lorem.ts7
-rw-r--r--src/definitions/music.ts7
-rw-r--r--src/definitions/name.ts32
-rw-r--r--src/definitions/phone_number.ts7
-rw-r--r--src/definitions/system.ts10
-rw-r--r--src/definitions/utils.ts12
-rw-r--r--src/definitions/vehicle.ts13
-rw-r--r--src/definitions/word.ts15
-rw-r--r--src/faker.ts8
20 files changed, 6 insertions, 290 deletions
diff --git a/src/definitions/address.ts b/src/definitions/address.ts
index c5d5409f..6552f39a 100644
--- a/src/definitions/address.ts
+++ b/src/definitions/address.ts
@@ -1,5 +1,3 @@
-import { allOf } from './utils';
-
/**
* The possible definitions related to addresses.
*/
@@ -99,36 +97,3 @@ export interface AddressDefinitions {
// A list of timezones names.
time_zone: string[];
}
-
-/**
- * Internal: A list of all keys for the AddressDefinitions.
- */
-export const ADDRESS = allOf<keyof AddressDefinitions>()(
- 'postcode_by_state',
- 'postcode',
-
- 'city_name',
- 'city_prefix',
- 'city_suffix',
-
- 'country',
- 'state',
- 'state_abbr',
- 'county',
-
- 'direction_abbr',
- 'direction',
-
- 'building_number',
-
- 'street_prefix',
- 'street_suffix',
-
- 'street_address',
- 'secondary_address',
-
- 'country_code',
- 'country_code_alpha_3',
-
- 'time_zone'
-);
diff --git a/src/definitions/animal.ts b/src/definitions/animal.ts
index 68fe0db2..d056e402 100644
--- a/src/definitions/animal.ts
+++ b/src/definitions/animal.ts
@@ -1,5 +1,3 @@
-import { allOf } from './utils';
-
/**
* The possible definitions related to animals.
*/
@@ -19,23 +17,3 @@ export interface AnimalDefinitions {
snake: string[];
type: string[];
}
-
-/**
- * Internal: A list of all keys for the AnimalDefinitions.
- */
-export const ANIMAL = allOf<keyof AnimalDefinitions>()(
- 'dog',
- 'cat',
- 'snake',
- 'bear',
- 'lion',
- 'cetacean',
- 'insect',
- 'crocodilia',
- 'cow',
- 'bird',
- 'fish',
- 'rabbit',
- 'horse',
- 'type'
-);
diff --git a/src/definitions/commerce.ts b/src/definitions/commerce.ts
index dbe22f69..eb106463 100644
--- a/src/definitions/commerce.ts
+++ b/src/definitions/commerce.ts
@@ -1,5 +1,3 @@
-import { allOf } from './utils';
-
/**
* The possible definitions related to commerce.
*/
@@ -39,13 +37,3 @@ export interface CommerceProductNameDefinitions {
*/
product: string[];
}
-
-/**
- * Internal: A list of all keys for the CommerceDefinitions.
- */
-export const COMMERCE = allOf<keyof CommerceDefinitions>()(
- 'color',
- 'department',
- 'product_name',
- 'product_description'
-);
diff --git a/src/definitions/company.ts b/src/definitions/company.ts
index 35947bde..89999ced 100644
--- a/src/definitions/company.ts
+++ b/src/definitions/company.ts
@@ -1,5 +1,3 @@
-import { allOf } from './utils';
-
/**
* The possible definitions related to companies.
*/
@@ -33,18 +31,3 @@ export interface CompanyDefinitions {
*/
suffix: string[];
}
-
-/**
- * Internal: A list of all keys for the CompanyDefinitions.
- */
-export const COMPANY = allOf<keyof CompanyDefinitions>()(
- 'bs_adjective',
- 'bs_noun',
- 'bs_verb',
-
- 'adjective',
- 'descriptor',
- 'noun',
-
- 'suffix'
-);
diff --git a/src/definitions/database.ts b/src/definitions/database.ts
index 935f35fc..47ab603d 100644
--- a/src/definitions/database.ts
+++ b/src/definitions/database.ts
@@ -1,5 +1,3 @@
-import { allOf } from './utils';
-
/**
* The possible definitions related to databases.
*/
@@ -21,13 +19,3 @@ export interface DatabaseDefinitions {
*/
type: string[];
}
-
-/**
- * Internal: A list of all keys for the DatabaseDefinitions.
- */
-export const DATABASE = allOf<keyof DatabaseDefinitions>()(
- 'collation',
- 'column',
- 'engine',
- 'type'
-);
diff --git a/src/definitions/date.ts b/src/definitions/date.ts
index 2738bdb5..a6d74722 100644
--- a/src/definitions/date.ts
+++ b/src/definitions/date.ts
@@ -1,5 +1,3 @@
-import { allOf } from './utils';
-
/**
* The possible definitions related to dates.
*/
@@ -37,8 +35,3 @@ export interface DateEntryDefinition {
*/
abbr_context?: string[];
}
-
-/**
- * Internal: A list of all keys for the DateDefinitions.
- */
-export const DATE = allOf<keyof DateDefinitions>()('month', 'weekday');
diff --git a/src/definitions/definitions.ts b/src/definitions/definitions.ts
index b696d47a..69a6c5cb 100644
--- a/src/definitions/definitions.ts
+++ b/src/definitions/definitions.ts
@@ -1,35 +1,19 @@
import type { AddressDefinitions } from './address';
-import { ADDRESS } from './address';
import type { AnimalDefinitions } from './animal';
-import { ANIMAL } from './animal';
import type { CommerceDefinitions } from './commerce';
-import { COMMERCE } from './commerce';
import type { CompanyDefinitions } from './company';
-import { COMPANY } from './company';
import type { DatabaseDefinitions } from './database';
-import { DATABASE } from './database';
import type { DateDefinitions } from './date';
-import { DATE } from './date';
import type { FinanceDefinitions } from './finance';
-import { FINANCE } from './finance';
import type { HackerDefinitions } from './hacker';
-import { HACKER } from './hacker';
import type { InternetDefinitions } from './internet';
-import { INTERNET } from './internet';
import type { LoremDefinitions } from './lorem';
-import { LOREM } from './lorem';
import type { MusicDefinitions } from './music';
-import { MUSIC } from './music';
import type { NameDefinitions } from './name';
-import { NAME } from './name';
import type { PhoneNumberDefinitions } from './phone_number';
-import { PHONE_NUMBER } from './phone_number';
import type { SystemDefinitions } from './system';
-import { SYSTEM } from './system';
import type { VehicleDefinitions } from './vehicle';
-import { VEHICLE } from './vehicle';
import type { WordDefinitions } from './word';
-import { WORD } from './word';
/**
* The definitions as used by the Faker modules.
@@ -84,29 +68,3 @@ export type DefinitionTypes = {
} & {
readonly [module in keyof Definitions]: Array<keyof Definitions[module]>;
};
-
-/**
- * Internal: List off all modules and their properties,
- * that needs to have a fallback generated in Faker.loadDefinitions().
- */
-export const DEFINITIONS: DefinitionTypes = {
- title: 'metadata',
- separator: 'metadata',
-
- address: ADDRESS,
- animal: ANIMAL,
- company: COMPANY,
- commerce: COMMERCE,
- database: DATABASE,
- date: DATE,
- finance: FINANCE,
- hacker: HACKER,
- internet: INTERNET,
- lorem: LOREM,
- music: MUSIC,
- name: NAME,
- phone_number: PHONE_NUMBER,
- system: SYSTEM,
- vehicle: VEHICLE,
- word: WORD,
-};
diff --git a/src/definitions/finance.ts b/src/definitions/finance.ts
index 633d087f..e5f4553b 100644
--- a/src/definitions/finance.ts
+++ b/src/definitions/finance.ts
@@ -1,5 +1,3 @@
-import { allOf } from './utils';
-
/**
* The possible definitions related to finances.
*/
@@ -38,13 +36,3 @@ export interface FinanceCurrencyEntryDefinitions {
*/
symbol: string;
}
-
-/**
- * Internal: A list of all keys for the FinanceDefinitions.
- */
-export const FINANCE = allOf<keyof FinanceDefinitions>()(
- 'account_type',
- 'credit_card',
- 'currency',
- 'transaction_type'
-);
diff --git a/src/definitions/hacker.ts b/src/definitions/hacker.ts
index 00aa3a40..8a23c88a 100644
--- a/src/definitions/hacker.ts
+++ b/src/definitions/hacker.ts
@@ -1,5 +1,3 @@
-import { allOf } from './utils';
-
/**
* The possible definitions related to computers.
*/
@@ -33,15 +31,3 @@ export interface HackerDefinitions {
*/
verb: string[];
}
-
-/**
- * Internal: A list of all keys for the HackerDefinitions.
- */
-export const HACKER = allOf<keyof HackerDefinitions>()(
- 'abbreviation',
- 'adjective',
- 'ingverb',
- 'noun',
- 'phrase',
- 'verb'
-);
diff --git a/src/definitions/index.ts b/src/definitions/index.ts
index 9eb4c3f3..da01ed15 100644
--- a/src/definitions/index.ts
+++ b/src/definitions/index.ts
@@ -7,7 +7,6 @@ export type {
export type { CompanyDefinitions } from './company';
export type { DatabaseDefinitions } from './database';
export type { DateDefinitions, DateEntryDefinition } from './date';
-export { DEFINITIONS } from './definitions';
export type { DefinitionTypes, LocaleDefinition } from './definitions';
export type {
FinanceCurrencyEntryDefinitions,
diff --git a/src/definitions/internet.ts b/src/definitions/internet.ts
index 562f77e9..3687229f 100644
--- a/src/definitions/internet.ts
+++ b/src/definitions/internet.ts
@@ -1,5 +1,4 @@
import type { EmojiType } from '../internet';
-import { allOf } from './utils';
/**
* The possible definitions related to internet stuff.
@@ -22,13 +21,3 @@ export interface InternetDefinitions {
*/
emoji: Record<EmojiType, string[]>;
}
-
-/**
- * Internal: A list of all keys for the InternetDefinitions.
- */
-export const INTERNET = allOf<keyof InternetDefinitions>()(
- 'domain_suffix',
- 'example_email',
- 'free_email',
- 'emoji'
-);
diff --git a/src/definitions/lorem.ts b/src/definitions/lorem.ts
index eb548e46..202a527f 100644
--- a/src/definitions/lorem.ts
+++ b/src/definitions/lorem.ts
@@ -1,5 +1,3 @@
-import { allOf } from './utils';
-
/**
* The possible definitions related to lorem texts.
*/
@@ -9,8 +7,3 @@ export interface LoremDefinitions {
*/
words: string[];
}
-
-/**
- * Internal: A list of all keys for the LoremDefinitions.
- */
-export const LOREM = allOf<keyof LoremDefinitions>()('words');
diff --git a/src/definitions/music.ts b/src/definitions/music.ts
index 1f2ffdd8..eaa340ae 100644
--- a/src/definitions/music.ts
+++ b/src/definitions/music.ts
@@ -1,5 +1,3 @@
-import { allOf } from './utils';
-
/**
* The possible definitions related to music.
*/
@@ -9,8 +7,3 @@ export interface MusicDefinitions {
*/
genre: string[];
}
-
-/**
- * Internal: A list of all keys for the MusicDefinitions.
- */
-export const MUSIC = allOf<keyof MusicDefinitions>()('genre');
diff --git a/src/definitions/name.ts b/src/definitions/name.ts
index 57926649..a5156410 100644
--- a/src/definitions/name.ts
+++ b/src/definitions/name.ts
@@ -1,5 +1,3 @@
-import { allOf } from './utils';
-
/**
* The possible definitions related to people's names.
*/
@@ -41,33 +39,3 @@ export interface NameTitleDefinitions {
job: string[];
level?: string[];
}
-
-/**
- * Internal: A list of all keys for the NameDefinitions.
- */
-export const NAME = allOf<keyof NameDefinitions>()(
- 'gender',
- 'binary_gender',
-
- 'prefix',
- 'female_prefix',
- 'male_prefix',
-
- 'first_name',
- 'female_first_name',
- 'male_first_name',
-
- 'middle_name',
- 'female_middle_name',
- 'male_middle_name',
-
- 'last_name',
- 'female_last_name',
- 'male_last_name',
-
- 'suffix',
-
- 'name',
-
- 'title'
-);
diff --git a/src/definitions/phone_number.ts b/src/definitions/phone_number.ts
index ed7353b5..1fb69ad2 100644
--- a/src/definitions/phone_number.ts
+++ b/src/definitions/phone_number.ts
@@ -1,5 +1,3 @@
-import { allOf } from './utils';
-
/**
* The possible definitions related to phone numbers.
*/
@@ -14,8 +12,3 @@ export interface PhoneNumberDefinitions {
*/
formats: string[];
}
-
-/**
- * Internal: A list of all keys for the PhoneNumberDefinitions.
- */
-export const PHONE_NUMBER = allOf<keyof PhoneNumberDefinitions>()('formats');
diff --git a/src/definitions/system.ts b/src/definitions/system.ts
index 5c9039b4..c3e25232 100644
--- a/src/definitions/system.ts
+++ b/src/definitions/system.ts
@@ -1,5 +1,3 @@
-import { allOf } from './utils';
-
/**
* The possible definitions related to files and the system.
*/
@@ -23,11 +21,3 @@ export interface SystemMimeTypeEntryDefinitions {
compressible?: boolean;
charset?: string;
}
-
-/**
- * Internal: A list of all keys for the SystemDefinitions.
- */
-export const SYSTEM = allOf<keyof SystemDefinitions>()(
- 'directoryPaths',
- 'mimeTypes'
-);
diff --git a/src/definitions/utils.ts b/src/definitions/utils.ts
deleted file mode 100644
index 03764c1d..00000000
--- a/src/definitions/utils.ts
+++ /dev/null
@@ -1,12 +0,0 @@
-// https://stackoverflow.com/a/53395649/4573065
-export type AllOf<T> = ['Needs to be all of', T];
-
-/**
- * Creates a function that requires all keys of the generic type to be used as parameters.
- * The function itself will return the given parameters.
- */
-export function allOf<T>(): <U extends T[]>(
- ...array: U & ([T] extends [U[number]] ? unknown : AllOf<T>[])
-) => U & ([T] extends [U[number]] ? unknown : AllOf<T>[]) {
- return (...array) => array;
-}
diff --git a/src/definitions/vehicle.ts b/src/definitions/vehicle.ts
index 7fdc11f1..71c35851 100644
--- a/src/definitions/vehicle.ts
+++ b/src/definitions/vehicle.ts
@@ -1,5 +1,3 @@
-import { allOf } from './utils';
-
/**
* The possible definitions related to vehicles.
*/
@@ -25,14 +23,3 @@ export interface VehicleDefinitions {
*/
type: string[];
}
-
-/**
- * Internal: A list of all keys for the VehicleDefinitions.
- */
-export const VEHICLE = allOf<keyof VehicleDefinitions>()(
- 'bicycle_type',
- 'fuel',
- 'manufacturer',
- 'model',
- 'type'
-);
diff --git a/src/definitions/word.ts b/src/definitions/word.ts
index dcbe47dd..3e502215 100644
--- a/src/definitions/word.ts
+++ b/src/definitions/word.ts
@@ -1,5 +1,3 @@
-import { allOf } from './utils';
-
/**
* The possible definitions related to words.
*/
@@ -12,16 +10,3 @@ export interface WordDefinitions {
preposition: string[];
verb: string[];
}
-
-/**
- * Internal: A list of all keys for the WordDefinitions.
- */
-export const WORD = allOf<keyof WordDefinitions>()(
- 'adjective',
- 'adverb',
- 'conjunction',
- 'interjection',
- 'noun',
- 'preposition',
- 'verb'
-);
diff --git a/src/faker.ts b/src/faker.ts
index 5ae0bd9c..58209d34 100644
--- a/src/faker.ts
+++ b/src/faker.ts
@@ -6,7 +6,6 @@ import { Database } from './database';
import { Datatype } from './datatype';
import { _Date } from './date';
import type { LocaleDefinition } from './definitions';
-import { DEFINITIONS } from './definitions';
import { FakerError } from './errors/faker-error';
import { Fake } from './fake';
import { Finance } from './finance';
@@ -43,6 +42,11 @@ export interface FakerOptions {
localeFallback?: UsableLocale;
}
+const metadataKeys: ReadonlyArray<keyof LocaleDefinition> = [
+ 'title',
+ 'separator',
+];
+
export class Faker {
locales: UsedLocales;
locale: UsableLocale;
@@ -157,7 +161,7 @@ export class Faker {
let result = target[module];
if (result) {
return result;
- } else if (DEFINITIONS[module] === 'metadata') {
+ } else if (metadataKeys.includes(module)) {
return resolveBaseData(module);
} else {
result = moduleLoader(module);