@anil-labs/factory 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (98) hide show
  1. package/CHANGELOG.md +54 -0
  2. package/LICENSE +21 -0
  3. package/README.md +371 -0
  4. package/dist/builders/index.d.cts +40 -0
  5. package/dist/builders/index.d.ts +40 -0
  6. package/dist/chunks/faker-BOtDMmjd.cjs +1430 -0
  7. package/dist/chunks/faker-BOtDMmjd.cjs.map +1 -0
  8. package/dist/chunks/faker-BlEhpR26.mjs +1287 -0
  9. package/dist/chunks/faker-BlEhpR26.mjs.map +1 -0
  10. package/dist/chunks/persist-DcARfeC-.cjs +134 -0
  11. package/dist/chunks/persist-DcARfeC-.cjs.map +1 -0
  12. package/dist/chunks/persist-ZGX3NWMF.mjs +117 -0
  13. package/dist/chunks/persist-ZGX3NWMF.mjs.map +1 -0
  14. package/dist/core/collection.d.cts +41 -0
  15. package/dist/core/collection.d.ts +41 -0
  16. package/dist/core/factory.d.cts +115 -0
  17. package/dist/core/factory.d.ts +115 -0
  18. package/dist/core/index.d.cts +6 -0
  19. package/dist/core/index.d.ts +6 -0
  20. package/dist/core/registry.d.cts +20 -0
  21. package/dist/core/registry.d.ts +20 -0
  22. package/dist/core/sequence.d.cts +36 -0
  23. package/dist/core/sequence.d.ts +36 -0
  24. package/dist/core/types.d.cts +47 -0
  25. package/dist/core/types.d.ts +47 -0
  26. package/dist/faker/color.d.cts +22 -0
  27. package/dist/faker/color.d.ts +22 -0
  28. package/dist/faker/commerce.d.cts +21 -0
  29. package/dist/faker/commerce.d.ts +21 -0
  30. package/dist/faker/company.d.cts +20 -0
  31. package/dist/faker/company.d.ts +20 -0
  32. package/dist/faker/datatype.d.cts +16 -0
  33. package/dist/faker/datatype.d.ts +16 -0
  34. package/dist/faker/date.d.cts +29 -0
  35. package/dist/faker/date.d.ts +29 -0
  36. package/dist/faker/faker.d.cts +82 -0
  37. package/dist/faker/faker.d.ts +82 -0
  38. package/dist/faker/finance.d.cts +25 -0
  39. package/dist/faker/finance.d.ts +25 -0
  40. package/dist/faker/helpers.d.cts +52 -0
  41. package/dist/faker/helpers.d.ts +52 -0
  42. package/dist/faker/image.d.cts +22 -0
  43. package/dist/faker/image.d.ts +22 -0
  44. package/dist/faker/index.d.cts +21 -0
  45. package/dist/faker/index.d.ts +21 -0
  46. package/dist/faker/internet.d.cts +33 -0
  47. package/dist/faker/internet.d.ts +33 -0
  48. package/dist/faker/locale.d.cts +26 -0
  49. package/dist/faker/locale.d.ts +26 -0
  50. package/dist/faker/location.d.cts +30 -0
  51. package/dist/faker/location.d.ts +30 -0
  52. package/dist/faker/lorem.d.cts +26 -0
  53. package/dist/faker/lorem.d.ts +26 -0
  54. package/dist/faker/number.d.cts +31 -0
  55. package/dist/faker/number.d.ts +31 -0
  56. package/dist/faker/person.d.cts +29 -0
  57. package/dist/faker/person.d.ts +29 -0
  58. package/dist/faker/regex.d.cts +19 -0
  59. package/dist/faker/regex.d.ts +19 -0
  60. package/dist/faker/string.d.cts +33 -0
  61. package/dist/faker/string.d.ts +33 -0
  62. package/dist/faker/system.d.cts +29 -0
  63. package/dist/faker/system.d.ts +29 -0
  64. package/dist/faker.cjs +26 -0
  65. package/dist/faker.mjs +3 -0
  66. package/dist/index.cjs +635 -0
  67. package/dist/index.cjs.map +1 -0
  68. package/dist/index.d.cts +37 -0
  69. package/dist/index.d.ts +37 -0
  70. package/dist/index.mjs +596 -0
  71. package/dist/index.mjs.map +1 -0
  72. package/dist/locales/en.cjs +351 -0
  73. package/dist/locales/en.cjs.map +1 -0
  74. package/dist/locales/en.d.cts +11 -0
  75. package/dist/locales/en.d.ts +11 -0
  76. package/dist/locales/en.mjs +350 -0
  77. package/dist/locales/en.mjs.map +1 -0
  78. package/dist/locales/types.d.cts +30 -0
  79. package/dist/locales/types.d.ts +30 -0
  80. package/dist/persist/console.d.cts +15 -0
  81. package/dist/persist/console.d.ts +15 -0
  82. package/dist/persist/http.d.cts +42 -0
  83. package/dist/persist/http.d.ts +42 -0
  84. package/dist/persist/index.d.cts +5 -0
  85. package/dist/persist/index.d.ts +5 -0
  86. package/dist/persist/memory.d.cts +26 -0
  87. package/dist/persist/memory.d.ts +26 -0
  88. package/dist/persist.cjs +5 -0
  89. package/dist/persist.mjs +2 -0
  90. package/dist/prng/index.d.cts +5 -0
  91. package/dist/prng/index.d.ts +5 -0
  92. package/dist/prng/mulberry32.d.cts +19 -0
  93. package/dist/prng/mulberry32.d.ts +19 -0
  94. package/dist/prng/types.d.cts +23 -0
  95. package/dist/prng/types.d.ts +23 -0
  96. package/dist/snapshot/index.d.cts +16 -0
  97. package/dist/snapshot/index.d.ts +16 -0
  98. package/package.json +136 -0
@@ -0,0 +1,82 @@
1
+ import { Prng } from '../prng/types';
2
+ import { Person } from './person';
3
+ import { Internet } from './internet';
4
+ import { Location } from './location';
5
+ import { Lorem } from './lorem';
6
+ import { DateGen } from './date';
7
+ import { NumberGen } from './number';
8
+ import { StringGen } from './string';
9
+ import { Color } from './color';
10
+ import { Company } from './company';
11
+ import { Commerce } from './commerce';
12
+ import { Finance } from './finance';
13
+ import { Image } from './image';
14
+ import { System } from './system';
15
+ import { Datatype } from './datatype';
16
+ import { Helpers } from './helpers';
17
+ /** Options for constructing a `Faker` instance. */
18
+ export interface FakerOptions {
19
+ /** Initial locale name. Defaults to `"en"`. */
20
+ locale?: string;
21
+ /** Initial PRNG seed. If omitted, a time-based seed is used. */
22
+ seed?: number;
23
+ }
24
+ /**
25
+ * Faceted, seedable, locale-aware random-data generator.
26
+ *
27
+ * Every namespace shares the same PRNG and locale reference — `seed()` and
28
+ * `locale()` mutate that shared state in place, so changes propagate without
29
+ * re-constructing modules.
30
+ *
31
+ * @example
32
+ * ```ts
33
+ * import { Faker } from '@anil-labs/factory'
34
+ *
35
+ * const f = new Faker({ seed: 42, locale: 'en' })
36
+ * f.person.fullName() // "Olivia Patel"
37
+ * f.seed(42)
38
+ * f.person.fullName() // "Olivia Patel" — deterministic
39
+ *
40
+ * // Or use the package's default instance:
41
+ * import { faker } from '@anil-labs/factory'
42
+ * faker.seed(1)
43
+ * faker.internet.email()
44
+ * ```
45
+ */
46
+ export declare class Faker {
47
+ private readonly rng;
48
+ private readonly localeRef;
49
+ readonly person: Person;
50
+ readonly internet: Internet;
51
+ readonly location: Location;
52
+ readonly lorem: Lorem;
53
+ readonly date: DateGen;
54
+ readonly number: NumberGen;
55
+ readonly string: StringGen;
56
+ readonly color: Color;
57
+ readonly company: Company;
58
+ readonly commerce: Commerce;
59
+ readonly finance: Finance;
60
+ readonly image: Image;
61
+ readonly system: System;
62
+ readonly datatype: Datatype;
63
+ readonly helpers: Helpers;
64
+ constructor(opts?: FakerOptions);
65
+ /** Reseed the underlying PRNG. Subsequent calls are deterministic from here. */
66
+ seed(seed: number): this;
67
+ /** Switch the active locale. Throws if unknown. */
68
+ locale(name: string): this;
69
+ /** Read the current locale identifier (e.g. `"en"`). */
70
+ currentLocale(): string;
71
+ /** Read the current seed (useful for snapshot reproduction). */
72
+ currentSeed(): number;
73
+ /**
74
+ * Build a fresh, independent `Faker` with its own PRNG seeded from this
75
+ * one's current state. Useful when you need to fork a deterministic stream.
76
+ */
77
+ fork(): Faker;
78
+ /** Access the underlying PRNG. Advanced use only. */
79
+ rawPrng(): Prng;
80
+ }
81
+ /** Default singleton — mutable via `faker.seed()` / `faker.locale()`. */
82
+ export declare const faker: Faker;
@@ -0,0 +1,25 @@
1
+ import { Prng } from '../prng/types';
2
+ /**
3
+ * Finance generators.
4
+ *
5
+ * @example
6
+ * ```ts
7
+ * faker.finance.amount() // "327.41"
8
+ * faker.finance.amount(0, 10, 2, '$') // "$4.27"
9
+ * faker.finance.accountNumber()
10
+ * faker.finance.creditCardNumber() // 16-digit Luhn-valid number
11
+ * faker.finance.currencyCode()
12
+ * faker.finance.iban()
13
+ * ```
14
+ */
15
+ export declare class Finance {
16
+ private readonly rng;
17
+ constructor(rng: Prng);
18
+ amount(min?: number, max?: number, decimals?: number, symbol?: string): string;
19
+ accountNumber(digits?: number): string;
20
+ /** Generates a Luhn-valid 16-digit credit-card number. */
21
+ creditCardNumber(): string;
22
+ currencyCode(): string;
23
+ iban(countryCode?: string, length?: number): string;
24
+ bitcoinAddress(): string;
25
+ }
@@ -0,0 +1,25 @@
1
+ import { Prng } from '../prng/types';
2
+ /**
3
+ * Finance generators.
4
+ *
5
+ * @example
6
+ * ```ts
7
+ * faker.finance.amount() // "327.41"
8
+ * faker.finance.amount(0, 10, 2, '$') // "$4.27"
9
+ * faker.finance.accountNumber()
10
+ * faker.finance.creditCardNumber() // 16-digit Luhn-valid number
11
+ * faker.finance.currencyCode()
12
+ * faker.finance.iban()
13
+ * ```
14
+ */
15
+ export declare class Finance {
16
+ private readonly rng;
17
+ constructor(rng: Prng);
18
+ amount(min?: number, max?: number, decimals?: number, symbol?: string): string;
19
+ accountNumber(digits?: number): string;
20
+ /** Generates a Luhn-valid 16-digit credit-card number. */
21
+ creditCardNumber(): string;
22
+ currencyCode(): string;
23
+ iban(countryCode?: string, length?: number): string;
24
+ bitcoinAddress(): string;
25
+ }
@@ -0,0 +1,52 @@
1
+ import { Prng } from '../prng/types';
2
+ export interface WeightedItem<T> {
3
+ /** The value to potentially return. */
4
+ readonly value: T;
5
+ /** Relative weight; need not sum to 1. */
6
+ readonly weight: number;
7
+ }
8
+ export interface UniqueOptions {
9
+ /** Maximum number of attempts before giving up. Defaults to `count * 10`. */
10
+ maxRetries?: number;
11
+ }
12
+ /**
13
+ * General helpers — operate on arbitrary inputs, not tied to any locale or
14
+ * faker namespace.
15
+ *
16
+ * @example
17
+ * ```ts
18
+ * faker.helpers.arrayElement([1, 2, 3]) // 2
19
+ * faker.helpers.arrayElements([1, 2, 3, 4], 2) // [3, 1]
20
+ * faker.helpers.shuffle([1, 2, 3]) // [2, 3, 1]
21
+ * faker.helpers.weightedArrayElement([
22
+ * { value: 'rare', weight: 1 },
23
+ * { value: 'common', weight: 9 },
24
+ * ])
25
+ * faker.helpers.fromRegExp(/[A-Z]{3}\d{4}/) // "PWB7401"
26
+ * faker.helpers.unique(() => faker.internet.email(), 5)
27
+ * ```
28
+ */
29
+ export declare class Helpers {
30
+ private readonly rng;
31
+ constructor(rng: Prng);
32
+ arrayElement<T>(items: readonly T[]): T;
33
+ /** Pick `count` distinct elements from `items` (no replacement). */
34
+ arrayElements<T>(items: readonly T[], count?: number): T[];
35
+ shuffle<T>(items: readonly T[]): T[];
36
+ weightedArrayElement<T>(items: readonly WeightedItem<T>[]): T;
37
+ /** Build an array of length `length` by calling `fn(index)`. */
38
+ multiple<T>(length: number, fn: (index: number) => T): T[];
39
+ /** Repeat a string `count` times. */
40
+ repeat(value: string, count: number): string;
41
+ /** Sample-string matching a regex. */
42
+ fromRegExp(pattern: RegExp | string): string;
43
+ /**
44
+ * Collect `count` unique results from `fn`. Throws if the retry budget is
45
+ * exhausted before reaching `count`.
46
+ */
47
+ unique<T>(fn: () => T, count: number, options?: UniqueOptions): T[];
48
+ /** Pick a random `enum` value, handling numeric reverse-mappings. */
49
+ enumValue<T>(enumObj: Record<string, T>): T;
50
+ /** With probability `chance`, return `value`; otherwise `undefined`. */
51
+ maybe<T>(value: T, chance?: number): T | undefined;
52
+ }
@@ -0,0 +1,52 @@
1
+ import { Prng } from '../prng/types';
2
+ export interface WeightedItem<T> {
3
+ /** The value to potentially return. */
4
+ readonly value: T;
5
+ /** Relative weight; need not sum to 1. */
6
+ readonly weight: number;
7
+ }
8
+ export interface UniqueOptions {
9
+ /** Maximum number of attempts before giving up. Defaults to `count * 10`. */
10
+ maxRetries?: number;
11
+ }
12
+ /**
13
+ * General helpers — operate on arbitrary inputs, not tied to any locale or
14
+ * faker namespace.
15
+ *
16
+ * @example
17
+ * ```ts
18
+ * faker.helpers.arrayElement([1, 2, 3]) // 2
19
+ * faker.helpers.arrayElements([1, 2, 3, 4], 2) // [3, 1]
20
+ * faker.helpers.shuffle([1, 2, 3]) // [2, 3, 1]
21
+ * faker.helpers.weightedArrayElement([
22
+ * { value: 'rare', weight: 1 },
23
+ * { value: 'common', weight: 9 },
24
+ * ])
25
+ * faker.helpers.fromRegExp(/[A-Z]{3}\d{4}/) // "PWB7401"
26
+ * faker.helpers.unique(() => faker.internet.email(), 5)
27
+ * ```
28
+ */
29
+ export declare class Helpers {
30
+ private readonly rng;
31
+ constructor(rng: Prng);
32
+ arrayElement<T>(items: readonly T[]): T;
33
+ /** Pick `count` distinct elements from `items` (no replacement). */
34
+ arrayElements<T>(items: readonly T[], count?: number): T[];
35
+ shuffle<T>(items: readonly T[]): T[];
36
+ weightedArrayElement<T>(items: readonly WeightedItem<T>[]): T;
37
+ /** Build an array of length `length` by calling `fn(index)`. */
38
+ multiple<T>(length: number, fn: (index: number) => T): T[];
39
+ /** Repeat a string `count` times. */
40
+ repeat(value: string, count: number): string;
41
+ /** Sample-string matching a regex. */
42
+ fromRegExp(pattern: RegExp | string): string;
43
+ /**
44
+ * Collect `count` unique results from `fn`. Throws if the retry budget is
45
+ * exhausted before reaching `count`.
46
+ */
47
+ unique<T>(fn: () => T, count: number, options?: UniqueOptions): T[];
48
+ /** Pick a random `enum` value, handling numeric reverse-mappings. */
49
+ enumValue<T>(enumObj: Record<string, T>): T;
50
+ /** With probability `chance`, return `value`; otherwise `undefined`. */
51
+ maybe<T>(value: T, chance?: number): T | undefined;
52
+ }
@@ -0,0 +1,22 @@
1
+ import { Prng } from '../prng/types';
2
+ /**
3
+ * Image-URL generators. No bytes are produced — just predictable URLs that
4
+ * resolve to real images from public providers.
5
+ *
6
+ * @example
7
+ * ```ts
8
+ * faker.image.url() // picsum.photos URL
9
+ * faker.image.avatar() // ui-avatars URL
10
+ * faker.image.dataUri(64, 64) // tiny embeddable PNG
11
+ * ```
12
+ */
13
+ export declare class Image {
14
+ private readonly rng;
15
+ constructor(rng: Prng);
16
+ /** Picsum-photos placeholder URL. */
17
+ url(width?: number, height?: number): string;
18
+ /** ui-avatars.com avatar URL — needs a name to render initials. */
19
+ avatar(name?: string): string;
20
+ /** Tiny single-color PNG data-uri — useful for testing inline-image flows. */
21
+ dataUri(width?: number, height?: number): string;
22
+ }
@@ -0,0 +1,22 @@
1
+ import { Prng } from '../prng/types';
2
+ /**
3
+ * Image-URL generators. No bytes are produced — just predictable URLs that
4
+ * resolve to real images from public providers.
5
+ *
6
+ * @example
7
+ * ```ts
8
+ * faker.image.url() // picsum.photos URL
9
+ * faker.image.avatar() // ui-avatars URL
10
+ * faker.image.dataUri(64, 64) // tiny embeddable PNG
11
+ * ```
12
+ */
13
+ export declare class Image {
14
+ private readonly rng;
15
+ constructor(rng: Prng);
16
+ /** Picsum-photos placeholder URL. */
17
+ url(width?: number, height?: number): string;
18
+ /** ui-avatars.com avatar URL — needs a name to render initials. */
19
+ avatar(name?: string): string;
20
+ /** Tiny single-color PNG data-uri — useful for testing inline-image flows. */
21
+ dataUri(width?: number, height?: number): string;
22
+ }
@@ -0,0 +1,21 @@
1
+ export { Faker, faker } from './faker';
2
+ export type { FakerOptions } from './faker';
3
+ export { LocaleRef, registerLocale, getLocale, listLocales, en } from './locale';
4
+ export type { LocaleData } from '../locales/types';
5
+ export { generateFromRegex } from './regex';
6
+ export { Person } from './person';
7
+ export { Internet } from './internet';
8
+ export { Location } from './location';
9
+ export { Lorem } from './lorem';
10
+ export { DateGen } from './date';
11
+ export { NumberGen } from './number';
12
+ export { StringGen } from './string';
13
+ export { Color } from './color';
14
+ export { Company } from './company';
15
+ export { Commerce } from './commerce';
16
+ export { Finance } from './finance';
17
+ export { Image } from './image';
18
+ export { System } from './system';
19
+ export { Datatype } from './datatype';
20
+ export { Helpers } from './helpers';
21
+ export type { WeightedItem, UniqueOptions } from './helpers';
@@ -0,0 +1,21 @@
1
+ export { Faker, faker } from './faker';
2
+ export type { FakerOptions } from './faker';
3
+ export { LocaleRef, registerLocale, getLocale, listLocales, en } from './locale';
4
+ export type { LocaleData } from '../locales/types';
5
+ export { generateFromRegex } from './regex';
6
+ export { Person } from './person';
7
+ export { Internet } from './internet';
8
+ export { Location } from './location';
9
+ export { Lorem } from './lorem';
10
+ export { DateGen } from './date';
11
+ export { NumberGen } from './number';
12
+ export { StringGen } from './string';
13
+ export { Color } from './color';
14
+ export { Company } from './company';
15
+ export { Commerce } from './commerce';
16
+ export { Finance } from './finance';
17
+ export { Image } from './image';
18
+ export { System } from './system';
19
+ export { Datatype } from './datatype';
20
+ export { Helpers } from './helpers';
21
+ export type { WeightedItem, UniqueOptions } from './helpers';
@@ -0,0 +1,33 @@
1
+ import { Prng } from '../prng/types';
2
+ import { LocaleRef } from './locale';
3
+ /**
4
+ * Internet / network namespace.
5
+ *
6
+ * @example
7
+ * ```ts
8
+ * faker.internet.email() // "olivia.patel91@example.com"
9
+ * faker.internet.email({ firstName: 'Alice', lastName: 'Wu' }) // "alice.wu41@…"
10
+ * faker.internet.userName() // "alex_anderson"
11
+ * faker.internet.url() // "https://app.gupta.io"
12
+ * faker.internet.ipv4() // "172.16.42.7"
13
+ * faker.internet.password(12) // "K8m$pQrt2Wz!"
14
+ * ```
15
+ */
16
+ export declare class Internet {
17
+ private readonly rng;
18
+ private readonly locale;
19
+ constructor(rng: Prng, locale: LocaleRef);
20
+ email(opts?: {
21
+ firstName?: string;
22
+ lastName?: string;
23
+ }): string;
24
+ userName(): string;
25
+ /** Bare domain (e.g. `acme.io`). */
26
+ domainName(): string;
27
+ url(): string;
28
+ ipv4(): string;
29
+ ipv6(): string;
30
+ /** Random MAC address (colon-separated). */
31
+ mac(): string;
32
+ password(length?: number): string;
33
+ }
@@ -0,0 +1,33 @@
1
+ import { Prng } from '../prng/types';
2
+ import { LocaleRef } from './locale';
3
+ /**
4
+ * Internet / network namespace.
5
+ *
6
+ * @example
7
+ * ```ts
8
+ * faker.internet.email() // "olivia.patel91@example.com"
9
+ * faker.internet.email({ firstName: 'Alice', lastName: 'Wu' }) // "alice.wu41@…"
10
+ * faker.internet.userName() // "alex_anderson"
11
+ * faker.internet.url() // "https://app.gupta.io"
12
+ * faker.internet.ipv4() // "172.16.42.7"
13
+ * faker.internet.password(12) // "K8m$pQrt2Wz!"
14
+ * ```
15
+ */
16
+ export declare class Internet {
17
+ private readonly rng;
18
+ private readonly locale;
19
+ constructor(rng: Prng, locale: LocaleRef);
20
+ email(opts?: {
21
+ firstName?: string;
22
+ lastName?: string;
23
+ }): string;
24
+ userName(): string;
25
+ /** Bare domain (e.g. `acme.io`). */
26
+ domainName(): string;
27
+ url(): string;
28
+ ipv4(): string;
29
+ ipv6(): string;
30
+ /** Random MAC address (colon-separated). */
31
+ mac(): string;
32
+ password(length?: number): string;
33
+ }
@@ -0,0 +1,26 @@
1
+ import { LocaleData } from '../locales/types';
2
+ import { en } from '../locales/en';
3
+ /**
4
+ * Live reference to the active locale data. A single instance is shared by
5
+ * every faker namespace, so swapping the locale at the `Faker` level
6
+ * propagates instantly without rebuilding modules.
7
+ */
8
+ export declare class LocaleRef {
9
+ private currentName;
10
+ private currentData;
11
+ constructor(initial?: string);
12
+ /** Read the currently-active locale data. */
13
+ get data(): LocaleData;
14
+ /** Read the active locale's identifier (e.g. `"en"`). */
15
+ get name(): string;
16
+ /** Swap to a different registered locale. Throws if unknown. */
17
+ set(name: string): void;
18
+ }
19
+ /** Register a new locale. Overwrites if `name` already exists. */
20
+ export declare function registerLocale(name: string, data: LocaleData): void;
21
+ /** Read a locale's raw data without making it active. */
22
+ export declare function getLocale(name: string): LocaleData | undefined;
23
+ /** List every registered locale identifier. */
24
+ export declare function listLocales(): string[];
25
+ export type { LocaleData };
26
+ export { en };
@@ -0,0 +1,26 @@
1
+ import { LocaleData } from '../locales/types';
2
+ import { en } from '../locales/en';
3
+ /**
4
+ * Live reference to the active locale data. A single instance is shared by
5
+ * every faker namespace, so swapping the locale at the `Faker` level
6
+ * propagates instantly without rebuilding modules.
7
+ */
8
+ export declare class LocaleRef {
9
+ private currentName;
10
+ private currentData;
11
+ constructor(initial?: string);
12
+ /** Read the currently-active locale data. */
13
+ get data(): LocaleData;
14
+ /** Read the active locale's identifier (e.g. `"en"`). */
15
+ get name(): string;
16
+ /** Swap to a different registered locale. Throws if unknown. */
17
+ set(name: string): void;
18
+ }
19
+ /** Register a new locale. Overwrites if `name` already exists. */
20
+ export declare function registerLocale(name: string, data: LocaleData): void;
21
+ /** Read a locale's raw data without making it active. */
22
+ export declare function getLocale(name: string): LocaleData | undefined;
23
+ /** List every registered locale identifier. */
24
+ export declare function listLocales(): string[];
25
+ export type { LocaleData };
26
+ export { en };
@@ -0,0 +1,30 @@
1
+ import { Prng } from '../prng/types';
2
+ import { LocaleRef } from './locale';
3
+ /**
4
+ * Postal-address namespace.
5
+ *
6
+ * @example
7
+ * ```ts
8
+ * faker.location.streetAddress() // "742 Oak Ave"
9
+ * faker.location.city() // "Seattle"
10
+ * faker.location.country() // "United States"
11
+ * faker.location.latitude() // 47.6062
12
+ * ```
13
+ */
14
+ export declare class Location {
15
+ private readonly rng;
16
+ private readonly locale;
17
+ constructor(rng: Prng, locale: LocaleRef);
18
+ streetAddress(): string;
19
+ city(): string;
20
+ state(): string;
21
+ zipCode(): string;
22
+ /** Locale's primary country (e.g. `"United States"` for `en`). */
23
+ country(): string;
24
+ /** Random country from the locale's broader country list. */
25
+ countryName(): string;
26
+ /** Full single-line address. */
27
+ fullAddress(): string;
28
+ latitude(min?: number, max?: number): number;
29
+ longitude(min?: number, max?: number): number;
30
+ }
@@ -0,0 +1,30 @@
1
+ import { Prng } from '../prng/types';
2
+ import { LocaleRef } from './locale';
3
+ /**
4
+ * Postal-address namespace.
5
+ *
6
+ * @example
7
+ * ```ts
8
+ * faker.location.streetAddress() // "742 Oak Ave"
9
+ * faker.location.city() // "Seattle"
10
+ * faker.location.country() // "United States"
11
+ * faker.location.latitude() // 47.6062
12
+ * ```
13
+ */
14
+ export declare class Location {
15
+ private readonly rng;
16
+ private readonly locale;
17
+ constructor(rng: Prng, locale: LocaleRef);
18
+ streetAddress(): string;
19
+ city(): string;
20
+ state(): string;
21
+ zipCode(): string;
22
+ /** Locale's primary country (e.g. `"United States"` for `en`). */
23
+ country(): string;
24
+ /** Random country from the locale's broader country list. */
25
+ countryName(): string;
26
+ /** Full single-line address. */
27
+ fullAddress(): string;
28
+ latitude(min?: number, max?: number): number;
29
+ longitude(min?: number, max?: number): number;
30
+ }
@@ -0,0 +1,26 @@
1
+ import { Prng } from '../prng/types';
2
+ import { LocaleRef } from './locale';
3
+ /**
4
+ * Lorem-ipsum text generator.
5
+ *
6
+ * @example
7
+ * ```ts
8
+ * faker.lorem.word() // "consectetur"
9
+ * faker.lorem.words(3) // "dolor sit amet"
10
+ * faker.lorem.sentence() // "Ut labore et dolore magna aliqua."
11
+ * faker.lorem.paragraph()
12
+ * faker.lorem.paragraphs(3)
13
+ * ```
14
+ */
15
+ export declare class Lorem {
16
+ private readonly rng;
17
+ private readonly locale;
18
+ constructor(rng: Prng, locale: LocaleRef);
19
+ word(): string;
20
+ words(count?: number): string;
21
+ sentence(wordCount?: number): string;
22
+ paragraph(sentenceCount?: number): string;
23
+ paragraphs(count?: number): string;
24
+ /** Alias of `paragraph()` — matches faker.js. */
25
+ text(): string;
26
+ }
@@ -0,0 +1,26 @@
1
+ import { Prng } from '../prng/types';
2
+ import { LocaleRef } from './locale';
3
+ /**
4
+ * Lorem-ipsum text generator.
5
+ *
6
+ * @example
7
+ * ```ts
8
+ * faker.lorem.word() // "consectetur"
9
+ * faker.lorem.words(3) // "dolor sit amet"
10
+ * faker.lorem.sentence() // "Ut labore et dolore magna aliqua."
11
+ * faker.lorem.paragraph()
12
+ * faker.lorem.paragraphs(3)
13
+ * ```
14
+ */
15
+ export declare class Lorem {
16
+ private readonly rng;
17
+ private readonly locale;
18
+ constructor(rng: Prng, locale: LocaleRef);
19
+ word(): string;
20
+ words(count?: number): string;
21
+ sentence(wordCount?: number): string;
22
+ paragraph(sentenceCount?: number): string;
23
+ paragraphs(count?: number): string;
24
+ /** Alias of `paragraph()` — matches faker.js. */
25
+ text(): string;
26
+ }
@@ -0,0 +1,31 @@
1
+ import { Prng } from '../prng/types';
2
+ /**
3
+ * Number generators.
4
+ *
5
+ * @example
6
+ * ```ts
7
+ * faker.number.int({ min: 1, max: 100 })
8
+ * faker.number.float({ min: 0, max: 1, decimals: 3 })
9
+ * faker.number.bigInt({ min: 0n, max: 1000n })
10
+ * faker.number.between(1, 5)
11
+ * ```
12
+ */
13
+ export declare class NumberGen {
14
+ private readonly rng;
15
+ constructor(rng: Prng);
16
+ int(opts?: {
17
+ max?: number;
18
+ min?: number;
19
+ }): number;
20
+ float(opts?: {
21
+ decimals?: number;
22
+ max?: number;
23
+ min?: number;
24
+ }): number;
25
+ bigInt(opts?: {
26
+ max?: bigint;
27
+ min?: bigint;
28
+ }): bigint;
29
+ /** Convenience: integer in `[min, max]`. */
30
+ between(min: number, max: number): number;
31
+ }
@@ -0,0 +1,31 @@
1
+ import { Prng } from '../prng/types';
2
+ /**
3
+ * Number generators.
4
+ *
5
+ * @example
6
+ * ```ts
7
+ * faker.number.int({ min: 1, max: 100 })
8
+ * faker.number.float({ min: 0, max: 1, decimals: 3 })
9
+ * faker.number.bigInt({ min: 0n, max: 1000n })
10
+ * faker.number.between(1, 5)
11
+ * ```
12
+ */
13
+ export declare class NumberGen {
14
+ private readonly rng;
15
+ constructor(rng: Prng);
16
+ int(opts?: {
17
+ max?: number;
18
+ min?: number;
19
+ }): number;
20
+ float(opts?: {
21
+ decimals?: number;
22
+ max?: number;
23
+ min?: number;
24
+ }): number;
25
+ bigInt(opts?: {
26
+ max?: bigint;
27
+ min?: bigint;
28
+ }): bigint;
29
+ /** Convenience: integer in `[min, max]`. */
30
+ between(min: number, max: number): number;
31
+ }
@@ -0,0 +1,29 @@
1
+ import { Prng } from '../prng/types';
2
+ import { LocaleRef } from './locale';
3
+ /**
4
+ * Personal-name namespace.
5
+ *
6
+ * @example
7
+ * ```ts
8
+ * faker.person.firstName() // "Sarah"
9
+ * faker.person.firstName('male') // "James"
10
+ * faker.person.fullName() // "Olivia Patel"
11
+ * faker.person.jobTitle() // → from `company.jobTitle()`
12
+ * ```
13
+ */
14
+ export declare class Person {
15
+ private readonly rng;
16
+ private readonly locale;
17
+ constructor(rng: Prng, locale: LocaleRef);
18
+ firstName(sex?: 'male' | 'female'): string;
19
+ lastName(): string;
20
+ fullName(opts?: {
21
+ sex?: 'male' | 'female';
22
+ withPrefix?: boolean;
23
+ withSuffix?: boolean;
24
+ }): string;
25
+ prefix(): string;
26
+ suffix(): string;
27
+ /** Returns `"male"` or `"female"`. */
28
+ sex(): 'male' | 'female';
29
+ }