@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.
- package/CHANGELOG.md +54 -0
- package/LICENSE +21 -0
- package/README.md +371 -0
- package/dist/builders/index.d.cts +40 -0
- package/dist/builders/index.d.ts +40 -0
- package/dist/chunks/faker-BOtDMmjd.cjs +1430 -0
- package/dist/chunks/faker-BOtDMmjd.cjs.map +1 -0
- package/dist/chunks/faker-BlEhpR26.mjs +1287 -0
- package/dist/chunks/faker-BlEhpR26.mjs.map +1 -0
- package/dist/chunks/persist-DcARfeC-.cjs +134 -0
- package/dist/chunks/persist-DcARfeC-.cjs.map +1 -0
- package/dist/chunks/persist-ZGX3NWMF.mjs +117 -0
- package/dist/chunks/persist-ZGX3NWMF.mjs.map +1 -0
- package/dist/core/collection.d.cts +41 -0
- package/dist/core/collection.d.ts +41 -0
- package/dist/core/factory.d.cts +115 -0
- package/dist/core/factory.d.ts +115 -0
- package/dist/core/index.d.cts +6 -0
- package/dist/core/index.d.ts +6 -0
- package/dist/core/registry.d.cts +20 -0
- package/dist/core/registry.d.ts +20 -0
- package/dist/core/sequence.d.cts +36 -0
- package/dist/core/sequence.d.ts +36 -0
- package/dist/core/types.d.cts +47 -0
- package/dist/core/types.d.ts +47 -0
- package/dist/faker/color.d.cts +22 -0
- package/dist/faker/color.d.ts +22 -0
- package/dist/faker/commerce.d.cts +21 -0
- package/dist/faker/commerce.d.ts +21 -0
- package/dist/faker/company.d.cts +20 -0
- package/dist/faker/company.d.ts +20 -0
- package/dist/faker/datatype.d.cts +16 -0
- package/dist/faker/datatype.d.ts +16 -0
- package/dist/faker/date.d.cts +29 -0
- package/dist/faker/date.d.ts +29 -0
- package/dist/faker/faker.d.cts +82 -0
- package/dist/faker/faker.d.ts +82 -0
- package/dist/faker/finance.d.cts +25 -0
- package/dist/faker/finance.d.ts +25 -0
- package/dist/faker/helpers.d.cts +52 -0
- package/dist/faker/helpers.d.ts +52 -0
- package/dist/faker/image.d.cts +22 -0
- package/dist/faker/image.d.ts +22 -0
- package/dist/faker/index.d.cts +21 -0
- package/dist/faker/index.d.ts +21 -0
- package/dist/faker/internet.d.cts +33 -0
- package/dist/faker/internet.d.ts +33 -0
- package/dist/faker/locale.d.cts +26 -0
- package/dist/faker/locale.d.ts +26 -0
- package/dist/faker/location.d.cts +30 -0
- package/dist/faker/location.d.ts +30 -0
- package/dist/faker/lorem.d.cts +26 -0
- package/dist/faker/lorem.d.ts +26 -0
- package/dist/faker/number.d.cts +31 -0
- package/dist/faker/number.d.ts +31 -0
- package/dist/faker/person.d.cts +29 -0
- package/dist/faker/person.d.ts +29 -0
- package/dist/faker/regex.d.cts +19 -0
- package/dist/faker/regex.d.ts +19 -0
- package/dist/faker/string.d.cts +33 -0
- package/dist/faker/string.d.ts +33 -0
- package/dist/faker/system.d.cts +29 -0
- package/dist/faker/system.d.ts +29 -0
- package/dist/faker.cjs +26 -0
- package/dist/faker.mjs +3 -0
- package/dist/index.cjs +635 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +37 -0
- package/dist/index.d.ts +37 -0
- package/dist/index.mjs +596 -0
- package/dist/index.mjs.map +1 -0
- package/dist/locales/en.cjs +351 -0
- package/dist/locales/en.cjs.map +1 -0
- package/dist/locales/en.d.cts +11 -0
- package/dist/locales/en.d.ts +11 -0
- package/dist/locales/en.mjs +350 -0
- package/dist/locales/en.mjs.map +1 -0
- package/dist/locales/types.d.cts +30 -0
- package/dist/locales/types.d.ts +30 -0
- package/dist/persist/console.d.cts +15 -0
- package/dist/persist/console.d.ts +15 -0
- package/dist/persist/http.d.cts +42 -0
- package/dist/persist/http.d.ts +42 -0
- package/dist/persist/index.d.cts +5 -0
- package/dist/persist/index.d.ts +5 -0
- package/dist/persist/memory.d.cts +26 -0
- package/dist/persist/memory.d.ts +26 -0
- package/dist/persist.cjs +5 -0
- package/dist/persist.mjs +2 -0
- package/dist/prng/index.d.cts +5 -0
- package/dist/prng/index.d.ts +5 -0
- package/dist/prng/mulberry32.d.cts +19 -0
- package/dist/prng/mulberry32.d.ts +19 -0
- package/dist/prng/types.d.cts +23 -0
- package/dist/prng/types.d.ts +23 -0
- package/dist/snapshot/index.d.cts +16 -0
- package/dist/snapshot/index.d.ts +16 -0
- package/package.json +136 -0
|
@@ -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
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { Prng } from '../prng/types';
|
|
2
|
+
/**
|
|
3
|
+
* Generate a sample string that matches the given regular-expression pattern.
|
|
4
|
+
*
|
|
5
|
+
* Supports the regex subset commonly used in test data:
|
|
6
|
+
* - Literals, dot, escaped characters
|
|
7
|
+
* - Character classes `[a-z]`, `[^…]`, `\d`, `\D`, `\w`, `\W`, `\s`, `\S`
|
|
8
|
+
* - Groups `(...)`, non-capturing `(?:...)`, alternation `a|b|c`
|
|
9
|
+
* - Quantifiers `*`, `+`, `?`, `{n}`, `{n,m}` (lazy `?` is ignored)
|
|
10
|
+
*
|
|
11
|
+
* Unsupported regex features (lookbehind/lookahead, backreferences,
|
|
12
|
+
* named groups) are silently treated as literals.
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* ```ts
|
|
16
|
+
* generateFromRegex(/[A-Z]{3}-\d{4}/, prng) // "ZQX-4172"
|
|
17
|
+
* ```
|
|
18
|
+
*/
|
|
19
|
+
export declare function generateFromRegex(pattern: RegExp | string, rng: Prng): string;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { Prng } from '../prng/types';
|
|
2
|
+
/**
|
|
3
|
+
* Generate a sample string that matches the given regular-expression pattern.
|
|
4
|
+
*
|
|
5
|
+
* Supports the regex subset commonly used in test data:
|
|
6
|
+
* - Literals, dot, escaped characters
|
|
7
|
+
* - Character classes `[a-z]`, `[^…]`, `\d`, `\D`, `\w`, `\W`, `\s`, `\S`
|
|
8
|
+
* - Groups `(...)`, non-capturing `(?:...)`, alternation `a|b|c`
|
|
9
|
+
* - Quantifiers `*`, `+`, `?`, `{n}`, `{n,m}` (lazy `?` is ignored)
|
|
10
|
+
*
|
|
11
|
+
* Unsupported regex features (lookbehind/lookahead, backreferences,
|
|
12
|
+
* named groups) are silently treated as literals.
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* ```ts
|
|
16
|
+
* generateFromRegex(/[A-Z]{3}-\d{4}/, prng) // "ZQX-4172"
|
|
17
|
+
* ```
|
|
18
|
+
*/
|
|
19
|
+
export declare function generateFromRegex(pattern: RegExp | string, rng: Prng): string;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { Prng } from '../prng/types';
|
|
2
|
+
/**
|
|
3
|
+
* String / identifier generators.
|
|
4
|
+
*
|
|
5
|
+
* @example
|
|
6
|
+
* ```ts
|
|
7
|
+
* faker.string.uuid() // "f47ac10b-58cc-4372-a567-0e02b2c3d479"
|
|
8
|
+
* faker.string.nanoid()
|
|
9
|
+
* faker.string.alphanumeric(8)
|
|
10
|
+
* faker.string.hexadecimal(16)
|
|
11
|
+
* faker.string.sample(20) // any printable char
|
|
12
|
+
* faker.string.slug() // "dolor-sit-amet"
|
|
13
|
+
* ```
|
|
14
|
+
*/
|
|
15
|
+
export declare class StringGen {
|
|
16
|
+
private readonly rng;
|
|
17
|
+
constructor(rng: Prng);
|
|
18
|
+
/** RFC-4122 v4 UUID. */
|
|
19
|
+
uuid(): string;
|
|
20
|
+
/** URL-safe random ID — same alphabet as nanoid. */
|
|
21
|
+
nanoid(length?: number): string;
|
|
22
|
+
alpha(length?: number): string;
|
|
23
|
+
numeric(length?: number): string;
|
|
24
|
+
alphanumeric(length?: number): string;
|
|
25
|
+
hexadecimal(length?: number, opts?: {
|
|
26
|
+
prefix?: string;
|
|
27
|
+
}): string;
|
|
28
|
+
/** Random printable ASCII (32–126), any character. */
|
|
29
|
+
sample(length?: number): string;
|
|
30
|
+
/** Lowercase, hyphen-joined word sequence. */
|
|
31
|
+
slug(words?: number, dictionary?: readonly string[]): string;
|
|
32
|
+
private pickFrom;
|
|
33
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { Prng } from '../prng/types';
|
|
2
|
+
/**
|
|
3
|
+
* String / identifier generators.
|
|
4
|
+
*
|
|
5
|
+
* @example
|
|
6
|
+
* ```ts
|
|
7
|
+
* faker.string.uuid() // "f47ac10b-58cc-4372-a567-0e02b2c3d479"
|
|
8
|
+
* faker.string.nanoid()
|
|
9
|
+
* faker.string.alphanumeric(8)
|
|
10
|
+
* faker.string.hexadecimal(16)
|
|
11
|
+
* faker.string.sample(20) // any printable char
|
|
12
|
+
* faker.string.slug() // "dolor-sit-amet"
|
|
13
|
+
* ```
|
|
14
|
+
*/
|
|
15
|
+
export declare class StringGen {
|
|
16
|
+
private readonly rng;
|
|
17
|
+
constructor(rng: Prng);
|
|
18
|
+
/** RFC-4122 v4 UUID. */
|
|
19
|
+
uuid(): string;
|
|
20
|
+
/** URL-safe random ID — same alphabet as nanoid. */
|
|
21
|
+
nanoid(length?: number): string;
|
|
22
|
+
alpha(length?: number): string;
|
|
23
|
+
numeric(length?: number): string;
|
|
24
|
+
alphanumeric(length?: number): string;
|
|
25
|
+
hexadecimal(length?: number, opts?: {
|
|
26
|
+
prefix?: string;
|
|
27
|
+
}): string;
|
|
28
|
+
/** Random printable ASCII (32–126), any character. */
|
|
29
|
+
sample(length?: number): string;
|
|
30
|
+
/** Lowercase, hyphen-joined word sequence. */
|
|
31
|
+
slug(words?: number, dictionary?: readonly string[]): string;
|
|
32
|
+
private pickFrom;
|
|
33
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { Prng } from '../prng/types';
|
|
2
|
+
import { LocaleRef } from './locale';
|
|
3
|
+
import { StringGen } from './string';
|
|
4
|
+
/**
|
|
5
|
+
* Filesystem / operating-system generators.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```ts
|
|
9
|
+
* faker.system.fileName() // "amber-cedar-pine.json"
|
|
10
|
+
* faker.system.commonFileExt() // "pdf"
|
|
11
|
+
* faker.system.mimeType() // "image/png"
|
|
12
|
+
* faker.system.filePath() // "/var/log/glass-stone.txt"
|
|
13
|
+
* ```
|
|
14
|
+
*/
|
|
15
|
+
export declare class System {
|
|
16
|
+
private readonly rng;
|
|
17
|
+
private readonly locale;
|
|
18
|
+
private readonly strings;
|
|
19
|
+
constructor(rng: Prng, locale: LocaleRef, strings: StringGen);
|
|
20
|
+
commonFileExt(): string;
|
|
21
|
+
fileExt(): string;
|
|
22
|
+
fileName(opts?: {
|
|
23
|
+
withExt?: boolean;
|
|
24
|
+
}): string;
|
|
25
|
+
directoryPath(): string;
|
|
26
|
+
filePath(): string;
|
|
27
|
+
mimeType(): string;
|
|
28
|
+
semver(): string;
|
|
29
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { Prng } from '../prng/types';
|
|
2
|
+
import { LocaleRef } from './locale';
|
|
3
|
+
import { StringGen } from './string';
|
|
4
|
+
/**
|
|
5
|
+
* Filesystem / operating-system generators.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```ts
|
|
9
|
+
* faker.system.fileName() // "amber-cedar-pine.json"
|
|
10
|
+
* faker.system.commonFileExt() // "pdf"
|
|
11
|
+
* faker.system.mimeType() // "image/png"
|
|
12
|
+
* faker.system.filePath() // "/var/log/glass-stone.txt"
|
|
13
|
+
* ```
|
|
14
|
+
*/
|
|
15
|
+
export declare class System {
|
|
16
|
+
private readonly rng;
|
|
17
|
+
private readonly locale;
|
|
18
|
+
private readonly strings;
|
|
19
|
+
constructor(rng: Prng, locale: LocaleRef, strings: StringGen);
|
|
20
|
+
commonFileExt(): string;
|
|
21
|
+
fileExt(): string;
|
|
22
|
+
fileName(opts?: {
|
|
23
|
+
withExt?: boolean;
|
|
24
|
+
}): string;
|
|
25
|
+
directoryPath(): string;
|
|
26
|
+
filePath(): string;
|
|
27
|
+
mimeType(): string;
|
|
28
|
+
semver(): string;
|
|
29
|
+
}
|
package/dist/faker.cjs
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
const require_faker = require("./chunks/faker-BOtDMmjd.cjs");
|
|
3
|
+
const require_locales_en = require("./locales/en.cjs");
|
|
4
|
+
exports.Color = require_faker.Color;
|
|
5
|
+
exports.Commerce = require_faker.Commerce;
|
|
6
|
+
exports.Company = require_faker.Company;
|
|
7
|
+
exports.Datatype = require_faker.Datatype;
|
|
8
|
+
exports.DateGen = require_faker.DateGen;
|
|
9
|
+
exports.Faker = require_faker.Faker;
|
|
10
|
+
exports.Finance = require_faker.Finance;
|
|
11
|
+
exports.Helpers = require_faker.Helpers;
|
|
12
|
+
exports.Image = require_faker.Image;
|
|
13
|
+
exports.Internet = require_faker.Internet;
|
|
14
|
+
exports.LocaleRef = require_faker.LocaleRef;
|
|
15
|
+
exports.Location = require_faker.Location;
|
|
16
|
+
exports.Lorem = require_faker.Lorem;
|
|
17
|
+
exports.NumberGen = require_faker.NumberGen;
|
|
18
|
+
exports.Person = require_faker.Person;
|
|
19
|
+
exports.StringGen = require_faker.StringGen;
|
|
20
|
+
exports.System = require_faker.System;
|
|
21
|
+
exports.en = require_locales_en.en;
|
|
22
|
+
exports.faker = require_faker.faker;
|
|
23
|
+
exports.generateFromRegex = require_faker.generateFromRegex;
|
|
24
|
+
exports.getLocale = require_faker.getLocale;
|
|
25
|
+
exports.listLocales = require_faker.listLocales;
|
|
26
|
+
exports.registerLocale = require_faker.registerLocale;
|
package/dist/faker.mjs
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { S as registerLocale, _ as Internet, a as Datatype, b as getLocale, c as Finance, d as Color, f as StringGen, g as Location, h as Lorem, i as generateFromRegex, l as Commerce, m as DateGen, n as faker, o as System, p as NumberGen, r as Helpers, s as Image, t as Faker, u as Company, v as Person, x as listLocales, y as LocaleRef } from "./chunks/faker-BlEhpR26.mjs";
|
|
2
|
+
import { en } from "./locales/en.mjs";
|
|
3
|
+
export { Color, Commerce, Company, Datatype, DateGen, Faker, Finance, Helpers, Image, Internet, LocaleRef, Location, Lorem, NumberGen, Person, StringGen, System, en, faker, generateFromRegex, getLocale, listLocales, registerLocale };
|