diff options
| -rw-r--r-- | scripts/bundle.ts | 2 | ||||
| -rw-r--r-- | src/definitions/internet.ts | 2 | ||||
| -rw-r--r-- | src/faker.ts | 56 | ||||
| -rw-r--r-- | src/index.ts | 4 | ||||
| -rw-r--r-- | src/modules/address/index.ts (renamed from src/address.ts) | 2 | ||||
| -rw-r--r-- | src/modules/animal/index.ts (renamed from src/animal.ts) | 2 | ||||
| -rw-r--r-- | src/modules/commerce/index.ts (renamed from src/commerce.ts) | 2 | ||||
| -rw-r--r-- | src/modules/company/index.ts (renamed from src/company.ts) | 2 | ||||
| -rw-r--r-- | src/modules/database/index.ts (renamed from src/database.ts) | 2 | ||||
| -rw-r--r-- | src/modules/datatype/index.ts (renamed from src/datatype.ts) | 6 | ||||
| -rw-r--r-- | src/modules/date/index.ts (renamed from src/date.ts) | 4 | ||||
| -rw-r--r-- | src/modules/fake/index.ts (renamed from src/fake.ts) | 4 | ||||
| -rw-r--r-- | src/modules/finance/iban.ts (renamed from src/utils/iban.ts) | 0 | ||||
| -rw-r--r-- | src/modules/finance/index.ts (renamed from src/finance.ts) | 6 | ||||
| -rw-r--r-- | src/modules/git/index.ts (renamed from src/git.ts) | 2 | ||||
| -rw-r--r-- | src/modules/hacker/index.ts (renamed from src/hacker.ts) | 2 | ||||
| -rw-r--r-- | src/modules/helpers/index.ts (renamed from src/helpers.ts) | 4 | ||||
| -rw-r--r-- | src/modules/image/index.ts (renamed from src/image.ts) | 10 | ||||
| -rw-r--r-- | src/modules/image/providers/lorempicsum.ts (renamed from src/image_providers/lorempicsum.ts) | 2 | ||||
| -rw-r--r-- | src/modules/image/providers/lorempixel.ts (renamed from src/image_providers/lorempixel.ts) | 4 | ||||
| -rw-r--r-- | src/modules/image/providers/unsplash.ts (renamed from src/image_providers/unsplash.ts) | 2 | ||||
| -rw-r--r-- | src/modules/internet/index.ts (renamed from src/internet.ts) | 4 | ||||
| -rw-r--r-- | src/modules/internet/user-agent.ts (renamed from src/utils/user-agent.ts) | 2 | ||||
| -rw-r--r-- | src/modules/lorem/index.ts (renamed from src/lorem.ts) | 2 | ||||
| -rw-r--r-- | src/modules/mersenne/index.ts (renamed from src/mersenne.ts) | 4 | ||||
| -rw-r--r-- | src/modules/mersenne/twister.ts (renamed from src/utils/mersenne.ts) | 0 | ||||
| -rw-r--r-- | src/modules/music/index.ts (renamed from src/music.ts) | 2 | ||||
| -rw-r--r-- | src/modules/name/index.ts (renamed from src/name.ts) | 4 | ||||
| -rw-r--r-- | src/modules/phone/index.ts (renamed from src/phone.ts) | 2 | ||||
| -rw-r--r-- | src/modules/random/index.ts (renamed from src/random.ts) | 6 | ||||
| -rw-r--r-- | src/modules/system/index.ts (renamed from src/system.ts) | 2 | ||||
| -rw-r--r-- | src/modules/time/index.ts (renamed from src/time.ts) | 4 | ||||
| -rw-r--r-- | src/modules/unique/index.ts (renamed from src/unique.ts) | 6 | ||||
| -rw-r--r-- | src/modules/unique/unique.ts (renamed from src/utils/unique.ts) | 2 | ||||
| -rw-r--r-- | src/modules/vehicle/index.ts (renamed from src/vehicle.ts) | 2 | ||||
| -rw-r--r-- | src/modules/word/index.ts (renamed from src/word.ts) | 2 | ||||
| -rw-r--r-- | src/utils/types.ts | 9 | ||||
| -rw-r--r-- | test/finance.spec.ts | 2 | ||||
| -rw-r--r-- | test/finance_iban.spec.ts | 2 | ||||
| -rw-r--r-- | test/mersenne.spec.ts | 2 | ||||
| -rw-r--r-- | test/scripts/apidoc/signature.example.ts | 2 |
41 files changed, 92 insertions, 89 deletions
diff --git a/scripts/bundle.ts b/scripts/bundle.ts index e831601a..29a3f2a0 100644 --- a/scripts/bundle.ts +++ b/scripts/bundle.ts @@ -25,7 +25,6 @@ buildSync({ // entryPoints: [ // './src/index.ts', // ...Object.keys(locales).map((locale) => `./src/locale/${locale}.ts`), - // './src/mersenne.ts', // ], outdir: './dist/cjs', bundle: false, // Creates 390MiB bundle ... @@ -42,7 +41,6 @@ buildSync({ entryPoints: [ './src/index.ts', ...Object.keys(locales).map((locale) => `./src/locale/${locale}.ts`), - './src/mersenne.ts', ], outdir: './dist/esm', bundle: true, diff --git a/src/definitions/internet.ts b/src/definitions/internet.ts index 3687229f..e81871f6 100644 --- a/src/definitions/internet.ts +++ b/src/definitions/internet.ts @@ -1,4 +1,4 @@ -import type { EmojiType } from '../internet'; +import type { EmojiType } from '../modules/internet'; /** * The possible definitions related to internet stuff. diff --git a/src/faker.ts b/src/faker.ts index 58209d34..e9fa978e 100644 --- a/src/faker.ts +++ b/src/faker.ts @@ -1,37 +1,33 @@ -import { Address } from './address'; -import { Animal } from './animal'; -import { Commerce } from './commerce'; -import { Company } from './company'; -import { Database } from './database'; -import { Datatype } from './datatype'; -import { _Date } from './date'; import type { LocaleDefinition } from './definitions'; import { FakerError } from './errors/faker-error'; -import { Fake } from './fake'; -import { Finance } from './finance'; -import { Git } from './git'; -import { Hacker } from './hacker'; -import { Helpers } from './helpers'; -import { Image } from './image'; import { deprecated } from './internal/deprecated'; -import { Internet } from './internet'; import type { KnownLocale } from './locales'; -import { Lorem } from './lorem'; -import { Mersenne } from './mersenne'; -import { Music } from './music'; -import { Name } from './name'; -import { Phone } from './phone'; -import { Random } from './random'; -import { System } from './system'; -import { Time } from './time'; -import { Unique } from './unique'; -import { Vehicle } from './vehicle'; -import { Word } from './word'; - -// https://github.com/microsoft/TypeScript/issues/29729#issuecomment-471566609 -export type LiteralUnion<T extends U, U = string> = - | T - | (U & { zz_IGNORE_ME?: never }); +import { Address } from './modules/address'; +import { Animal } from './modules/animal'; +import { Commerce } from './modules/commerce'; +import { Company } from './modules/company'; +import { Database } from './modules/database'; +import { Datatype } from './modules/datatype'; +import { _Date } from './modules/date'; +import { Fake } from './modules/fake'; +import { Finance } from './modules/finance'; +import { Git } from './modules/git'; +import { Hacker } from './modules/hacker'; +import { Helpers } from './modules/helpers'; +import { Image } from './modules/image'; +import { Internet } from './modules/internet'; +import { Lorem } from './modules/lorem'; +import { Mersenne } from './modules/mersenne'; +import { Music } from './modules/music'; +import { Name } from './modules/name'; +import { Phone } from './modules/phone'; +import { Random } from './modules/random'; +import { System } from './modules/system'; +import { Time } from './modules/time'; +import { Unique } from './modules/unique'; +import { Vehicle } from './modules/vehicle'; +import { Word } from './modules/word'; +import type { LiteralUnion } from './utils/types'; export type UsableLocale = LiteralUnion<KnownLocale>; export type UsedLocales = Partial<Record<UsableLocale, LocaleDefinition>>; diff --git a/src/index.ts b/src/index.ts index 984833f5..8a1d415e 100644 --- a/src/index.ts +++ b/src/index.ts @@ -28,8 +28,8 @@ export type { } from './definitions'; export { FakerError } from './errors/faker-error'; export type { FakerOptions, UsableLocale, UsedLocales } from './faker'; -export { Gender } from './name'; -export type { GenderType } from './name'; +export { Gender } from './modules/name'; +export type { GenderType } from './modules/name'; export { Faker }; // since we are requiring the top level of faker, load all locales by default diff --git a/src/address.ts b/src/modules/address/index.ts index e077acaa..db82e01e 100644 --- a/src/address.ts +++ b/src/modules/address/index.ts @@ -1,4 +1,4 @@ -import type { Faker } from '.'; +import type { Faker } from '../..'; /** * Module to generate addresses and locations. diff --git a/src/animal.ts b/src/modules/animal/index.ts index 6a1d10a2..416fe533 100644 --- a/src/animal.ts +++ b/src/modules/animal/index.ts @@ -1,4 +1,4 @@ -import type { Faker } from '.'; +import type { Faker } from '../..'; /** * Module to generate animal related entries. diff --git a/src/commerce.ts b/src/modules/commerce/index.ts index 754fe73a..71ce96d6 100644 --- a/src/commerce.ts +++ b/src/modules/commerce/index.ts @@ -1,4 +1,4 @@ -import type { Faker } from '.'; +import type { Faker } from '../..'; /** * Module to generate commerce and product related entries. diff --git a/src/company.ts b/src/modules/company/index.ts index c2d72260..fb5f2e66 100644 --- a/src/company.ts +++ b/src/modules/company/index.ts @@ -1,4 +1,4 @@ -import type { Faker } from '.'; +import type { Faker } from '../..'; /** * Module to generate company related entries. diff --git a/src/database.ts b/src/modules/database/index.ts index 770b4b04..073d3f8a 100644 --- a/src/database.ts +++ b/src/modules/database/index.ts @@ -1,4 +1,4 @@ -import type { Faker } from '.'; +import type { Faker } from '../..'; /** * Module to generate database related entries. diff --git a/src/datatype.ts b/src/modules/datatype/index.ts index 0984779b..653d4d3f 100644 --- a/src/datatype.ts +++ b/src/modules/datatype/index.ts @@ -1,6 +1,6 @@ -import type { Faker } from '.'; -import { FakerError } from './errors/faker-error'; -import { deprecated } from './internal/deprecated'; +import type { Faker } from '../..'; +import { FakerError } from '../../errors/faker-error'; +import { deprecated } from '../../internal/deprecated'; /** * Module to generate various primitive values and data types. diff --git a/src/date.ts b/src/modules/date/index.ts index bb65ce4e..09f608f0 100644 --- a/src/date.ts +++ b/src/modules/date/index.ts @@ -1,5 +1,5 @@ -import type { Faker } from '.'; -import type { DateEntryDefinition } from './definitions'; +import type { Faker } from '../..'; +import type { DateEntryDefinition } from '../../definitions'; /** * Converts date passed as a string, number or Date to a Date object. diff --git a/src/fake.ts b/src/modules/fake/index.ts index 4b6bc788..a9f2a22a 100644 --- a/src/fake.ts +++ b/src/modules/fake/index.ts @@ -1,5 +1,5 @@ -import type { Faker } from '.'; -import { FakerError } from './errors/faker-error'; +import type { Faker } from '../..'; +import { FakerError } from '../../errors/faker-error'; /** * Generator method for combining faker methods based on string input. diff --git a/src/utils/iban.ts b/src/modules/finance/iban.ts index 9b4780c5..9b4780c5 100644 --- a/src/utils/iban.ts +++ b/src/modules/finance/iban.ts diff --git a/src/finance.ts b/src/modules/finance/index.ts index 48ce550c..a74dceba 100644 --- a/src/finance.ts +++ b/src/modules/finance/index.ts @@ -1,6 +1,6 @@ -import type { Faker } from '.'; -import { FakerError } from './errors/faker-error'; -import iban from './utils/iban'; +import type { Faker } from '../..'; +import { FakerError } from '../../errors/faker-error'; +import iban from './iban'; /** * Module to generate finance related entries. diff --git a/src/git.ts b/src/modules/git/index.ts index c0c98062..e86f6648 100644 --- a/src/git.ts +++ b/src/modules/git/index.ts @@ -1,4 +1,4 @@ -import type { Faker } from '.'; +import type { Faker } from '../..'; /** * Module to generate git related entries. diff --git a/src/hacker.ts b/src/modules/hacker/index.ts index 49c63602..ee1bbc5c 100644 --- a/src/hacker.ts +++ b/src/modules/hacker/index.ts @@ -1,4 +1,4 @@ -import type { Faker } from '.'; +import type { Faker } from '../..'; /** * Module to generate hacker/IT words and phrases. diff --git a/src/helpers.ts b/src/modules/helpers/index.ts index 0d8ce5b0..1b28ddfa 100644 --- a/src/helpers.ts +++ b/src/modules/helpers/index.ts @@ -1,5 +1,5 @@ -import type { Faker } from '.'; -import { deprecated } from './internal/deprecated'; +import type { Faker } from '../..'; +import { deprecated } from '../../internal/deprecated'; /** * A full card with various details. diff --git a/src/image.ts b/src/modules/image/index.ts index fc6a2a96..9e8e1879 100644 --- a/src/image.ts +++ b/src/modules/image/index.ts @@ -1,8 +1,8 @@ -import type { Faker } from '.'; -import { LoremPicsum } from './image_providers/lorempicsum'; -import { Lorempixel } from './image_providers/lorempixel'; -import { Unsplash } from './image_providers/unsplash'; -import type { MethodsOf } from './utils/types'; +import type { Faker } from '../..'; +import type { MethodsOf } from '../../utils/types'; +import { LoremPicsum } from './providers/lorempicsum'; +import { Lorempixel } from './providers/lorempixel'; +import { Unsplash } from './providers/unsplash'; /** * Module to generate placeholder images. diff --git a/src/image_providers/lorempicsum.ts b/src/modules/image/providers/lorempicsum.ts index f28b1e8f..25869205 100644 --- a/src/image_providers/lorempicsum.ts +++ b/src/modules/image/providers/lorempicsum.ts @@ -1,4 +1,4 @@ -import type { Faker } from '..'; +import type { Faker } from '../../..'; /** * Module to generate links to random images on `https://picsum.photos/`. diff --git a/src/image_providers/lorempixel.ts b/src/modules/image/providers/lorempixel.ts index 17cbc2f5..f1ab384b 100644 --- a/src/image_providers/lorempixel.ts +++ b/src/modules/image/providers/lorempixel.ts @@ -1,5 +1,5 @@ -import type { Faker } from '..'; -import type { MethodsOf } from '../utils/types'; +import type { Faker } from '../../..'; +import type { MethodsOf } from '../../../utils/types'; /** * Module to generate links to random images on `https://lorempixel.com/`. diff --git a/src/image_providers/unsplash.ts b/src/modules/image/providers/unsplash.ts index 994b2a04..45bd815c 100644 --- a/src/image_providers/unsplash.ts +++ b/src/modules/image/providers/unsplash.ts @@ -1,4 +1,4 @@ -import type { Faker } from '..'; +import type { Faker } from '../../..'; /** * Module to generate links to random images on `https://source.unsplash.com/`. diff --git a/src/internet.ts b/src/modules/internet/index.ts index 6d018dc3..bcc5daf3 100644 --- a/src/internet.ts +++ b/src/modules/internet/index.ts @@ -1,5 +1,5 @@ -import type { Faker } from '.'; -import * as random_ua from './utils/user-agent'; +import type { Faker } from '../..'; +import * as random_ua from './user-agent'; export type EmojiType = | 'smiley' diff --git a/src/utils/user-agent.ts b/src/modules/internet/user-agent.ts index b3438cbd..046758d4 100644 --- a/src/utils/user-agent.ts +++ b/src/modules/internet/user-agent.ts @@ -42,7 +42,7 @@ * this stuff is worth it, you can buy me a beer in return. Luka Pusic */ -import type { Faker } from '..'; +import type { Faker } from '../..'; export type Arch = 'lin' | 'mac' | 'win'; diff --git a/src/lorem.ts b/src/modules/lorem/index.ts index a7a1b4d3..5df39146 100644 --- a/src/lorem.ts +++ b/src/modules/lorem/index.ts @@ -1,4 +1,4 @@ -import type { Faker } from '.'; +import type { Faker } from '../..'; /** * Module to generate random texts and words. diff --git a/src/mersenne.ts b/src/modules/mersenne/index.ts index c8f531f2..33e610f8 100644 --- a/src/mersenne.ts +++ b/src/modules/mersenne/index.ts @@ -1,5 +1,5 @@ -import { FakerError } from './errors/faker-error'; -import Gen from './utils/mersenne'; +import { FakerError } from '../../errors/faker-error'; +import Gen from './twister'; /** * Module to generate seed based random numbers. diff --git a/src/utils/mersenne.ts b/src/modules/mersenne/twister.ts index 5859f3ae..5859f3ae 100644 --- a/src/utils/mersenne.ts +++ b/src/modules/mersenne/twister.ts diff --git a/src/music.ts b/src/modules/music/index.ts index d0e0a1a7..a34a4bb8 100644 --- a/src/music.ts +++ b/src/modules/music/index.ts @@ -1,4 +1,4 @@ -import type { Faker } from '.'; +import type { Faker } from '../..'; /** * Module to generate music related entries. diff --git a/src/name.ts b/src/modules/name/index.ts index 280e4b09..c1ac22a7 100644 --- a/src/name.ts +++ b/src/modules/name/index.ts @@ -1,5 +1,5 @@ -import type { Faker } from '.'; -import { deprecated } from './internal/deprecated'; +import type { Faker } from '../..'; +import { deprecated } from '../../internal/deprecated'; export enum Gender { female = 'female', diff --git a/src/phone.ts b/src/modules/phone/index.ts index c8a1902d..7e85915c 100644 --- a/src/phone.ts +++ b/src/modules/phone/index.ts @@ -1,4 +1,4 @@ -import type { Faker } from '.'; +import type { Faker } from '../..'; /** * Module to generate phone-related data. diff --git a/src/random.ts b/src/modules/random/index.ts index 87976828..7939b298 100644 --- a/src/random.ts +++ b/src/modules/random/index.ts @@ -1,6 +1,6 @@ -import type { Faker } from '.'; -import { FakerError } from './errors/faker-error'; -import { deprecated } from './internal/deprecated'; +import type { Faker } from '../..'; +import { FakerError } from '../../errors/faker-error'; +import { deprecated } from '../../internal/deprecated'; /** * Method to reduce array of characters. diff --git a/src/system.ts b/src/modules/system/index.ts index 90e56d55..250f1fb8 100644 --- a/src/system.ts +++ b/src/modules/system/index.ts @@ -1,4 +1,4 @@ -import type { Faker } from '.'; +import type { Faker } from '../..'; const commonFileTypes = ['video', 'audio', 'image', 'text', 'application']; diff --git a/src/time.ts b/src/modules/time/index.ts index c33638a7..021d75c8 100644 --- a/src/time.ts +++ b/src/modules/time/index.ts @@ -1,5 +1,5 @@ -import type { LiteralUnion } from './faker'; -import { deprecated } from './internal/deprecated'; +import { deprecated } from '../../internal/deprecated'; +import type { LiteralUnion } from '../../utils/types'; /** * Module to generate time of dates in various formats. diff --git a/src/unique.ts b/src/modules/unique/index.ts index 188a2e63..798fc29e 100644 --- a/src/unique.ts +++ b/src/modules/unique/index.ts @@ -1,6 +1,6 @@ -import { deprecated } from './internal/deprecated'; -import type { RecordKey } from './utils/unique'; -import * as uniqueExec from './utils/unique'; +import { deprecated } from '../../internal/deprecated'; +import type { RecordKey } from './unique'; +import * as uniqueExec from './unique'; /** * Module to generate unique entries. diff --git a/src/utils/unique.ts b/src/modules/unique/unique.ts index df1b827e..70408faf 100644 --- a/src/utils/unique.ts +++ b/src/modules/unique/unique.ts @@ -1,4 +1,4 @@ -import { FakerError } from '../errors/faker-error'; +import { FakerError } from '../../errors/faker-error'; export type RecordKey = string | number | symbol; diff --git a/src/vehicle.ts b/src/modules/vehicle/index.ts index ca0d11f2..ec010af9 100644 --- a/src/vehicle.ts +++ b/src/modules/vehicle/index.ts @@ -1,4 +1,4 @@ -import type { Faker } from '.'; +import type { Faker } from '../..'; /** * Module to generate vehicle related entries. diff --git a/src/word.ts b/src/modules/word/index.ts index b586c0d0..5968d225 100644 --- a/src/word.ts +++ b/src/modules/word/index.ts @@ -1,4 +1,4 @@ -import type { Faker } from '.'; +import type { Faker } from '../..'; /** * Filters a string array for values with a specific length. diff --git a/src/utils/types.ts b/src/utils/types.ts index 705d02d1..65c87ebf 100644 --- a/src/utils/types.ts +++ b/src/utils/types.ts @@ -1,4 +1,13 @@ /** + * Type that provides auto-suggestions but also any string. + * + * @see https://github.com/microsoft/TypeScript/issues/29729#issuecomment-471566609 + */ +export type LiteralUnion<T extends U, U = string> = + | T + | (U & { zz_IGNORE_ME?: never }); + +/** * Type that represents a single method/function name of the given type. */ export type MethodOf< diff --git a/test/finance.spec.ts b/test/finance.spec.ts index 4656e1de..0a110870 100644 --- a/test/finance.spec.ts +++ b/test/finance.spec.ts @@ -1,7 +1,7 @@ import { afterEach, describe, expect, it } from 'vitest'; import { faker } from '../src'; import { FakerError } from '../src/errors/faker-error'; -import ibanLib from '../src/utils/iban'; +import ibanLib from '../src/modules/finance/iban'; import { luhnCheck } from './support/luhnCheck'; const seedRuns = [ diff --git a/test/finance_iban.spec.ts b/test/finance_iban.spec.ts index a5936faf..9384c885 100644 --- a/test/finance_iban.spec.ts +++ b/test/finance_iban.spec.ts @@ -1,7 +1,7 @@ import validator from 'validator'; import { describe, expect, it } from 'vitest'; import { faker } from '../src'; -import ibanLib from '../src/utils/iban'; +import ibanLib from '../src/modules/finance/iban'; const NON_SEEDED_BASED_RUN = 25; diff --git a/test/mersenne.spec.ts b/test/mersenne.spec.ts index 642731b2..4097b1e0 100644 --- a/test/mersenne.spec.ts +++ b/test/mersenne.spec.ts @@ -1,6 +1,6 @@ import { beforeAll, beforeEach, describe, expect, it } from 'vitest'; import { FakerError } from '../src/errors/faker-error'; -import { Mersenne } from '../src/mersenne'; +import { Mersenne } from '../src/modules/mersenne'; type SeededRun = { seed: number | number[]; diff --git a/test/scripts/apidoc/signature.example.ts b/test/scripts/apidoc/signature.example.ts index 9c9b483e..f709100e 100644 --- a/test/scripts/apidoc/signature.example.ts +++ b/test/scripts/apidoc/signature.example.ts @@ -1,4 +1,4 @@ -import type { LiteralUnion } from '../../../src/faker'; +import type { LiteralUnion } from '../../../src/utils/types'; /** * Parameter options type with default from signature. |
