From 8a0bbf5faa03c294d308a13fe210ba6aaeef6968 Mon Sep 17 00:00:00 2001 From: ST-DDT Date: Sun, 23 Apr 2023 18:51:27 +0200 Subject: feat: introduce locale proxy (#2004) --- src/faker.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'src/faker.ts') diff --git a/src/faker.ts b/src/faker.ts index a694fcc2..e715234d 100644 --- a/src/faker.ts +++ b/src/faker.ts @@ -3,6 +3,8 @@ import { FakerError } from './errors/faker-error'; import { deprecated } from './internal/deprecated'; import type { Mersenne } from './internal/mersenne/mersenne'; import mersenne from './internal/mersenne/mersenne'; +import type { LocaleProxy } from './locale-proxy'; +import { createLocaleProxy } from './locale-proxy'; import { AirlineModule } from './modules/airline'; import { AnimalModule } from './modules/animal'; import { ColorModule } from './modules/color'; @@ -59,7 +61,8 @@ import { mergeLocales } from './utils/merge-locales'; * customFaker.music.genre(); // throws Error as this data is not available in `es` */ export class Faker { - readonly definitions: LocaleDefinition; + readonly rawDefinitions: LocaleDefinition; + readonly definitions: LocaleProxy; private _defaultRefDate: () => Date = () => new Date(); /** @@ -329,7 +332,8 @@ export class Faker { locale = mergeLocales(locale); } - this.definitions = locale as LocaleDefinition; + this.rawDefinitions = locale as LocaleDefinition; + this.definitions = createLocaleProxy(this.rawDefinitions); } /** -- cgit v1.2.3