@vielzeug/illusionist 2.3.1 → 3.0.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 (78) hide show
  1. package/README.md +2 -50
  2. package/dist/_helpers/boolean.cjs +1 -1
  3. package/dist/_helpers/boolean.cjs.map +1 -1
  4. package/dist/_helpers/boolean.d.ts +1 -1
  5. package/dist/_helpers/boolean.d.ts.map +1 -1
  6. package/dist/_helpers/boolean.js +4 -3
  7. package/dist/_helpers/boolean.js.map +1 -1
  8. package/dist/_helpers/float.cjs +1 -1
  9. package/dist/_helpers/float.cjs.map +1 -1
  10. package/dist/_helpers/float.d.ts +1 -1
  11. package/dist/_helpers/float.d.ts.map +1 -1
  12. package/dist/_helpers/float.js +6 -7
  13. package/dist/_helpers/float.js.map +1 -1
  14. package/dist/_helpers/int.cjs +1 -1
  15. package/dist/_helpers/int.cjs.map +1 -1
  16. package/dist/_helpers/int.d.ts +1 -1
  17. package/dist/_helpers/int.d.ts.map +1 -1
  18. package/dist/_helpers/int.js +1 -1
  19. package/dist/_helpers/int.js.map +1 -1
  20. package/dist/_helpers/next-float.d.ts +2 -0
  21. package/dist/_helpers/next-float.d.ts.map +1 -0
  22. package/dist/_helpers/next-float.js +2 -0
  23. package/dist/_helpers/string.cjs +1 -1
  24. package/dist/_helpers/string.cjs.map +1 -1
  25. package/dist/_helpers/string.d.ts +2 -2
  26. package/dist/_helpers/string.d.ts.map +1 -1
  27. package/dist/_helpers/string.js +18 -27
  28. package/dist/_helpers/string.js.map +1 -1
  29. package/dist/date/date.cjs +1 -1
  30. package/dist/date/date.cjs.map +1 -1
  31. package/dist/date/date.d.ts.map +1 -1
  32. package/dist/date/date.js +24 -24
  33. package/dist/date/date.js.map +1 -1
  34. package/dist/factory.cjs +1 -1
  35. package/dist/factory.cjs.map +1 -1
  36. package/dist/factory.d.ts +0 -5
  37. package/dist/factory.d.ts.map +1 -1
  38. package/dist/factory.js +12 -22
  39. package/dist/factory.js.map +1 -1
  40. package/dist/finance/finance.cjs +1 -1
  41. package/dist/finance/finance.cjs.map +1 -1
  42. package/dist/finance/finance.js +4 -4
  43. package/dist/finance/finance.js.map +1 -1
  44. package/dist/illusionist.cjs +3 -3
  45. package/dist/illusionist.cjs.map +1 -1
  46. package/dist/illusionist.iife.js +3 -3
  47. package/dist/illusionist.iife.js.map +1 -1
  48. package/dist/illusionist.js +3 -3
  49. package/dist/illusionist.js.map +1 -1
  50. package/dist/internet/internet.cjs +1 -1
  51. package/dist/internet/internet.cjs.map +1 -1
  52. package/dist/internet/internet.js +11 -10
  53. package/dist/internet/internet.js.map +1 -1
  54. package/dist/location/location.cjs +1 -1
  55. package/dist/location/location.cjs.map +1 -1
  56. package/dist/location/location.d.ts.map +1 -1
  57. package/dist/location/location.js +31 -30
  58. package/dist/location/location.js.map +1 -1
  59. package/dist/seed/create-seed.cjs +1 -1
  60. package/dist/seed/create-seed.cjs.map +1 -1
  61. package/dist/seed/create-seed.d.ts +2 -2
  62. package/dist/seed/create-seed.d.ts.map +1 -1
  63. package/dist/seed/create-seed.js +10 -11
  64. package/dist/seed/create-seed.js.map +1 -1
  65. package/dist/seed/mulberry32.cjs.map +1 -1
  66. package/dist/seed/mulberry32.d.ts +1 -1
  67. package/dist/seed/mulberry32.d.ts.map +1 -1
  68. package/dist/seed/mulberry32.js.map +1 -1
  69. package/dist/system/system.cjs +1 -1
  70. package/dist/system/system.cjs.map +1 -1
  71. package/dist/system/system.d.ts.map +1 -1
  72. package/dist/system/system.js +23 -24
  73. package/dist/system/system.js.map +1 -1
  74. package/dist/types.d.ts +2 -3
  75. package/dist/types.d.ts.map +1 -1
  76. package/package.json +10 -10
  77. package/dist/_dev.d.ts +0 -2
  78. package/dist/_dev.d.ts.map +0 -1
package/README.md CHANGED
@@ -1,8 +1,6 @@
1
1
  # @vielzeug/illusionist
2
2
 
3
- > Typed, deterministic, locale-aware fake data generator with seeded PRNG.
4
-
5
- [![npm version](https://img.shields.io/npm/v/@vielzeug/illusionist)](https://www.npmjs.com/package/@vielzeug/illusionist) [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
3
+ > Typed, deterministic, locale-aware fake data generator with seeded PRNG
6
4
 
7
5
  ## Installation
8
6
 
@@ -28,53 +26,6 @@ illusion.finance.iban(); // "IT0649896243786776403271206"
28
26
  illusion.location.city(); // "Denver"
29
27
  illusion.lorem.paragraph(); // "Dolor in fugiat anim dolor aute officia irure sunt..."
30
28
  illusion.system.semver(); // "7.4.0"
31
-
32
- illusion.dispose(); // [Symbol.dispose]() also works
33
- ```
34
-
35
- ## Entry Points
36
-
37
- - `@vielzeug/illusionist` — curated root exports + `createIllusion` factory
38
- - `@vielzeug/illusionist/person` — names, genders, job titles
39
- - `@vielzeug/illusionist/internet` — emails, URLs, IPs, user agents
40
- - `@vielzeug/illusionist/commerce` — product names, prices, departments
41
- - `@vielzeug/illusionist/date` — past/future dates, birthdays, weekdays
42
- - `@vielzeug/illusionist/finance` — IBANs, credit cards, crypto addresses
43
- - `@vielzeug/illusionist/location` — cities, streets, coordinates
44
- - `@vielzeug/illusionist/lorem` — lorem ipsum text generation
45
- - `@vielzeug/illusionist/system` — file paths, semver, UUIDs, cron
46
- - `@vielzeug/illusionist/seed` — `createSeed`, `mulberry32` PRNG
47
- - `@vielzeug/illusionist/locales` — locale objects (`en`, `de`); tree-shakeable, import only what you use
48
-
49
- ## Seeded Determinism
50
-
51
- Pass a `seed` for reproducible output — same seed always produces the same sequence across all categories. Omit `seed` for cryptographic randomness via `crypto.getRandomValues`.
52
-
53
- ```ts
54
- const a = createIllusion({ seed: 'test-fixture', locale: en });
55
- const b = createIllusion({ seed: 'test-fixture', locale: en });
56
-
57
- a.person.fullName() === b.person.fullName(); // true
58
- ```
59
-
60
- ## Locale Support
61
-
62
- Initial locales are explicit, tree-shakeable objects exported from `@vielzeug/illusionist/locales`. Locale data ships only for locales you import; the root package includes no default locale.
63
-
64
- ```ts
65
- import { de } from '@vielzeug/illusionist/locales';
66
-
67
- const illusion = createIllusion({ seed: 42, locale: de });
68
-
69
- illusion.person.firstName(); // "Mathilda"
70
- illusion.location.city(); // "Bielefeld"
71
- ```
72
-
73
- For dynamic app switching, load the locale before creating the synchronous instance:
74
-
75
- ```ts
76
- const { de } = await import('@vielzeug/illusionist/locales');
77
- const illusion = createIllusion({ locale: de });
78
29
  ```
79
30
 
80
31
  ## Documentation
@@ -83,6 +34,7 @@ const illusion = createIllusion({ locale: de });
83
34
  - [Usage Guide](https://vielzeug.dev/illusionist/usage)
84
35
  - [API Reference](https://vielzeug.dev/illusionist/api)
85
36
  - [Examples](https://vielzeug.dev/illusionist/examples)
37
+ - [Migration Guide](https://vielzeug.dev/illusionist/migration)
86
38
 
87
39
  ## License
88
40
 
@@ -1,2 +1,2 @@
1
- function e(e,t=.5){return(e?.next()??crypto.getRandomValues(new Uint32Array(1))[0]/4294967296)<t}exports.boolean=e;
1
+ let e=require("@vielzeug/arsenal");function t(t,n=.5){return(0,e.randomFloat)(t)<n}exports.boolean=t;
2
2
  //# sourceMappingURL=boolean.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"boolean.cjs","names":[],"sources":["../../src/_helpers/boolean.ts"],"sourcesContent":["import type { RandomSource } from '@vielzeug/arsenal/random';\n\n/** Generates a random boolean with an optional probability bias (0–1, default 0.5). */\nexport function boolean(source?: RandomSource, probability = 0.5): boolean {\n const raw = source?.next() ?? crypto.getRandomValues(new Uint32Array(1))[0]! / 0x100000000;\n\n return raw < probability;\n}\n"],"mappings":"AAGA,SAAgB,EAAQ,EAAuB,EAAc,GAAc,CAGzE,OAFY,GAAQ,KAAK,GAAK,OAAO,gBAAgB,IAAI,YAAY,CAAC,CAAC,CAAC,CAAC,GAAM,YAElE,CACf"}
1
+ {"version":3,"file":"boolean.cjs","names":[],"sources":["../../src/_helpers/boolean.ts"],"sourcesContent":["import type { RandomSource } from '../types';\n\nimport { nextFloat } from './next-float';\n\n/** Generates a random boolean with an optional probability bias (0–1, default 0.5). */\nexport function boolean(source?: RandomSource, probability = 0.5): boolean {\n return nextFloat(source) < probability;\n}\n"],"mappings":"mCAKA,SAAgB,EAAQ,EAAuB,EAAc,GAAc,CACzE,OAAA,EAAO,EAAA,YAAA,CAAU,CAAM,EAAI,CAC7B"}
@@ -1,4 +1,4 @@
1
- import type { RandomSource } from '@vielzeug/arsenal/random';
1
+ import type { RandomSource } from '../types';
2
2
  /** Generates a random boolean with an optional probability bias (0–1, default 0.5). */
3
3
  export declare function boolean(source?: RandomSource, probability?: number): boolean;
4
4
  //# sourceMappingURL=boolean.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"boolean.d.ts","sourceRoot":"","sources":["../../src/_helpers/boolean.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAE7D,uFAAuF;AACvF,wBAAgB,OAAO,CAAC,MAAM,CAAC,EAAE,YAAY,EAAE,WAAW,SAAM,GAAG,OAAO,CAIzE"}
1
+ {"version":3,"file":"boolean.d.ts","sourceRoot":"","sources":["../../src/_helpers/boolean.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAI7C,uFAAuF;AACvF,wBAAgB,OAAO,CAAC,MAAM,CAAC,EAAE,YAAY,EAAE,WAAW,SAAM,GAAG,OAAO,CAEzE"}
@@ -1,8 +1,9 @@
1
+ import { nextFloat as e } from "./next-float.js";
1
2
  //#region src/_helpers/boolean.ts
2
- function e(e, t = .5) {
3
- return (e?.next() ?? crypto.getRandomValues(/* @__PURE__ */ new Uint32Array(1))[0] / 4294967296) < t;
3
+ function t(t, n = .5) {
4
+ return e(t) < n;
4
5
  }
5
6
  //#endregion
6
- export { e as boolean };
7
+ export { t as boolean };
7
8
 
8
9
  //# sourceMappingURL=boolean.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"boolean.js","names":[],"sources":["../../src/_helpers/boolean.ts"],"sourcesContent":["import type { RandomSource } from '@vielzeug/arsenal/random';\n\n/** Generates a random boolean with an optional probability bias (0–1, default 0.5). */\nexport function boolean(source?: RandomSource, probability = 0.5): boolean {\n const raw = source?.next() ?? crypto.getRandomValues(new Uint32Array(1))[0]! / 0x100000000;\n\n return raw < probability;\n}\n"],"mappings":";AAGA,SAAgB,EAAQ,GAAuB,IAAc,IAAc;CAGzE,QAFY,GAAQ,KAAK,KAAK,OAAO,gCAAgB,IAAI,YAAY,CAAC,CAAC,CAAC,CAAC,KAAM,cAElE;AACf"}
1
+ {"version":3,"file":"boolean.js","names":[],"sources":["../../src/_helpers/boolean.ts"],"sourcesContent":["import type { RandomSource } from '../types';\n\nimport { nextFloat } from './next-float';\n\n/** Generates a random boolean with an optional probability bias (0–1, default 0.5). */\nexport function boolean(source?: RandomSource, probability = 0.5): boolean {\n return nextFloat(source) < probability;\n}\n"],"mappings":";;AAKA,SAAgB,EAAQ,GAAuB,IAAc,IAAc;CACzE,OAAO,EAAU,CAAM,IAAI;AAC7B"}
@@ -1,2 +1,2 @@
1
- function e(e,t,n){if(e>t)return e;let r=t-e;return e+(n?.next()??crypto.getRandomValues(new Uint32Array(1))[0]/4294967296)*r}function t(t,n,r=2,i){let a=10**r,o=e(t*a,n*a,i);return Math.round(o)/a}exports.float=e,exports.floatFixed=t;
1
+ let e=require("@vielzeug/arsenal");function t(t,n,r){return t>n?t:t+(0,e.randomFloat)(r)*(n-t)}function n(e,n,r=2,i){let a=10**r,o=t(e*a,n*a,i);return Math.round(o)/a}exports.float=t,exports.floatFixed=n;
2
2
  //# sourceMappingURL=float.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"float.cjs","names":[],"sources":["../../src/_helpers/float.ts"],"sourcesContent":["import type { RandomSource } from '@vielzeug/arsenal/random';\n\n/**\n * Generates a random float in `[min, max)`.\n * Pass `min` = `max` for a constant; the result is still `min` (not `max`).\n */\nexport function float(min: number, max: number, source?: RandomSource): number {\n if (min > max) return min;\n\n const span = max - min;\n const raw = source?.next() ?? crypto.getRandomValues(new Uint32Array(1))[0]! / 0x100000000;\n\n return min + raw * span;\n}\n\n/** Generates a random float with a fixed number of decimal places. */\nexport function floatFixed(min: number, max: number, decimals = 2, source?: RandomSource): number {\n const factor = 10 ** decimals;\n const scaled = float(min * factor, max * factor, source);\n\n return Math.round(scaled) / factor;\n}\n"],"mappings":"AAMA,SAAgB,EAAM,EAAa,EAAa,EAA+B,CAC7E,GAAI,EAAM,EAAK,OAAO,EAEtB,IAAM,EAAO,EAAM,EAGnB,OAAO,GAFK,GAAQ,KAAK,GAAK,OAAO,gBAAgB,IAAI,YAAY,CAAC,CAAC,CAAC,CAAC,GAAM,YAE5D,CACrB,CAGA,SAAgB,EAAW,EAAa,EAAa,EAAW,EAAG,EAA+B,CAChG,IAAM,EAAS,IAAM,EACf,EAAS,EAAM,EAAM,EAAQ,EAAM,EAAQ,CAAM,EAEvD,OAAO,KAAK,MAAM,CAAM,EAAI,CAC9B"}
1
+ {"version":3,"file":"float.cjs","names":[],"sources":["../../src/_helpers/float.ts"],"sourcesContent":["import type { RandomSource } from '../types';\n\nimport { nextFloat } from './next-float';\n\n/**\n * Generates a random float in `[min, max)`.\n * Pass `min` = `max` for a constant; the result is still `min` (not `max`).\n */\nexport function float(min: number, max: number, source?: RandomSource): number {\n if (min > max) return min;\n\n return min + nextFloat(source) * (max - min);\n}\n\n/** Generates a random float with a fixed number of decimal places. */\nexport function floatFixed(min: number, max: number, decimals = 2, source?: RandomSource): number {\n const factor = 10 ** decimals;\n const scaled = float(min * factor, max * factor, source);\n\n return Math.round(scaled) / factor;\n}\n"],"mappings":"mCAQA,SAAgB,EAAM,EAAa,EAAa,EAA+B,CAG7E,OAFI,EAAM,EAAY,EAEf,GAAA,EAAM,EAAA,YAAA,CAAU,CAAM,GAAK,EAAM,EAC1C,CAGA,SAAgB,EAAW,EAAa,EAAa,EAAW,EAAG,EAA+B,CAChG,IAAM,EAAS,IAAM,EACf,EAAS,EAAM,EAAM,EAAQ,EAAM,EAAQ,CAAM,EAEvD,OAAO,KAAK,MAAM,CAAM,EAAI,CAC9B"}
@@ -1,4 +1,4 @@
1
- import type { RandomSource } from '@vielzeug/arsenal/random';
1
+ import type { RandomSource } from '../types';
2
2
  /**
3
3
  * Generates a random float in `[min, max)`.
4
4
  * Pass `min` = `max` for a constant; the result is still `min` (not `max`).
@@ -1 +1 @@
1
- {"version":3,"file":"float.d.ts","sourceRoot":"","sources":["../../src/_helpers/float.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAE7D;;;GAGG;AACH,wBAAgB,KAAK,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,YAAY,GAAG,MAAM,CAO7E;AAED,sEAAsE;AACtE,wBAAgB,UAAU,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,QAAQ,SAAI,EAAE,MAAM,CAAC,EAAE,YAAY,GAAG,MAAM,CAKhG"}
1
+ {"version":3,"file":"float.d.ts","sourceRoot":"","sources":["../../src/_helpers/float.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAI7C;;;GAGG;AACH,wBAAgB,KAAK,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,YAAY,GAAG,MAAM,CAI7E;AAED,sEAAsE;AACtE,wBAAgB,UAAU,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,QAAQ,SAAI,EAAE,MAAM,CAAC,EAAE,YAAY,GAAG,MAAM,CAKhG"}
@@ -1,14 +1,13 @@
1
+ import { nextFloat as e } from "./next-float.js";
1
2
  //#region src/_helpers/float.ts
2
- function e(e, t, n) {
3
- if (e > t) return e;
4
- let r = t - e;
5
- return e + (n?.next() ?? crypto.getRandomValues(/* @__PURE__ */ new Uint32Array(1))[0] / 4294967296) * r;
3
+ function t(t, n, r) {
4
+ return t > n ? t : t + e(r) * (n - t);
6
5
  }
7
- function t(t, n, r = 2, i) {
8
- let a = 10 ** r, o = e(t * a, n * a, i);
6
+ function n(e, n, r = 2, i) {
7
+ let a = 10 ** r, o = t(e * a, n * a, i);
9
8
  return Math.round(o) / a;
10
9
  }
11
10
  //#endregion
12
- export { e as float, t as floatFixed };
11
+ export { t as float, n as floatFixed };
13
12
 
14
13
  //# sourceMappingURL=float.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"float.js","names":[],"sources":["../../src/_helpers/float.ts"],"sourcesContent":["import type { RandomSource } from '@vielzeug/arsenal/random';\n\n/**\n * Generates a random float in `[min, max)`.\n * Pass `min` = `max` for a constant; the result is still `min` (not `max`).\n */\nexport function float(min: number, max: number, source?: RandomSource): number {\n if (min > max) return min;\n\n const span = max - min;\n const raw = source?.next() ?? crypto.getRandomValues(new Uint32Array(1))[0]! / 0x100000000;\n\n return min + raw * span;\n}\n\n/** Generates a random float with a fixed number of decimal places. */\nexport function floatFixed(min: number, max: number, decimals = 2, source?: RandomSource): number {\n const factor = 10 ** decimals;\n const scaled = float(min * factor, max * factor, source);\n\n return Math.round(scaled) / factor;\n}\n"],"mappings":";AAMA,SAAgB,EAAM,GAAa,GAAa,GAA+B;CAC7E,IAAI,IAAM,GAAK,OAAO;CAEtB,IAAM,IAAO,IAAM;CAGnB,OAAO,KAFK,GAAQ,KAAK,KAAK,OAAO,gCAAgB,IAAI,YAAY,CAAC,CAAC,CAAC,CAAC,KAAM,cAE5D;AACrB;AAGA,SAAgB,EAAW,GAAa,GAAa,IAAW,GAAG,GAA+B;CAChG,IAAM,IAAS,MAAM,GACf,IAAS,EAAM,IAAM,GAAQ,IAAM,GAAQ,CAAM;CAEvD,OAAO,KAAK,MAAM,CAAM,IAAI;AAC9B"}
1
+ {"version":3,"file":"float.js","names":[],"sources":["../../src/_helpers/float.ts"],"sourcesContent":["import type { RandomSource } from '../types';\n\nimport { nextFloat } from './next-float';\n\n/**\n * Generates a random float in `[min, max)`.\n * Pass `min` = `max` for a constant; the result is still `min` (not `max`).\n */\nexport function float(min: number, max: number, source?: RandomSource): number {\n if (min > max) return min;\n\n return min + nextFloat(source) * (max - min);\n}\n\n/** Generates a random float with a fixed number of decimal places. */\nexport function floatFixed(min: number, max: number, decimals = 2, source?: RandomSource): number {\n const factor = 10 ** decimals;\n const scaled = float(min * factor, max * factor, source);\n\n return Math.round(scaled) / factor;\n}\n"],"mappings":";;AAQA,SAAgB,EAAM,GAAa,GAAa,GAA+B;CAG7E,OAFI,IAAM,IAAY,IAEf,IAAM,EAAU,CAAM,KAAK,IAAM;AAC1C;AAGA,SAAgB,EAAW,GAAa,GAAa,IAAW,GAAG,GAA+B;CAChG,IAAM,IAAS,MAAM,GACf,IAAS,EAAM,IAAM,GAAQ,IAAM,GAAQ,CAAM;CAEvD,OAAO,KAAK,MAAM,CAAM,IAAI;AAC9B"}
@@ -1,2 +1,2 @@
1
- let e=require("@vielzeug/arsenal/random");function t(t,n,r){return(0,e.random)(t,n,r)}exports.int=t;
1
+ let e=require("@vielzeug/arsenal");function t(t,n,r){return(0,e.random)(t,n,r)}exports.int=t;
2
2
  //# sourceMappingURL=int.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"int.cjs","names":[],"sources":["../../src/_helpers/int.ts"],"sourcesContent":["import type { RandomSource } from '@vielzeug/arsenal/random';\nimport { random } from '@vielzeug/arsenal/random';\n\n/** Generates a random integer in `[min, max]` (inclusive). */\nexport function int(min: number, max: number, source?: RandomSource): number {\n return random(min, max, source);\n}\n"],"mappings":"0CAIA,SAAgB,EAAI,EAAa,EAAa,EAA+B,CAC3E,OAAA,EAAO,EAAA,OAAA,CAAO,EAAK,EAAK,CAAM,CAChC"}
1
+ {"version":3,"file":"int.cjs","names":[],"sources":["../../src/_helpers/int.ts"],"sourcesContent":["import { random } from '@vielzeug/arsenal';\n\nimport type { RandomSource } from '../types';\n\n/** Generates a random integer in `[min, max]` (inclusive). */\nexport function int(min: number, max: number, source?: RandomSource): number {\n return random(min, max, source);\n}\n"],"mappings":"mCAKA,SAAgB,EAAI,EAAa,EAAa,EAA+B,CAC3E,OAAA,EAAO,EAAA,OAAA,CAAO,EAAK,EAAK,CAAM,CAChC"}
@@ -1,4 +1,4 @@
1
- import type { RandomSource } from '@vielzeug/arsenal/random';
1
+ import type { RandomSource } from '../types';
2
2
  /** Generates a random integer in `[min, max]` (inclusive). */
3
3
  export declare function int(min: number, max: number, source?: RandomSource): number;
4
4
  //# sourceMappingURL=int.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"int.d.ts","sourceRoot":"","sources":["../../src/_helpers/int.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAG7D,8DAA8D;AAC9D,wBAAgB,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,YAAY,GAAG,MAAM,CAE3E"}
1
+ {"version":3,"file":"int.d.ts","sourceRoot":"","sources":["../../src/_helpers/int.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAE7C,8DAA8D;AAC9D,wBAAgB,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,YAAY,GAAG,MAAM,CAE3E"}
@@ -1,4 +1,4 @@
1
- import { random as e } from "@vielzeug/arsenal/random";
1
+ import { random as e } from "@vielzeug/arsenal";
2
2
  //#region src/_helpers/int.ts
3
3
  function t(t, n, r) {
4
4
  return e(t, n, r);
@@ -1 +1 @@
1
- {"version":3,"file":"int.js","names":[],"sources":["../../src/_helpers/int.ts"],"sourcesContent":["import type { RandomSource } from '@vielzeug/arsenal/random';\nimport { random } from '@vielzeug/arsenal/random';\n\n/** Generates a random integer in `[min, max]` (inclusive). */\nexport function int(min: number, max: number, source?: RandomSource): number {\n return random(min, max, source);\n}\n"],"mappings":";;AAIA,SAAgB,EAAI,GAAa,GAAa,GAA+B;CAC3E,OAAO,EAAO,GAAK,GAAK,CAAM;AAChC"}
1
+ {"version":3,"file":"int.js","names":[],"sources":["../../src/_helpers/int.ts"],"sourcesContent":["import { random } from '@vielzeug/arsenal';\n\nimport type { RandomSource } from '../types';\n\n/** Generates a random integer in `[min, max]` (inclusive). */\nexport function int(min: number, max: number, source?: RandomSource): number {\n return random(min, max, source);\n}\n"],"mappings":";;AAKA,SAAgB,EAAI,GAAa,GAAa,GAA+B;CAC3E,OAAO,EAAO,GAAK,GAAK,CAAM;AAChC"}
@@ -0,0 +1,2 @@
1
+ export { randomFloat as nextFloat } from '@vielzeug/arsenal';
2
+ //# sourceMappingURL=next-float.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"next-float.d.ts","sourceRoot":"","sources":["../../src/_helpers/next-float.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,IAAI,SAAS,EAAE,MAAM,mBAAmB,CAAC"}
@@ -0,0 +1,2 @@
1
+ import { randomFloat as e } from "@vielzeug/arsenal";
2
+ export { e as nextFloat };
@@ -1,2 +1,2 @@
1
- let e=require("@vielzeug/arsenal/random");function t(t,n){return(0,e.draw)([...t],n)}function n(e,t){let n=``;for(let r=0;r<e;r++)n+=Math.floor((t?.next()??crypto.getRandomValues(new Uint32Array(1))[0]/4294967296)*10);return n}function r(e,t){let n=``;for(let r=0;r<e;r++){let e=Math.floor((t?.next()??crypto.getRandomValues(new Uint32Array(1))[0]/4294967296)*16);n+=`0123456789abcdef`[e]}return n}function i(e,t){let n=``;for(let r=0;r<e;r++){let e=Math.floor((t?.next()??crypto.getRandomValues(new Uint32Array(1))[0]/4294967296)*62);n+=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789`[e]}return n}function a(e,t){let n=``;for(let r=0;r<e;r++){let e=Math.floor((t?.next()??crypto.getRandomValues(new Uint32Array(1))[0]/4294967296)*58);n+=`123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz`[e]}return n}exports.alphanumeric=i,exports.base58String=a,exports.hexString=r,exports.numericString=n,exports.pick=t;
1
+ let e=require("@vielzeug/arsenal");function t(t,n){return t.length===0?void 0:t[Math.floor((0,e.randomFloat)(n)*t.length)]}function n(t,n){let r=``;for(let i=0;i<t;i++)r+=Math.floor((0,e.randomFloat)(n)*10);return r}function r(t,n){let r=``;for(let i=0;i<t;i++)r+=`0123456789abcdef`[Math.floor((0,e.randomFloat)(n)*16)];return r}function i(t,n){let r=``;for(let i=0;i<t;i++)r+=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789`[Math.floor((0,e.randomFloat)(n)*62)];return r}function a(t,n){let r=``;for(let i=0;i<t;i++)r+=`123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz`[Math.floor((0,e.randomFloat)(n)*58)];return r}exports.alphanumeric=i,exports.base58String=a,exports.hexString=r,exports.numericString=n,exports.pick=t;
2
2
  //# sourceMappingURL=string.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"string.cjs","names":[],"sources":["../../src/_helpers/string.ts"],"sourcesContent":["import type { RandomSource } from '@vielzeug/arsenal/random';\nimport { draw } from '@vielzeug/arsenal/random';\n\n/** Picks a random element from an array. Returns `undefined` for empty arrays. */\nexport function pick<T>(array: readonly T[], source?: RandomSource): T | undefined {\n return draw([...array], source);\n}\n\n/** Generates a string of random digits with a fixed length. */\nexport function numericString(length: number, source?: RandomSource): string {\n let result = '';\n\n for (let i = 0; i < length; i++) {\n result += Math.floor((source?.next() ?? crypto.getRandomValues(new Uint32Array(1))[0]! / 0x100000000) * 10);\n }\n\n return result;\n}\n\n/** Generates a random hex string of the given length. */\nexport function hexString(length: number, source?: RandomSource): string {\n const chars = '0123456789abcdef';\n let result = '';\n\n for (let i = 0; i < length; i++) {\n const idx = Math.floor((source?.next() ?? crypto.getRandomValues(new Uint32Array(1))[0]! / 0x100000000) * 16);\n\n result += chars[idx];\n }\n\n return result;\n}\n\n/** Generates a random alphanumeric string of the given length. */\nexport function alphanumeric(length: number, source?: RandomSource): string {\n const chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';\n let result = '';\n\n for (let i = 0; i < length; i++) {\n const idx = Math.floor(\n (source?.next() ?? crypto.getRandomValues(new Uint32Array(1))[0]! / 0x100000000) * chars.length,\n );\n\n result += chars[idx];\n }\n\n return result;\n}\n\n/** Generates a random Base58 string (no 0, O, I, l) — used for Bitcoin-style addresses. */\nexport function base58String(length: number, source?: RandomSource): string {\n const chars = '123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz';\n let result = '';\n\n for (let i = 0; i < length; i++) {\n const idx = Math.floor(\n (source?.next() ?? crypto.getRandomValues(new Uint32Array(1))[0]! / 0x100000000) * chars.length,\n );\n\n result += chars[idx];\n }\n\n return result;\n}\n"],"mappings":"0CAIA,SAAgB,EAAQ,EAAqB,EAAsC,CACjF,OAAA,EAAO,EAAA,KAAA,CAAK,CAAC,GAAG,CAAK,EAAG,CAAM,CAChC,CAGA,SAAgB,EAAc,EAAgB,EAA+B,CAC3E,IAAI,EAAS,GAEb,IAAK,IAAI,EAAI,EAAG,EAAI,EAAQ,IAC1B,GAAU,KAAK,OAAO,GAAQ,KAAK,GAAK,OAAO,gBAAgB,IAAI,YAAY,CAAC,CAAC,CAAC,CAAC,GAAM,YAAe,EAAE,EAG5G,OAAO,CACT,CAGA,SAAgB,EAAU,EAAgB,EAA+B,CACvE,IACI,EAAS,GAEb,IAAK,IAAI,EAAI,EAAG,EAAI,EAAQ,IAAK,CAC/B,IAAM,EAAM,KAAK,OAAO,GAAQ,KAAK,GAAK,OAAO,gBAAgB,IAAI,YAAY,CAAC,CAAC,CAAC,CAAC,GAAM,YAAe,EAAE,EAE5G,GAAU,mBAAM,EAClB,CAEA,OAAO,CACT,CAGA,SAAgB,EAAa,EAAgB,EAA+B,CAC1E,IACI,EAAS,GAEb,IAAK,IAAI,EAAI,EAAG,EAAI,EAAQ,IAAK,CAC/B,IAAM,EAAM,KAAK,OACd,GAAQ,KAAK,GAAK,OAAO,gBAAgB,IAAI,YAAY,CAAC,CAAC,CAAC,CAAC,GAAM,YAAe,EACrF,EAEA,GAAU,iEAAM,EAClB,CAEA,OAAO,CACT,CAGA,SAAgB,EAAa,EAAgB,EAA+B,CAC1E,IACI,EAAS,GAEb,IAAK,IAAI,EAAI,EAAG,EAAI,EAAQ,IAAK,CAC/B,IAAM,EAAM,KAAK,OACd,GAAQ,KAAK,GAAK,OAAO,gBAAgB,IAAI,YAAY,CAAC,CAAC,CAAC,CAAC,GAAM,YAAe,EACrF,EAEA,GAAU,6DAAM,EAClB,CAEA,OAAO,CACT"}
1
+ {"version":3,"file":"string.cjs","names":[],"sources":["../../src/_helpers/string.ts"],"sourcesContent":["import type { RandomSource } from '../types';\n\nimport { nextFloat } from './next-float';\n\n/** Picks a random element from a readonly array. Returns `undefined` for empty arrays. */\nexport function pick<T>(array: readonly T[], source?: RandomSource): T | undefined {\n return array.length === 0 ? undefined : array[Math.floor(nextFloat(source) * array.length)];\n}\n\n/** Generates a string of random digits with a fixed length. */\nexport function numericString(length: number, source?: RandomSource): string {\n let result = '';\n\n for (let i = 0; i < length; i++) {\n result += Math.floor(nextFloat(source) * 10);\n }\n\n return result;\n}\n\n/** Generates a random hex string of the given length. */\nexport function hexString(length: number, source?: RandomSource): string {\n const chars = '0123456789abcdef';\n let result = '';\n\n for (let i = 0; i < length; i++) {\n result += chars[Math.floor(nextFloat(source) * 16)];\n }\n\n return result;\n}\n\n/** Generates a random alphanumeric string of the given length. */\nexport function alphanumeric(length: number, source?: RandomSource): string {\n const chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';\n let result = '';\n\n for (let i = 0; i < length; i++) {\n result += chars[Math.floor(nextFloat(source) * chars.length)];\n }\n\n return result;\n}\n\n/** Generates a random Base58 string (no 0, O, I, l) — used for Bitcoin-style addresses. */\nexport function base58String(length: number, source?: RandomSource): string {\n const chars = '123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz';\n let result = '';\n\n for (let i = 0; i < length; i++) {\n result += chars[Math.floor(nextFloat(source) * chars.length)];\n }\n\n return result;\n}\n"],"mappings":"mCAKA,SAAgB,EAAQ,EAAqB,EAAsC,CACjF,OAAO,EAAM,SAAW,EAAI,IAAA,GAAY,EAAM,KAAK,OAAA,EAAM,EAAA,YAAA,CAAU,CAAM,EAAI,EAAM,MAAM,EAC3F,CAGA,SAAgB,EAAc,EAAgB,EAA+B,CAC3E,IAAI,EAAS,GAEb,IAAK,IAAI,EAAI,EAAG,EAAI,EAAQ,IAC1B,GAAU,KAAK,OAAA,EAAM,EAAA,YAAA,CAAU,CAAM,EAAI,EAAE,EAG7C,OAAO,CACT,CAGA,SAAgB,EAAU,EAAgB,EAA+B,CACvE,IACI,EAAS,GAEb,IAAK,IAAI,EAAI,EAAG,EAAI,EAAQ,IAC1B,GAAU,mBAAM,KAAK,OAAA,EAAM,EAAA,YAAA,CAAU,CAAM,EAAI,EAAE,GAGnD,OAAO,CACT,CAGA,SAAgB,EAAa,EAAgB,EAA+B,CAC1E,IACI,EAAS,GAEb,IAAK,IAAI,EAAI,EAAG,EAAI,EAAQ,IAC1B,GAAU,iEAAM,KAAK,OAAA,EAAM,EAAA,YAAA,CAAU,CAAM,EAAI,EAAY,GAG7D,OAAO,CACT,CAGA,SAAgB,EAAa,EAAgB,EAA+B,CAC1E,IACI,EAAS,GAEb,IAAK,IAAI,EAAI,EAAG,EAAI,EAAQ,IAC1B,GAAU,6DAAM,KAAK,OAAA,EAAM,EAAA,YAAA,CAAU,CAAM,EAAI,EAAY,GAG7D,OAAO,CACT"}
@@ -1,5 +1,5 @@
1
- import type { RandomSource } from '@vielzeug/arsenal/random';
2
- /** Picks a random element from an array. Returns `undefined` for empty arrays. */
1
+ import type { RandomSource } from '../types';
2
+ /** Picks a random element from a readonly array. Returns `undefined` for empty arrays. */
3
3
  export declare function pick<T>(array: readonly T[], source?: RandomSource): T | undefined;
4
4
  /** Generates a string of random digits with a fixed length. */
5
5
  export declare function numericString(length: number, source?: RandomSource): string;
@@ -1 +1 @@
1
- {"version":3,"file":"string.d.ts","sourceRoot":"","sources":["../../src/_helpers/string.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAG7D,kFAAkF;AAClF,wBAAgB,IAAI,CAAC,CAAC,EAAE,KAAK,EAAE,SAAS,CAAC,EAAE,EAAE,MAAM,CAAC,EAAE,YAAY,GAAG,CAAC,GAAG,SAAS,CAEjF;AAED,+DAA+D;AAC/D,wBAAgB,aAAa,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,YAAY,GAAG,MAAM,CAQ3E;AAED,yDAAyD;AACzD,wBAAgB,SAAS,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,YAAY,GAAG,MAAM,CAWvE;AAED,kEAAkE;AAClE,wBAAgB,YAAY,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,YAAY,GAAG,MAAM,CAa1E;AAED,2FAA2F;AAC3F,wBAAgB,YAAY,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,YAAY,GAAG,MAAM,CAa1E"}
1
+ {"version":3,"file":"string.d.ts","sourceRoot":"","sources":["../../src/_helpers/string.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAI7C,0FAA0F;AAC1F,wBAAgB,IAAI,CAAC,CAAC,EAAE,KAAK,EAAE,SAAS,CAAC,EAAE,EAAE,MAAM,CAAC,EAAE,YAAY,GAAG,CAAC,GAAG,SAAS,CAEjF;AAED,+DAA+D;AAC/D,wBAAgB,aAAa,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,YAAY,GAAG,MAAM,CAQ3E;AAED,yDAAyD;AACzD,wBAAgB,SAAS,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,YAAY,GAAG,MAAM,CASvE;AAED,kEAAkE;AAClE,wBAAgB,YAAY,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,YAAY,GAAG,MAAM,CAS1E;AAED,2FAA2F;AAC3F,wBAAgB,YAAY,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,YAAY,GAAG,MAAM,CAS1E"}
@@ -1,36 +1,27 @@
1
- import { draw as e } from "@vielzeug/arsenal/random";
1
+ import { nextFloat as e } from "./next-float.js";
2
2
  //#region src/_helpers/string.ts
3
3
  function t(t, n) {
4
- return e([...t], n);
4
+ return t.length === 0 ? void 0 : t[Math.floor(e(n) * t.length)];
5
5
  }
6
- function n(e, t) {
7
- let n = "";
8
- for (let r = 0; r < e; r++) n += Math.floor((t?.next() ?? crypto.getRandomValues(/* @__PURE__ */ new Uint32Array(1))[0] / 4294967296) * 10);
9
- return n;
6
+ function n(t, n) {
7
+ let r = "";
8
+ for (let i = 0; i < t; i++) r += Math.floor(e(n) * 10);
9
+ return r;
10
10
  }
11
- function r(e, t) {
12
- let n = "";
13
- for (let r = 0; r < e; r++) {
14
- let e = Math.floor((t?.next() ?? crypto.getRandomValues(/* @__PURE__ */ new Uint32Array(1))[0] / 4294967296) * 16);
15
- n += "0123456789abcdef"[e];
16
- }
17
- return n;
11
+ function r(t, n) {
12
+ let r = "";
13
+ for (let i = 0; i < t; i++) r += "0123456789abcdef"[Math.floor(e(n) * 16)];
14
+ return r;
18
15
  }
19
- function i(e, t) {
20
- let n = "";
21
- for (let r = 0; r < e; r++) {
22
- let e = Math.floor((t?.next() ?? crypto.getRandomValues(/* @__PURE__ */ new Uint32Array(1))[0] / 4294967296) * 62);
23
- n += "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"[e];
24
- }
25
- return n;
16
+ function i(t, n) {
17
+ let r = "";
18
+ for (let i = 0; i < t; i++) r += "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"[Math.floor(e(n) * 62)];
19
+ return r;
26
20
  }
27
- function a(e, t) {
28
- let n = "";
29
- for (let r = 0; r < e; r++) {
30
- let e = Math.floor((t?.next() ?? crypto.getRandomValues(/* @__PURE__ */ new Uint32Array(1))[0] / 4294967296) * 58);
31
- n += "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"[e];
32
- }
33
- return n;
21
+ function a(t, n) {
22
+ let r = "";
23
+ for (let i = 0; i < t; i++) r += "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"[Math.floor(e(n) * 58)];
24
+ return r;
34
25
  }
35
26
  //#endregion
36
27
  export { i as alphanumeric, a as base58String, r as hexString, n as numericString, t as pick };
@@ -1 +1 @@
1
- {"version":3,"file":"string.js","names":[],"sources":["../../src/_helpers/string.ts"],"sourcesContent":["import type { RandomSource } from '@vielzeug/arsenal/random';\nimport { draw } from '@vielzeug/arsenal/random';\n\n/** Picks a random element from an array. Returns `undefined` for empty arrays. */\nexport function pick<T>(array: readonly T[], source?: RandomSource): T | undefined {\n return draw([...array], source);\n}\n\n/** Generates a string of random digits with a fixed length. */\nexport function numericString(length: number, source?: RandomSource): string {\n let result = '';\n\n for (let i = 0; i < length; i++) {\n result += Math.floor((source?.next() ?? crypto.getRandomValues(new Uint32Array(1))[0]! / 0x100000000) * 10);\n }\n\n return result;\n}\n\n/** Generates a random hex string of the given length. */\nexport function hexString(length: number, source?: RandomSource): string {\n const chars = '0123456789abcdef';\n let result = '';\n\n for (let i = 0; i < length; i++) {\n const idx = Math.floor((source?.next() ?? crypto.getRandomValues(new Uint32Array(1))[0]! / 0x100000000) * 16);\n\n result += chars[idx];\n }\n\n return result;\n}\n\n/** Generates a random alphanumeric string of the given length. */\nexport function alphanumeric(length: number, source?: RandomSource): string {\n const chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';\n let result = '';\n\n for (let i = 0; i < length; i++) {\n const idx = Math.floor(\n (source?.next() ?? crypto.getRandomValues(new Uint32Array(1))[0]! / 0x100000000) * chars.length,\n );\n\n result += chars[idx];\n }\n\n return result;\n}\n\n/** Generates a random Base58 string (no 0, O, I, l) — used for Bitcoin-style addresses. */\nexport function base58String(length: number, source?: RandomSource): string {\n const chars = '123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz';\n let result = '';\n\n for (let i = 0; i < length; i++) {\n const idx = Math.floor(\n (source?.next() ?? crypto.getRandomValues(new Uint32Array(1))[0]! / 0x100000000) * chars.length,\n );\n\n result += chars[idx];\n }\n\n return result;\n}\n"],"mappings":";;AAIA,SAAgB,EAAQ,GAAqB,GAAsC;CACjF,OAAO,EAAK,CAAC,GAAG,CAAK,GAAG,CAAM;AAChC;AAGA,SAAgB,EAAc,GAAgB,GAA+B;CAC3E,IAAI,IAAS;CAEb,KAAK,IAAI,IAAI,GAAG,IAAI,GAAQ,KAC1B,KAAU,KAAK,OAAO,GAAQ,KAAK,KAAK,OAAO,gCAAgB,IAAI,YAAY,CAAC,CAAC,CAAC,CAAC,KAAM,cAAe,EAAE;CAG5G,OAAO;AACT;AAGA,SAAgB,EAAU,GAAgB,GAA+B;CACvE,IACI,IAAS;CAEb,KAAK,IAAI,IAAI,GAAG,IAAI,GAAQ,KAAK;EAC/B,IAAM,IAAM,KAAK,OAAO,GAAQ,KAAK,KAAK,OAAO,gCAAgB,IAAI,YAAY,CAAC,CAAC,CAAC,CAAC,KAAM,cAAe,EAAE;EAE5G,KAAU,mBAAM;CAClB;CAEA,OAAO;AACT;AAGA,SAAgB,EAAa,GAAgB,GAA+B;CAC1E,IACI,IAAS;CAEb,KAAK,IAAI,IAAI,GAAG,IAAI,GAAQ,KAAK;EAC/B,IAAM,IAAM,KAAK,OACd,GAAQ,KAAK,KAAK,OAAO,gCAAgB,IAAI,YAAY,CAAC,CAAC,CAAC,CAAC,KAAM,cAAe,EACrF;EAEA,KAAU,iEAAM;CAClB;CAEA,OAAO;AACT;AAGA,SAAgB,EAAa,GAAgB,GAA+B;CAC1E,IACI,IAAS;CAEb,KAAK,IAAI,IAAI,GAAG,IAAI,GAAQ,KAAK;EAC/B,IAAM,IAAM,KAAK,OACd,GAAQ,KAAK,KAAK,OAAO,gCAAgB,IAAI,YAAY,CAAC,CAAC,CAAC,CAAC,KAAM,cAAe,EACrF;EAEA,KAAU,6DAAM;CAClB;CAEA,OAAO;AACT"}
1
+ {"version":3,"file":"string.js","names":[],"sources":["../../src/_helpers/string.ts"],"sourcesContent":["import type { RandomSource } from '../types';\n\nimport { nextFloat } from './next-float';\n\n/** Picks a random element from a readonly array. Returns `undefined` for empty arrays. */\nexport function pick<T>(array: readonly T[], source?: RandomSource): T | undefined {\n return array.length === 0 ? undefined : array[Math.floor(nextFloat(source) * array.length)];\n}\n\n/** Generates a string of random digits with a fixed length. */\nexport function numericString(length: number, source?: RandomSource): string {\n let result = '';\n\n for (let i = 0; i < length; i++) {\n result += Math.floor(nextFloat(source) * 10);\n }\n\n return result;\n}\n\n/** Generates a random hex string of the given length. */\nexport function hexString(length: number, source?: RandomSource): string {\n const chars = '0123456789abcdef';\n let result = '';\n\n for (let i = 0; i < length; i++) {\n result += chars[Math.floor(nextFloat(source) * 16)];\n }\n\n return result;\n}\n\n/** Generates a random alphanumeric string of the given length. */\nexport function alphanumeric(length: number, source?: RandomSource): string {\n const chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';\n let result = '';\n\n for (let i = 0; i < length; i++) {\n result += chars[Math.floor(nextFloat(source) * chars.length)];\n }\n\n return result;\n}\n\n/** Generates a random Base58 string (no 0, O, I, l) — used for Bitcoin-style addresses. */\nexport function base58String(length: number, source?: RandomSource): string {\n const chars = '123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz';\n let result = '';\n\n for (let i = 0; i < length; i++) {\n result += chars[Math.floor(nextFloat(source) * chars.length)];\n }\n\n return result;\n}\n"],"mappings":";;AAKA,SAAgB,EAAQ,GAAqB,GAAsC;CACjF,OAAO,EAAM,WAAW,IAAI,KAAA,IAAY,EAAM,KAAK,MAAM,EAAU,CAAM,IAAI,EAAM,MAAM;AAC3F;AAGA,SAAgB,EAAc,GAAgB,GAA+B;CAC3E,IAAI,IAAS;CAEb,KAAK,IAAI,IAAI,GAAG,IAAI,GAAQ,KAC1B,KAAU,KAAK,MAAM,EAAU,CAAM,IAAI,EAAE;CAG7C,OAAO;AACT;AAGA,SAAgB,EAAU,GAAgB,GAA+B;CACvE,IACI,IAAS;CAEb,KAAK,IAAI,IAAI,GAAG,IAAI,GAAQ,KAC1B,KAAU,mBAAM,KAAK,MAAM,EAAU,CAAM,IAAI,EAAE;CAGnD,OAAO;AACT;AAGA,SAAgB,EAAa,GAAgB,GAA+B;CAC1E,IACI,IAAS;CAEb,KAAK,IAAI,IAAI,GAAG,IAAI,GAAQ,KAC1B,KAAU,iEAAM,KAAK,MAAM,EAAU,CAAM,IAAI,EAAY;CAG7D,OAAO;AACT;AAGA,SAAgB,EAAa,GAAgB,GAA+B;CAC1E,IACI,IAAS;CAEb,KAAK,IAAI,IAAI,GAAG,IAAI,GAAQ,KAC1B,KAAU,6DAAM,KAAK,MAAM,EAAU,CAAM,IAAI,EAAY;CAG7D,OAAO;AACT"}
@@ -1,2 +1,2 @@
1
- const e=require("../_virtual/_rolldown/runtime.cjs"),t=require("../_helpers/int.cjs");let n=require("@vielzeug/tempo");var r=e.__exportAll({between:()=>c,birthday:()=>l,future:()=>o,month:()=>d,past:()=>a,recent:()=>s,weekday:()=>u});function i(e){return e??n.Temporal.Now.zonedDateTimeISO(`UTC`)}function a(e,r){let a=i(r?.ref),o=(r?.years??1)*365*24*60*60;return(0,n.shift)(a,{seconds:-t.int(1,o,e.source)})}function o(e,r){let a=i(r?.ref),o=(r?.years??1)*365*24*60*60;return(0,n.shift)(a,{seconds:t.int(1,o,e.source)})}function s(e,r){let a=i(r?.ref),o=(r?.days??1)*24*60*60;return(0,n.shift)(a,{seconds:-t.int(1,o,e.source)})}function c(e,t,n){let r=t.toInstant().epochNanoseconds,i=n.toInstant().epochNanoseconds;if(r>i)return t;let a=i-r,o=Number(a/1000000000n),s=Math.floor(e.source.next()*o);return t.add({seconds:s})}function l(e,n){let r=i(n?.ref),a=n?.minAge??18,o=n?.maxAge??80,s=t.int(a,o,e.source),c=t.int(1,12,e.source),l=t.int(1,28,e.source);return r.toPlainDate().subtract({years:s}).with({day:l,month:c})}function u(e,n){return((n??e.locale.code)===`de`?[`Montag`,`Dienstag`,`Mittwoch`,`Donnerstag`,`Freitag`,`Samstag`,`Sonntag`]:[`Monday`,`Tuesday`,`Wednesday`,`Thursday`,`Friday`,`Saturday`,`Sunday`])[t.int(0,6,e.source)]}function d(e,n){return((n??e.locale.code)===`de`?[`Januar`,`Februar`,`März`,`April`,`Mai`,`Juni`,`Juli`,`August`,`September`,`Oktober`,`November`,`Dezember`]:[`January`,`February`,`March`,`April`,`May`,`June`,`July`,`August`,`September`,`October`,`November`,`December`])[t.int(0,11,e.source)]}exports.between=c,exports.birthday=l,Object.defineProperty(exports,"date_exports",{enumerable:!0,get:function(){return r}}),exports.future=o,exports.month=d,exports.past=a,exports.recent=s,exports.weekday=u;
1
+ const e=require("../_virtual/_rolldown/runtime.cjs"),t=require("../_helpers/int.cjs");let n=require("@vielzeug/tempo");var r=e.__exportAll({between:()=>c,birthday:()=>l,future:()=>o,month:()=>d,past:()=>a,recent:()=>s,weekday:()=>u});function i(e){return e??n.Temporal.Now.zonedDateTimeISO(`UTC`)}function a(e,n){let r=i(n?.ref),a=(n?.years??1)*365*24*60*60;return r.add({seconds:-t.int(1,a,e.source)})}function o(e,n){let r=i(n?.ref),a=(n?.years??1)*365*24*60*60;return r.add({seconds:t.int(1,a,e.source)})}function s(e,n){let r=i(n?.ref),a=(n?.days??1)*24*60*60;return r.add({seconds:-t.int(1,a,e.source)})}function c(e,t,n){let r=t.toInstant().epochNanoseconds,i=n.toInstant().epochNanoseconds;if(r>i)return t;let a=i-r,o=Number(a/1000000000n),s=Math.floor(e.source.next()*o);return t.add({seconds:s})}function l(e,n){let r=i(n?.ref),a=n?.minAge??18,o=n?.maxAge??80,s=t.int(a,o,e.source),c=t.int(1,12,e.source),l=t.int(1,28,e.source);return r.toPlainDate().subtract({years:s}).with({day:l,month:c})}function u(e,n){return((n??e.locale.code)===`de`?[`Montag`,`Dienstag`,`Mittwoch`,`Donnerstag`,`Freitag`,`Samstag`,`Sonntag`]:[`Monday`,`Tuesday`,`Wednesday`,`Thursday`,`Friday`,`Saturday`,`Sunday`])[t.int(0,6,e.source)]}function d(e,n){return((n??e.locale.code)===`de`?[`Januar`,`Februar`,`März`,`April`,`Mai`,`Juni`,`Juli`,`August`,`September`,`Oktober`,`November`,`Dezember`]:[`January`,`February`,`March`,`April`,`May`,`June`,`July`,`August`,`September`,`October`,`November`,`December`])[t.int(0,11,e.source)]}exports.between=c,exports.birthday=l,Object.defineProperty(exports,"date_exports",{enumerable:!0,get:function(){return r}}),exports.future=o,exports.month=d,exports.past=a,exports.recent=s,exports.weekday=u;
2
2
  //# sourceMappingURL=date.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"date.cjs","names":[],"sources":["../../src/date/date.ts"],"sourcesContent":["import { shift, Temporal } from '@vielzeug/tempo';\n\nimport { int } from '../_helpers/int';\nimport type { IllusionistContext } from '../types';\n\ntype DateOptions = {\n years?: number;\n ref?: Temporal.ZonedDateTime;\n};\n\nfunction resolveRef(ref?: Temporal.ZonedDateTime): Temporal.ZonedDateTime {\n return ref ?? Temporal.Now.zonedDateTimeISO('UTC');\n}\n\n/**\n * Generates a past date within the given number of years from `ref` (default: now).\n */\nexport function past(ctx: IllusionistContext, options?: DateOptions): Temporal.ZonedDateTime {\n const ref = resolveRef(options?.ref);\n const years = options?.years ?? 1;\n const maxSeconds = years * 365 * 24 * 60 * 60;\n const minSeconds = 1;\n\n return shift(ref, { seconds: -int(minSeconds, maxSeconds, ctx.source) });\n}\n\n/**\n * Generates a future date within the given number of years from `ref` (default: now).\n */\nexport function future(ctx: IllusionistContext, options?: DateOptions): Temporal.ZonedDateTime {\n const ref = resolveRef(options?.ref);\n const years = options?.years ?? 1;\n const maxSeconds = years * 365 * 24 * 60 * 60;\n\n return shift(ref, { seconds: int(1, maxSeconds, ctx.source) });\n}\n\n/**\n * Generates a recent date within the given number of days from `ref` (default: now).\n */\nexport function recent(\n ctx: IllusionistContext,\n options?: { days?: number; ref?: Temporal.ZonedDateTime },\n): Temporal.ZonedDateTime {\n const ref = resolveRef(options?.ref);\n const days = options?.days ?? 1;\n const maxSeconds = days * 24 * 60 * 60;\n\n return shift(ref, { seconds: -int(1, maxSeconds, ctx.source) });\n}\n\n/**\n * Generates a date between `from` and `to`.\n */\nexport function between(\n ctx: IllusionistContext,\n from: Temporal.ZonedDateTime,\n to: Temporal.ZonedDateTime,\n): Temporal.ZonedDateTime {\n const fromNs = from.toInstant().epochNanoseconds;\n const toNs = to.toInstant().epochNanoseconds;\n\n if (fromNs > toNs) {\n return from;\n }\n\n const spanNs = toNs - fromNs;\n const spanSeconds = Number(spanNs / 1_000_000_000n);\n const offsetSeconds = Math.floor(ctx.source.next() * spanSeconds);\n\n return from.add({ seconds: offsetSeconds });\n}\n\n/**\n * Generates a random birthday — a date with a random year (default 18-80 years ago) and random month/day.\n */\nexport function birthday(\n ctx: IllusionistContext,\n options?: { minAge?: number; maxAge?: number; ref?: Temporal.ZonedDateTime },\n): Temporal.PlainDate {\n const ref = resolveRef(options?.ref);\n const minAge = options?.minAge ?? 18;\n const maxAge = options?.maxAge ?? 80;\n const age = int(minAge, maxAge, ctx.source);\n const month = int(1, 12, ctx.source);\n const day = int(1, 28, ctx.source);\n\n return ref.toPlainDate().subtract({ years: age }).with({ day, month });\n}\n\n/**\n * Returns a random weekday name.\n */\nexport function weekday(ctx: IllusionistContext, locale?: string): string {\n const days = ['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday'];\n const loc = locale ?? ctx.locale.code;\n const localized =\n loc === 'de' ? ['Montag', 'Dienstag', 'Mittwoch', 'Donnerstag', 'Freitag', 'Samstag', 'Sonntag'] : days;\n\n return localized[int(0, 6, ctx.source)]!;\n}\n\n/**\n * Returns a random month name.\n */\nexport function month(ctx: IllusionistContext, locale?: string): string {\n const months = [\n 'January',\n 'February',\n 'March',\n 'April',\n 'May',\n 'June',\n 'July',\n 'August',\n 'September',\n 'October',\n 'November',\n 'December',\n ];\n const loc = locale ?? ctx.locale.code;\n const localized =\n loc === 'de'\n ? [\n 'Januar',\n 'Februar',\n 'März',\n 'April',\n 'Mai',\n 'Juni',\n 'Juli',\n 'August',\n 'September',\n 'Oktober',\n 'November',\n 'Dezember',\n ]\n : months;\n\n return localized[int(0, 11, ctx.source)]!;\n}\n"],"mappings":"0OAUA,SAAS,EAAW,EAAsD,CACxE,OAAO,GAAO,EAAA,SAAS,IAAI,iBAAiB,KAAK,CACnD,CAKA,SAAgB,EAAK,EAAyB,EAA+C,CAC3F,IAAM,EAAM,EAAW,GAAS,GAAG,EAE7B,GADQ,GAAS,OAAS,GACL,IAAM,GAAK,GAAK,GAG3C,OAAA,EAAO,EAAA,MAAA,CAAM,EAAK,CAAE,QAAS,CAAC,EAAA,IAAI,EAAY,EAAY,EAAI,MAAM,CAAE,CAAC,CACzE,CAKA,SAAgB,EAAO,EAAyB,EAA+C,CAC7F,IAAM,EAAM,EAAW,GAAS,GAAG,EAE7B,GADQ,GAAS,OAAS,GACL,IAAM,GAAK,GAAK,GAE3C,OAAA,EAAO,EAAA,MAAA,CAAM,EAAK,CAAE,QAAS,EAAA,IAAI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yB,CAkCtE,QAnBY,GAAU,EAAI,OAAO,QAEvB,KACJ,CACE,SACA,UACA,OACA,QACA,MACA,OACA,OACA,SACA,YACA,UACA,WACA,UACF,EACA,CA9BJ,UACA,WACA,QACA,QACA,MACA,OACA,OACA,SACA,YACA,UACA,WACA,UAmBI,EAAA,CAEW,EAAA,IAAI,EAAG,GAAI,EAAI,MAAM,EACxC"}
1
+ {"version":3,"file":"date.cjs","names":[],"sources":["../../src/date/date.ts"],"sourcesContent":["import { Temporal } from '@vielzeug/tempo';\n\nimport { int } from '../_helpers/int';\nimport type { IllusionistContext } from '../types';\n\ntype DateOptions = {\n years?: number;\n ref?: Temporal.ZonedDateTime;\n};\n\nfunction resolveRef(ref?: Temporal.ZonedDateTime): Temporal.ZonedDateTime {\n return ref ?? Temporal.Now.zonedDateTimeISO('UTC');\n}\n\n/**\n * Generates a past date within the given number of years from `ref` (default: now).\n */\nexport function past(ctx: IllusionistContext, options?: DateOptions): Temporal.ZonedDateTime {\n const ref = resolveRef(options?.ref);\n const years = options?.years ?? 1;\n const maxSeconds = years * 365 * 24 * 60 * 60;\n const minSeconds = 1;\n\n return ref.add({ seconds: -int(minSeconds, maxSeconds, ctx.source) });\n}\n\n/**\n * Generates a future date within the given number of years from `ref` (default: now).\n */\nexport function future(ctx: IllusionistContext, options?: DateOptions): Temporal.ZonedDateTime {\n const ref = resolveRef(options?.ref);\n const years = options?.years ?? 1;\n const maxSeconds = years * 365 * 24 * 60 * 60;\n\n return ref.add({ seconds: int(1, maxSeconds, ctx.source) });\n}\n\n/**\n * Generates a recent date within the given number of days from `ref` (default: now).\n */\nexport function recent(\n ctx: IllusionistContext,\n options?: { days?: number; ref?: Temporal.ZonedDateTime },\n): Temporal.ZonedDateTime {\n const ref = resolveRef(options?.ref);\n const days = options?.days ?? 1;\n const maxSeconds = days * 24 * 60 * 60;\n\n return ref.add({ seconds: -int(1, maxSeconds, ctx.source) });\n}\n\n/**\n * Generates a date between `from` and `to`.\n */\nexport function between(\n ctx: IllusionistContext,\n from: Temporal.ZonedDateTime,\n to: Temporal.ZonedDateTime,\n): Temporal.ZonedDateTime {\n const fromNs = from.toInstant().epochNanoseconds;\n const toNs = to.toInstant().epochNanoseconds;\n\n if (fromNs > toNs) {\n return from;\n }\n\n const spanNs = toNs - fromNs;\n const spanSeconds = Number(spanNs / 1_000_000_000n);\n const offsetSeconds = Math.floor(ctx.source.next() * spanSeconds);\n\n return from.add({ seconds: offsetSeconds });\n}\n\n/**\n * Generates a random birthday — a date with a random year (default 18-80 years ago) and random month/day.\n */\nexport function birthday(\n ctx: IllusionistContext,\n options?: { minAge?: number; maxAge?: number; ref?: Temporal.ZonedDateTime },\n): Temporal.PlainDate {\n const ref = resolveRef(options?.ref);\n const minAge = options?.minAge ?? 18;\n const maxAge = options?.maxAge ?? 80;\n const age = int(minAge, maxAge, ctx.source);\n const month = int(1, 12, ctx.source);\n const day = int(1, 28, ctx.source);\n\n return ref.toPlainDate().subtract({ years: age }).with({ day, month });\n}\n\n/**\n * Returns a random weekday name.\n */\nexport function weekday(ctx: IllusionistContext, locale?: string): string {\n const days = ['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday'];\n const loc = locale ?? ctx.locale.code;\n const localized =\n loc === 'de' ? ['Montag', 'Dienstag', 'Mittwoch', 'Donnerstag', 'Freitag', 'Samstag', 'Sonntag'] : days;\n\n return localized[int(0, 6, ctx.source)]!;\n}\n\n/**\n * Returns a random month name.\n */\nexport function month(ctx: IllusionistContext, locale?: string): string {\n const months = [\n 'January',\n 'February',\n 'March',\n 'April',\n 'May',\n 'June',\n 'July',\n 'August',\n 'September',\n 'October',\n 'November',\n 'December',\n ];\n const loc = locale ?? ctx.locale.code;\n const localized =\n loc === 'de'\n ? [\n 'Januar',\n 'Februar',\n 'März',\n 'April',\n 'Mai',\n 'Juni',\n 'Juli',\n 'August',\n 'September',\n 'Oktober',\n 'November',\n 'Dezember',\n ]\n : months;\n\n return localized[int(0, 11, ctx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EAAE,OAAO,CAAC,EAAE,WAAW,GAAG,QAAQ,CAAC,aAAa,CAO3F;AAED;;GAEG;AACH,wBAAgB,MAAM,CAAC,GAAG,EAAE,kBAAkB,EAAE,OAAO,CAAC,EAAE,WAAW,GAAG,QAAQ,CAAC,aAAa,CAM7F;AAED;;GAEG;AACH,wBAAgB,MAAM,CACpB,GAAG,EAAE,kBAAkB,EACvB,OAAO,CAAC,EAAE;IAAE,IAAI,CAAC,EAAE,MAAM,CAAC;IAAC,GAAG,CAAC,EAAE,QAAQ,CAAC,aAAa,CAAA;CAAE,GACxD,QAAQ,CAAC,aAAa,CAMxB;AAED;;GAEG;AACH,wBAAgB,OAAO,CACrB,GAAG,EAAE,kBAAkB,EACvB,IAAI,EAAE,QAAQ,CAAC,aAAa,EAC5B,EAAE,EAAE,QAAQ,CAAC,aAAa,GACzB,QAAQ,CAAC,aAAa,CAaxB;AAED;;GAEG;AACH,wBAAgB,QAAQ,CACtB,GAAG,EAAE,kBAAkB,EACvB,OAAO,CAAC,EAAE;IAAE,MAAM,CAAC,EAAE,MAAM,CAAC;IAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IAAC,GAAG,CAAC,EAAE,QAAQ,CAAC,aAAa,CAAA;CAAE,GAC3E,QAAQ,CAAC,SAAS,CASpB;AAED;;GAEG;AACH,wBAAgB,OAAO,CAAC,GAAG,EAAE,kBAAkB,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,CAOxE;AAED;;GAEG;AACH,wBAAgB,KAAK,CAAC,GAAG,EAAE,kBAAkB,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,CAmCtE"}
package/dist/date/date.js CHANGED
@@ -1,45 +1,45 @@
1
1
  import { __exportAll as e } from "../_virtual/_rolldown/runtime.js";
2
2
  import { int as t } from "../_helpers/int.js";
3
- import { Temporal as n, shift as r } from "@vielzeug/tempo";
3
+ import { Temporal as n } from "@vielzeug/tempo";
4
4
  //#region src/date/date.ts
5
- var i = /* @__PURE__ */ e({
6
- between: () => l,
7
- birthday: () => u,
8
- future: () => s,
9
- month: () => f,
10
- past: () => o,
11
- recent: () => c,
12
- weekday: () => d
5
+ var r = /* @__PURE__ */ e({
6
+ between: () => c,
7
+ birthday: () => l,
8
+ future: () => o,
9
+ month: () => d,
10
+ past: () => a,
11
+ recent: () => s,
12
+ weekday: () => u
13
13
  });
14
- function a(e) {
14
+ function i(e) {
15
15
  return e ?? n.Now.zonedDateTimeISO("UTC");
16
16
  }
17
+ function a(e, n) {
18
+ let r = i(n?.ref), a = (n?.years ?? 1) * 365 * 24 * 60 * 60;
19
+ return r.add({ seconds: -t(1, a, e.source) });
20
+ }
17
21
  function o(e, n) {
18
- let i = a(n?.ref), o = (n?.years ?? 1) * 365 * 24 * 60 * 60;
19
- return r(i, { seconds: -t(1, o, e.source) });
22
+ let r = i(n?.ref), a = (n?.years ?? 1) * 365 * 24 * 60 * 60;
23
+ return r.add({ seconds: t(1, a, e.source) });
20
24
  }
21
25
  function s(e, n) {
22
- let i = a(n?.ref), o = (n?.years ?? 1) * 365 * 24 * 60 * 60;
23
- return r(i, { seconds: t(1, o, e.source) });
24
- }
25
- function c(e, n) {
26
- let i = a(n?.ref), o = (n?.days ?? 1) * 24 * 60 * 60;
27
- return r(i, { seconds: -t(1, o, e.source) });
26
+ let r = i(n?.ref), a = (n?.days ?? 1) * 24 * 60 * 60;
27
+ return r.add({ seconds: -t(1, a, e.source) });
28
28
  }
29
- function l(e, t, n) {
29
+ function c(e, t, n) {
30
30
  let r = t.toInstant().epochNanoseconds, i = n.toInstant().epochNanoseconds;
31
31
  if (r > i) return t;
32
32
  let a = i - r, o = Number(a / 1000000000n), s = Math.floor(e.source.next() * o);
33
33
  return t.add({ seconds: s });
34
34
  }
35
- function u(e, n) {
36
- let r = a(n?.ref), i = n?.minAge ?? 18, o = n?.maxAge ?? 80, s = t(i, o, e.source), c = t(1, 12, e.source), l = t(1, 28, e.source);
35
+ function l(e, n) {
36
+ let r = i(n?.ref), a = n?.minAge ?? 18, o = n?.maxAge ?? 80, s = t(a, o, e.source), c = t(1, 12, e.source), l = t(1, 28, e.source);
37
37
  return r.toPlainDate().subtract({ years: s }).with({
38
38
  day: l,
39
39
  month: c
40
40
  });
41
41
  }
42
- function d(e, n) {
42
+ function u(e, n) {
43
43
  return ((n ?? e.locale.code) === "de" ? [
44
44
  "Montag",
45
45
  "Dienstag",
@@ -58,7 +58,7 @@ function d(e, n) {
58
58
  "Sunday"
59
59
  ])[t(0, 6, e.source)];
60
60
  }
61
- function f(e, n) {
61
+ function d(e, n) {
62
62
  return ((n ?? e.locale.code) === "de" ? [
63
63
  "Januar",
64
64
  "Februar",
@@ -88,6 +88,6 @@ function f(e, n) {
88
88
  ])[t(0, 11, e.source)];
89
89
  }
90
90
  //#endregion
91
- export { l as between, u as birthday, i as date_exports, s as future, f as month, o as past, c as recent, d as weekday };
91
+ export { c as between, l as birthday, r as date_exports, o as future, d as month, a as past, s as recent, u as weekday };
92
92
 
93
93
  //# sourceMappingURL=date.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"date.js","names":[],"sources":["../../src/date/date.ts"],"sourcesContent":["import { shift, Temporal } from '@vielzeug/tempo';\n\nimport { int } from '../_helpers/int';\nimport type { IllusionistContext } from '../types';\n\ntype DateOptions = {\n years?: number;\n ref?: Temporal.ZonedDateTime;\n};\n\nfunction resolveRef(ref?: Temporal.ZonedDateTime): Temporal.ZonedDateTime {\n return ref ?? Temporal.Now.zonedDateTimeISO('UTC');\n}\n\n/**\n * Generates a past date within the given number of years from `ref` (default: now).\n */\nexport function past(ctx: IllusionistContext, options?: DateOptions): Temporal.ZonedDateTime {\n const ref = resolveRef(options?.ref);\n const years = options?.years ?? 1;\n const maxSeconds = years * 365 * 24 * 60 * 60;\n const minSeconds = 1;\n\n return shift(ref, { seconds: -int(minSeconds, maxSeconds, ctx.source) });\n}\n\n/**\n * Generates a future date within the given number of years from `ref` (default: now).\n */\nexport function future(ctx: IllusionistContext, options?: DateOptions): Temporal.ZonedDateTime {\n const ref = resolveRef(options?.ref);\n const years = options?.years ?? 1;\n const maxSeconds = years * 365 * 24 * 60 * 60;\n\n return shift(ref, { seconds: int(1, maxSeconds, ctx.source) });\n}\n\n/**\n * Generates a recent date within the given number of days from `ref` (default: now).\n */\nexport function recent(\n ctx: IllusionistContext,\n options?: { days?: number; ref?: Temporal.ZonedDateTime },\n): Temporal.ZonedDateTime {\n const ref = resolveRef(options?.ref);\n const days = options?.days ?? 1;\n const maxSeconds = days * 24 * 60 * 60;\n\n return shift(ref, { seconds: -int(1, maxSeconds, ctx.source) });\n}\n\n/**\n * Generates a date between `from` and `to`.\n */\nexport function between(\n ctx: IllusionistContext,\n from: Temporal.ZonedDateTime,\n to: Temporal.ZonedDateTime,\n): Temporal.ZonedDateTime {\n const fromNs = from.toInstant().epochNanoseconds;\n const toNs = to.toInstant().epochNanoseconds;\n\n if (fromNs > toNs) {\n return from;\n }\n\n const spanNs = toNs - fromNs;\n const spanSeconds = Number(spanNs / 1_000_000_000n);\n const offsetSeconds = Math.floor(ctx.source.next() * spanSeconds);\n\n return from.add({ seconds: offsetSeconds });\n}\n\n/**\n * Generates a random birthday — a date with a random year (default 18-80 years ago) and random month/day.\n */\nexport function birthday(\n ctx: IllusionistContext,\n options?: { minAge?: number; maxAge?: number; ref?: Temporal.ZonedDateTime },\n): Temporal.PlainDate {\n const ref = resolveRef(options?.ref);\n const minAge = options?.minAge ?? 18;\n const maxAge = options?.maxAge ?? 80;\n const age = int(minAge, maxAge, ctx.source);\n const month = int(1, 12, ctx.source);\n const day = int(1, 28, ctx.source);\n\n return ref.toPlainDate().subtract({ years: age }).with({ day, month });\n}\n\n/**\n * Returns a random weekday name.\n */\nexport function weekday(ctx: IllusionistContext, locale?: string): string {\n const days = ['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday'];\n const loc = locale ?? ctx.locale.code;\n const localized =\n loc === 'de' ? ['Montag', 'Dienstag', 'Mittwoch', 'Donnerstag', 'Freitag', 'Samstag', 'Sonntag'] : days;\n\n return localized[int(0, 6, ctx.source)]!;\n}\n\n/**\n * Returns a random month name.\n */\nexport function month(ctx: IllusionistContext, locale?: string): string {\n const months = [\n 'January',\n 'February',\n 'March',\n 'April',\n 'May',\n 'June',\n 'July',\n 'August',\n 'September',\n 'October',\n 'November',\n 'December',\n ];\n const loc = locale ?? ctx.locale.code;\n const localized =\n loc === 'de'\n ? [\n 'Januar',\n 'Februar',\n 'März',\n 'April',\n 'Mai',\n 'Juni',\n 'Juli',\n 'August',\n 'September',\n 'Oktober',\n 'November',\n 'Dezember',\n ]\n : months;\n\n return localized[int(0, 11, ctx.source)]!;\n}\n"],"mappings":";;;;;;;;;;;;;AAUA,SAAS,EAAW,GAAsD;CACxE,OAAO,KAAO,EAAS,IAAI,iBAAiB,KAAK;AACnD;AAKA,SAAgB,EAAK,GAAyB,GAA+C;CAC3F,IAAM,IAAM,EAAW,GAAS,GAAG,GAE7B,KADQ,GAAS,SAAS,KACL,MAAM,KAAK,KAAK;CAG3C,OAAO,EAAM,GAAK,EAAE,SAAS,CAAC,EAAI,GAAY,GAAY,EAAI,MAAM,EAAE,CAAC;AACzE;AAKA,SAAgB,EAAO,GAAyB,GAA+C;CAC7F,IAAM,IAAM,EAAW,GAAS,GAAG,GAE7B,KADQ,GAAS,SAAS,KACL,MAAM,KAAK,KAAK;CAE3C,OAAO,EAAM,GAAK,EAAE,SAAS,EAAI,GAAG,GAAY,EAAI,MAAM,EAAE,CAAC;AAC/D;AAKA,SAAgB,EACd,GACA,GACwB;CACxB,IAAM,IAAM,EAAW,GAAS,GAAG,GAE7B,KADO,GAAS,QAAQ,KACJ,KAAK,KAAK;CAEpC,OAAO,EAAM,GAAK,EAAE,SAAS,CAAC,EAAI,GAAG,GAAY,EAAI,MAAM,EAAE,CAAC;AAChE;AAKA,SAAgB,EACd,GACA,GACA,GACwB;CACxB,IAAM,IAAS,EAAK,UAAU,CAAC,CAAC,kBAC1B,IAAO,EAAG,UAAU,CAAC,CAAC;CAE5B,IAAI,IAAS,GACX,OAAO;CAGT,IAAM,IAAS,IAAO,GAChB,IAAc,OAAO,IAAS,WAAc,GAC5C,IAAgB,KAAK,MAAM,EAAI,OAAO,KAAK,IAAI,CAAW;CAEhE,OAAO,EAAK,IAAI,EAAE,SAAS,EAAc,CAAC;AAC5C;AAKA,SAAgB,EACd,GACA,GACoB;CACpB,IAAM,IAAM,EAAW,GAAS,GAAG,GAC7B,IAAS,GAAS,UAAU,IAC5B,IAAS,GAAS,UAAU,IAC5B,IAAM,EAAI,GAAQ,GAAQ,EAAI,MAAM,GACpC,IAAQ,EAAI,GAAG,IAAI,EAAI,MAAM,GAC7B,IAAM,EAAI,GAAG,IAAI,EAAI,MAAM;CAEjC,OAAO,EAAI,YAAY,CAAC,CAAC,SAAS,EAAE,OAAO,EAAI,CAAC,CAAC,CAAC,KAAK;EAAE;EAAK;CAAM,CAAC;AACvE;AAKA,SAAgB,EAAQ,GAAyB,GAAyB;CAMxE,SAJY,KAAU,EAAI,OAAO,UAEvB,OAAO;EAAC;EAAU;EAAY;EAAY;EAAc;EAAW;EAAW;CAAS,IAAI;EAHvF;EAAU;EAAW;EAAa;EAAY;EAAU;EAAY;CAGmB,EAAA,CAEpF,EAAI,GAAG,GAAG,EAAI,MAAM;AACvC;AAKA,SAAgB,EAAM,GAAyB,GAAyB;CAkCtE,SAnBY,KAAU,EAAI,OAAO,UAEvB,OACJ;EACE;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;CACF,IACA;EA9BJ;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;CAmBI,EAAA,CAEW,EAAI,GAAG,IAAI,EAAI,MAAM;AACxC"}
1
+ {"version":3,"file":"date.js","names":[],"sources":["../../src/date/date.ts"],"sourcesContent":["import { Temporal } from '@vielzeug/tempo';\n\nimport { int } from '../_helpers/int';\nimport type { IllusionistContext } from '../types';\n\ntype DateOptions = {\n years?: number;\n ref?: Temporal.ZonedDateTime;\n};\n\nfunction resolveRef(ref?: Temporal.ZonedDateTime): Temporal.ZonedDateTime {\n return ref ?? Temporal.Now.zonedDateTimeISO('UTC');\n}\n\n/**\n * Generates a past date within the given number of years from `ref` (default: now).\n */\nexport function past(ctx: IllusionistContext, options?: DateOptions): Temporal.ZonedDateTime {\n const ref = resolveRef(options?.ref);\n const years = options?.years ?? 1;\n const maxSeconds = years * 365 * 24 * 60 * 60;\n const minSeconds = 1;\n\n return ref.add({ seconds: -int(minSeconds, maxSeconds, ctx.source) });\n}\n\n/**\n * Generates a future date within the given number of years from `ref` (default: now).\n */\nexport function future(ctx: IllusionistContext, options?: DateOptions): Temporal.ZonedDateTime {\n const ref = resolveRef(options?.ref);\n const years = options?.years ?? 1;\n const maxSeconds = years * 365 * 24 * 60 * 60;\n\n return ref.add({ seconds: int(1, maxSeconds, ctx.source) });\n}\n\n/**\n * Generates a recent date within the given number of days from `ref` (default: now).\n */\nexport function recent(\n ctx: IllusionistContext,\n options?: { days?: number; ref?: Temporal.ZonedDateTime },\n): Temporal.ZonedDateTime {\n const ref = resolveRef(options?.ref);\n const days = options?.days ?? 1;\n const maxSeconds = days * 24 * 60 * 60;\n\n return ref.add({ seconds: -int(1, maxSeconds, ctx.source) });\n}\n\n/**\n * Generates a date between `from` and `to`.\n */\nexport function between(\n ctx: IllusionistContext,\n from: Temporal.ZonedDateTime,\n to: Temporal.ZonedDateTime,\n): Temporal.ZonedDateTime {\n const fromNs = from.toInstant().epochNanoseconds;\n const toNs = to.toInstant().epochNanoseconds;\n\n if (fromNs > toNs) {\n return from;\n }\n\n const spanNs = toNs - fromNs;\n const spanSeconds = Number(spanNs / 1_000_000_000n);\n const offsetSeconds = Math.floor(ctx.source.next() * spanSeconds);\n\n return from.add({ seconds: offsetSeconds });\n}\n\n/**\n * Generates a random birthday — a date with a random year (default 18-80 years ago) and random month/day.\n */\nexport function birthday(\n ctx: IllusionistContext,\n options?: { minAge?: number; maxAge?: number; ref?: Temporal.ZonedDateTime },\n): Temporal.PlainDate {\n const ref = resolveRef(options?.ref);\n const minAge = options?.minAge ?? 18;\n const maxAge = options?.maxAge ?? 80;\n const age = int(minAge, maxAge, ctx.source);\n const month = int(1, 12, ctx.source);\n const day = int(1, 28, ctx.source);\n\n return ref.toPlainDate().subtract({ years: age }).with({ day, month });\n}\n\n/**\n * Returns a random weekday name.\n */\nexport function weekday(ctx: IllusionistContext, locale?: string): string {\n const days = ['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday'];\n const loc = locale ?? ctx.locale.code;\n const localized =\n loc === 'de' ? ['Montag', 'Dienstag', 'Mittwoch', 'Donnerstag', 'Freitag', 'Samstag', 'Sonntag'] : days;\n\n return localized[int(0, 6, ctx.source)]!;\n}\n\n/**\n * Returns a random month name.\n */\nexport function month(ctx: IllusionistContext, locale?: string): string {\n const months = [\n 'January',\n 'February',\n 'March',\n 'April',\n 'May',\n 'June',\n 'July',\n 'August',\n 'September',\n 'October',\n 'November',\n 'December',\n ];\n const loc = locale ?? ctx.locale.code;\n const localized =\n loc === 'de'\n ? [\n 'Januar',\n 'Februar',\n 'März',\n 'April',\n 'Mai',\n 'Juni',\n 'Juli',\n 'August',\n 'September',\n 'Oktober',\n 'November',\n 'Dezember',\n ]\n : months;\n\n return localized[int(0, 11, ctx.source)]!;\n}\n"],"mappings":";;;;;;;;;;;;;AAUA,SAAS,EAAW,GAAsD;CACxE,OAAO,KAAO,EAAS,IAAI,iBAAiB,KAAK;AACnD;AAKA,SAAgB,EAAK,GAAyB,GAA+C;CAC3F,IAAM,IAAM,EAAW,GAAS,GAAG,GAE7B,KADQ,GAAS,SAAS,KACL,MAAM,KAAK,KAAK;CAG3C,OAAO,EAAI,IAAI,EAAE,SAAS,CAAC,EAAI,GAAY,GAAY,EAAI,MAAM,EAAE,CAAC;AACtE;AAKA,SAAgB,EAAO,GAAyB,GAA+C;CAC7F,IAAM,IAAM,EAAW,GAAS,GAAG,GA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AM;AACvC;AAKA,SAAgB,EAAM,GAAyB,GAAyB;CAkCtE,SAnBY,KAAU,EAAI,OAAO,UAEvB,OACJ;EACE;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;CACF,IACA;EA9BJ;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;CAmBI,EAAA,CAEW,EAAI,GAAG,IAAI,EAAI,MAAM;AACxC"}
package/dist/factory.cjs CHANGED
@@ -1,2 +1,2 @@
1
- const e=require("./commerce/commerce.cjs"),t=require("./date/date.cjs"),n=require("./finance/finance.cjs"),r=require("./internet/internet.cjs"),i=require("./location/location.cjs"),a=require("./lorem/lorem.cjs"),o=require("./person/person.cjs"),s=require("./seed/create-seed.cjs"),c=require("./system/system.cjs");function l(l){let{locale:u,seed:d}=l,f=s.createSeed(d),p=new AbortController,m=!1,h={locale:u,source:f},g=e=>{let t={};for(let[n,r]of Object.entries(e))typeof r==`function`&&(t[n]=(...e)=>r(h,...e));return t},_=()=>{m||(m=!0,p.abort())};return{commerce:g(e.commerce_exports),date:g(t.date_exports),get disposalSignal(){return p.signal},dispose:_,get disposed(){return m},finance:g(n.finance_exports),internet:g(r.internet_exports),locale:u,location:g(i.location_exports),lorem:g(a.lorem_exports),person:g(o.person_exports),seed:d,system:g(c.system_exports),[Symbol.dispose]:_}}exports.createIllusion=l;
1
+ const e=require("./commerce/commerce.cjs"),t=require("./date/date.cjs"),n=require("./finance/finance.cjs"),r=require("./internet/internet.cjs"),i=require("./location/location.cjs"),a=require("./lorem/lorem.cjs"),o=require("./person/person.cjs"),s=require("./seed/create-seed.cjs"),c=require("./system/system.cjs");function l(l){let{locale:u,seed:d}=l,f={locale:u,source:s.createSeed(d)},p=e=>{let t={};for(let[n,r]of Object.entries(e))typeof r==`function`&&(t[n]=(...e)=>r(f,...e));return t};return{commerce:p(e.commerce_exports),date:p(t.date_exports),finance:p(n.finance_exports),internet:p(r.internet_exports),locale:u,location:p(i.location_exports),lorem:p(a.lorem_exports),person:p(o.person_exports),seed:d,system:p(c.system_exports)}}exports.createIllusion=l;
2
2
  //# sourceMappingURL=factory.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"factory.cjs","names":[],"sources":["../src/factory.ts"],"sourcesContent":["import type { RandomSource } from '@vielzeug/arsenal/random';\nimport * as commerceApi from './commerce/commerce';\nimport * as dateApi from './date/date';\nimport * as financeApi from './finance/finance';\nimport * as internetApi from './internet/internet';\nimport * as locationApi from './location/location';\nimport * as loremApi from './lorem/lorem';\nimport * as personApi from './person/person';\nimport { createSeed } from './seed/create-seed';\nimport * as systemApi from './system/system';\nimport type { IllusionistContext, IllusionistLocale, IllusionistOptions } from './types';\n\nexport type { IllusionistOptions } from './types';\n\n/** Strips the leading `IllusionistContext` parameter from a function type. */\ntype Bound<F> = F extends (ctx: IllusionistContext, ...args: infer A) => infer R ? (...args: A) => R : F;\n\n/** Maps a module of `(ctx, ...args) => R` functions to `(...args) => R`. */\ntype BoundApi<T> = { readonly [K in keyof T]: Bound<T[K]> };\n\nexport type Illusionist = {\n readonly person: BoundApi<typeof personApi>;\n readonly internet: BoundApi<typeof internetApi>;\n readonly commerce: BoundApi<typeof commerceApi>;\n readonly date: BoundApi<typeof dateApi>;\n readonly finance: BoundApi<typeof financeApi>;\n readonly location: BoundApi<typeof locationApi>;\n readonly lorem: BoundApi<typeof loremApi>;\n readonly system: BoundApi<typeof systemApi>;\n\n /** The seed used to initialize this instance, or `undefined` for cryptographic randomness. */\n readonly seed: number | string | undefined;\n /** The active locale data. */\n readonly locale: IllusionistLocale;\n\n dispose(): void;\n readonly disposed: boolean;\n readonly disposalSignal: AbortSignal;\n [Symbol.dispose](): void;\n};\n\n/**\n * Creates a bound illusionist instance with all categories sharing a single seeded\n * random source and locale.\n *\n * @example\n * ```ts\n * import { en } from '@vielzeug/illusionist/locales';\n *\n * const illusion = createIllusion({ seed: 12345, locale: en });\n *\n * illusion.person.fullName(); // deterministic — same seed → same result\n * illusion.internet.email();\n * illusion.commerce.price();\n * illusion.dispose(); // [Symbol.dispose]() also works\n * ```\n */\nexport function createIllusion(options: IllusionistOptions): Illusionist {\n const { locale, seed } = options;\n const source: RandomSource = createSeed(seed);\n const controller = new AbortController();\n let disposed = false;\n\n const ctx: IllusionistContext = { locale, source };\n\n const bind = <T extends Record<string, (ctx: IllusionistContext, ...args: never[]) => unknown>>(\n api: T,\n ): BoundApi<T> => {\n const bound = {} as Record<string, (...args: never[]) => unknown>;\n\n for (const [key, fn] of Object.entries(api)) {\n if (typeof fn === 'function') {\n bound[key] = (...args: never[]) => (fn as (ctx: IllusionistContext, ...args: never[]) => unknown)(ctx, ...args);\n }\n }\n\n return bound as unknown as BoundApi<T>;\n };\n\n const dispose = (): void => {\n if (disposed) return;\n\n disposed = true;\n controller.abort();\n };\n\n return {\n commerce: bind(commerceApi),\n date: bind(dateApi),\n get disposalSignal(): AbortSignal {\n return controller.signal;\n },\n dispose,\n get disposed(): boolean {\n return disposed;\n },\n finance: bind(financeApi),\n internet: bind(internetApi),\n locale,\n location: bind(locationApi),\n lorem: bind(loremApi),\n person: bind(personApi),\n seed,\n system: bind(systemApi),\n [Symbol.dispose]: dispose,\n };\n}\n"],"mappings":"0TAyDA,SAAgB,EAAe,EAA0C,CACvE,GAAM,CAAE,SAAQ,QAAS,EACnB,EAAuB,EAAA,WAAW,CAAI,EACtC,EAAa,IAAI,gBACnB,EAAW,GAET,EAA0B,CAAE,SAAQ,QAAO,EAE3C,EACJ,GACgB,CAChB,IAAM,EAAQ,CAAC,EAEf,IAAK,GAAM,CAAC,EAAK,KAAO,OAAO,QAAQ,CAAG,EACpC,OAAO,GAAO,aAChB,EAAM,IAAQ,GAAG,IAAmB,EAA8D,EAAK,GAAG,CAAI,GAIlH,OAAO,CACT,EAEM,MAAsB,CACtB,IAEJ,EAAW,GACX,EAAW,MAAM,EACnB,EAEA,MAAO,CACL,SAAU,EAAK,EAAA,gBAAW,EAC1B,KAAM,EAAK,EAAA,YAAO,EAClB,IAAI,gBAA8B,CAChC,OAAO,EAAW,MACpB,EACA,UACA,IAAI,UAAoB,CACtB,OAAO,CACT,EACA,QAAS,EAAK,EAAA,eAAU,EACxB,SAAU,EAAK,EAAA,gBAAW,EAC1B,SACA,SAAU,EAAK,EAAA,gBAAW,EAC1B,MAAO,EAAK,EAAA,aAAQ,EACpB,OAAQ,EAAK,EAAA,cAAS,EACtB,OACA,OAAQ,EAAK,EAAA,cAAS,GACrB,OAAO,SAAU,CACpB,CACF"}
1
+ {"version":3,"file":"factory.cjs","names":[],"sources":["../src/factory.ts"],"sourcesContent":["import * as commerceApi from './commerce/commerce';\nimport * as dateApi from './date/date';\nimport * as financeApi from './finance/finance';\nimport * as internetApi from './internet/internet';\nimport * as locationApi from './location/location';\nimport * as loremApi from './lorem/lorem';\nimport * as personApi from './person/person';\nimport { createSeed } from './seed/create-seed';\nimport * as systemApi from './system/system';\nimport type { IllusionistContext, IllusionistLocale, IllusionistOptions, RandomSource } from './types';\n\nexport type { IllusionistOptions } from './types';\n\n/** Strips the leading `IllusionistContext` parameter from a function type. */\ntype Bound<F> = F extends (ctx: IllusionistContext, ...args: infer A) => infer R ? (...args: A) => R : F;\n\n/** Maps a module of `(ctx, ...args) => R` functions to `(...args) => R`. */\ntype BoundApi<T> = { readonly [K in keyof T]: Bound<T[K]> };\n\nexport type Illusionist = {\n readonly person: BoundApi<typeof personApi>;\n readonly internet: BoundApi<typeof internetApi>;\n readonly commerce: BoundApi<typeof commerceApi>;\n readonly date: BoundApi<typeof dateApi>;\n readonly finance: BoundApi<typeof financeApi>;\n readonly location: BoundApi<typeof locationApi>;\n readonly lorem: BoundApi<typeof loremApi>;\n readonly system: BoundApi<typeof systemApi>;\n\n /** The seed used to initialize this instance, or `undefined` for cryptographic randomness. */\n readonly seed: number | string | undefined;\n /** The active locale data. */\n readonly locale: IllusionistLocale;\n};\n\n/**\n * Creates a bound illusionist instance with all categories sharing a single seeded\n * random source and locale.\n *\n * @example\n * ```ts\n * import { en } from '@vielzeug/illusionist/locales';\n *\n * const illusion = createIllusion({ seed: 12345, locale: en });\n *\n * illusion.person.fullName(); // deterministic — same seed → same result\n * illusion.internet.email();\n * illusion.commerce.price();\n * ```\n */\nexport function createIllusion(options: IllusionistOptions): Illusionist {\n const { locale, seed } = options;\n const source: RandomSource = createSeed(seed);\n\n const ctx: IllusionistContext = { locale, source };\n\n const bind = <T extends Record<string, (ctx: IllusionistContext, ...args: never[]) => unknown>>(\n api: T,\n ): BoundApi<T> => {\n const bound = {} as Record<string, (...args: never[]) => unknown>;\n\n for (const [key, fn] of Object.entries(api)) {\n if (typeof fn === 'function') {\n bound[key] = (...args: never[]) => (fn as (ctx: IllusionistContext, ...args: never[]) => unknown)(ctx, ...args);\n }\n }\n\n return bound as unknown as BoundApi<T>;\n };\n\n return {\n commerce: bind(commerceApi),\n date: bind(dateApi),\n finance: bind(financeApi),\n internet: bind(internetApi),\n locale,\n location: bind(locationApi),\n lorem: bind(loremApi),\n person: bind(personApi),\n seed,\n system: bind(systemApi),\n };\n}\n"],"mappings":"0TAkDA,SAAgB,EAAe,EAA0C,CACvE,GAAM,CAAE,SAAQ,QAAS,EAGnB,EAA0B,CAAE,SAAQ,OAFb,EAAA,WAAW,CAEE,CAAO,EAE3C,EACJ,GACgB,CAChB,IAAM,EAAQ,CAAC,EAEf,IAAK,GAAM,CAAC,EAAK,KAAO,OAAO,QAAQ,CAAG,EACpC,OAAO,GAAO,aAChB,EAAM,IAAQ,GAAG,IAAmB,EAA8D,EAAK,GAAG,CAAI,GAIlH,OAAO,CACT,EAEA,MAAO,CACL,SAAU,EAAK,EAAA,gBAAW,EAC1B,KAAM,EAAK,EAAA,YAAO,EAClB,QAAS,EAAK,EAAA,eAAU,EACxB,SAAU,EAAK,EAAA,gBAAW,EAC1B,SACA,SAAU,EAAK,EAAA,gBAAW,EAC1B,MAAO,EAAK,EAAA,aAAQ,EACpB,OAAQ,EAAK,EAAA,cAAS,EACtB,OACA,OAAQ,EAAK,EAAA,cAAS,CACxB,CACF"}
package/dist/factory.d.ts CHANGED
@@ -27,10 +27,6 @@ export type Illusionist = {
27
27
  readonly seed: number | string | undefined;
28
28
  /** The active locale data. */
29
29
  readonly locale: IllusionistLocale;
30
- dispose(): void;
31
- readonly disposed: boolean;
32
- readonly disposalSignal: AbortSignal;
33
- [Symbol.dispose](): void;
34
30
  };
35
31
  /**
36
32
  * Creates a bound illusionist instance with all categories sharing a single seeded
@@ -45,7 +41,6 @@ export type Illusionist = {
45
41
  * illusion.person.fullName(); // deterministic — same seed → same result
46
42
  * illusion.internet.email();
47
43
  * illusion.commerce.price();
48
- * illusion.dispose(); // [Symbol.dispose]() also works
49
44
  * ```
50
45
  */
51
46
  export declare function createIllusion(options: IllusionistOptions): Illusionist;
@@ -1 +1 @@
1
- {"version":3,"file":"factory.d.ts","sourceRoot":"","sources":["../src/factory.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,WAAW,MAAM,qBAAqB,CAAC;AACnD,OAAO,KAAK,OAAO,MAAM,aAAa,CAAC;AACvC,OAAO,KAAK,UAAU,MAAM,mBAAmB,CAAC;AAChD,OAAO,KAAK,WAAW,MAAM,qBAAqB,CAAC;AACnD,OAAO,KAAK,WAAW,MAAM,qBAAqB,CAAC;AACnD,OAAO,KAAK,QAAQ,MAAM,eAAe,CAAC;AAC1C,OAAO,KAAK,SAAS,MAAM,iBAAiB,CAAC;AAE7C,OAAO,KAAK,SAAS,MAAM,iBAAiB,CAAC;AAC7C,OAAO,KAAK,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAC;AAEzF,YAAY,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAC;AAElD,8EAA8E;AAC9E,KAAK,KAAK,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,GAAG,EAAE,kBAAkB,EAAE,GAAG,IAAI,EAAE,MAAM,CAAC,KAAK,MAAM,CAAC,GAAG,CAAC,GAAG,IAAI,EAAE,CAAC,KAAK,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