@vielzeug/illusionist 2.2.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 (222) hide show
  1. package/README.md +89 -0
  2. package/dist/_dev.d.ts +2 -0
  3. package/dist/_dev.d.ts.map +1 -0
  4. package/dist/_helpers/boolean.cjs +2 -0
  5. package/dist/_helpers/boolean.cjs.map +1 -0
  6. package/dist/_helpers/boolean.d.ts +4 -0
  7. package/dist/_helpers/boolean.d.ts.map +1 -0
  8. package/dist/_helpers/boolean.js +8 -0
  9. package/dist/_helpers/boolean.js.map +1 -0
  10. package/dist/_helpers/float.cjs +2 -0
  11. package/dist/_helpers/float.cjs.map +1 -0
  12. package/dist/_helpers/float.d.ts +9 -0
  13. package/dist/_helpers/float.d.ts.map +1 -0
  14. package/dist/_helpers/float.js +14 -0
  15. package/dist/_helpers/float.js.map +1 -0
  16. package/dist/_helpers/int.cjs +2 -0
  17. package/dist/_helpers/int.cjs.map +1 -0
  18. package/dist/_helpers/int.d.ts +4 -0
  19. package/dist/_helpers/int.d.ts.map +1 -0
  20. package/dist/_helpers/int.js +9 -0
  21. package/dist/_helpers/int.js.map +1 -0
  22. package/dist/_helpers/string.cjs +2 -0
  23. package/dist/_helpers/string.cjs.map +1 -0
  24. package/dist/_helpers/string.d.ts +12 -0
  25. package/dist/_helpers/string.d.ts.map +1 -0
  26. package/dist/_helpers/string.js +38 -0
  27. package/dist/_helpers/string.js.map +1 -0
  28. package/dist/_virtual/_rolldown/runtime.cjs +1 -0
  29. package/dist/_virtual/_rolldown/runtime.js +11 -0
  30. package/dist/commerce/commerce.cjs +2 -0
  31. package/dist/commerce/commerce.cjs.map +1 -0
  32. package/dist/commerce/commerce.d.ts +15 -0
  33. package/dist/commerce/commerce.d.ts.map +1 -0
  34. package/dist/commerce/commerce.js +51 -0
  35. package/dist/commerce/commerce.js.map +1 -0
  36. package/dist/commerce/data.cjs +2 -0
  37. package/dist/commerce/data.cjs.map +1 -0
  38. package/dist/commerce/data.d.ts +7 -0
  39. package/dist/commerce/data.d.ts.map +1 -0
  40. package/dist/commerce/data.js +83 -0
  41. package/dist/commerce/data.js.map +1 -0
  42. package/dist/commerce/index.cjs +1 -0
  43. package/dist/commerce/index.d.ts +2 -0
  44. package/dist/commerce/index.d.ts.map +1 -0
  45. package/dist/commerce/index.js +2 -0
  46. package/dist/date/date.cjs +2 -0
  47. package/dist/date/date.cjs.map +1 -0
  48. package/dist/date/date.d.ts +43 -0
  49. package/dist/date/date.d.ts.map +1 -0
  50. package/dist/date/date.js +93 -0
  51. package/dist/date/date.js.map +1 -0
  52. package/dist/date/index.cjs +1 -0
  53. package/dist/date/index.d.ts +2 -0
  54. package/dist/date/index.d.ts.map +1 -0
  55. package/dist/date/index.js +2 -0
  56. package/dist/errors.cjs +2 -0
  57. package/dist/errors.cjs.map +1 -0
  58. package/dist/errors.d.ts +8 -0
  59. package/dist/errors.d.ts.map +1 -0
  60. package/dist/errors.js +10 -0
  61. package/dist/errors.js.map +1 -0
  62. package/dist/factory.cjs +2 -0
  63. package/dist/factory.cjs.map +1 -0
  64. package/dist/factory.d.ts +46 -0
  65. package/dist/factory.d.ts.map +1 -0
  66. package/dist/factory.js +46 -0
  67. package/dist/factory.js.map +1 -0
  68. package/dist/finance/data.cjs +2 -0
  69. package/dist/finance/data.cjs.map +1 -0
  70. package/dist/finance/data.d.ts +32 -0
  71. package/dist/finance/data.d.ts.map +1 -0
  72. package/dist/finance/data.js +60 -0
  73. package/dist/finance/data.js.map +1 -0
  74. package/dist/finance/finance.cjs +2 -0
  75. package/dist/finance/finance.cjs.map +1 -0
  76. package/dist/finance/finance.d.ts +20 -0
  77. package/dist/finance/finance.d.ts.map +1 -0
  78. package/dist/finance/finance.js +90 -0
  79. package/dist/finance/finance.js.map +1 -0
  80. package/dist/finance/index.cjs +1 -0
  81. package/dist/finance/index.d.ts +2 -0
  82. package/dist/finance/index.d.ts.map +1 -0
  83. package/dist/finance/index.js +2 -0
  84. package/dist/iife-entry.d.ts +4 -0
  85. package/dist/iife-entry.d.ts.map +1 -0
  86. package/dist/illusionist.cjs +4 -0
  87. package/dist/illusionist.cjs.map +1 -0
  88. package/dist/illusionist.iife.js +4 -0
  89. package/dist/illusionist.iife.js.map +1 -0
  90. package/dist/illusionist.js +4 -0
  91. package/dist/illusionist.js.map +1 -0
  92. package/dist/index.cjs +1 -0
  93. package/dist/index.d.ts +13 -0
  94. package/dist/index.d.ts.map +1 -0
  95. package/dist/index.js +12 -0
  96. package/dist/internet/data.cjs +2 -0
  97. package/dist/internet/data.cjs.map +1 -0
  98. package/dist/internet/data.d.ts +10 -0
  99. package/dist/internet/data.d.ts.map +1 -0
  100. package/dist/internet/data.js +84 -0
  101. package/dist/internet/data.js.map +1 -0
  102. package/dist/internet/index.cjs +1 -0
  103. package/dist/internet/index.d.ts +2 -0
  104. package/dist/internet/index.d.ts.map +1 -0
  105. package/dist/internet/index.js +2 -0
  106. package/dist/internet/internet.cjs +2 -0
  107. package/dist/internet/internet.cjs.map +1 -0
  108. package/dist/internet/internet.d.ts +31 -0
  109. package/dist/internet/internet.d.ts.map +1 -0
  110. package/dist/internet/internet.js +121 -0
  111. package/dist/internet/internet.js.map +1 -0
  112. package/dist/locales/de.cjs +2 -0
  113. package/dist/locales/de.cjs.map +1 -0
  114. package/dist/locales/de.d.ts +22 -0
  115. package/dist/locales/de.d.ts.map +1 -0
  116. package/dist/locales/de.js +12 -0
  117. package/dist/locales/de.js.map +1 -0
  118. package/dist/locales/en.cjs +2 -0
  119. package/dist/locales/en.cjs.map +1 -0
  120. package/dist/locales/en.d.ts +22 -0
  121. package/dist/locales/en.d.ts.map +1 -0
  122. package/dist/locales/en.js +12 -0
  123. package/dist/locales/en.js.map +1 -0
  124. package/dist/locales/index.cjs +1 -0
  125. package/dist/locales/index.d.ts +3 -0
  126. package/dist/locales/index.d.ts.map +1 -0
  127. package/dist/locales/index.js +3 -0
  128. package/dist/location/data/de.cjs +2 -0
  129. package/dist/location/data/de.cjs.map +1 -0
  130. package/dist/location/data/de.d.ts +9 -0
  131. package/dist/location/data/de.d.ts.map +1 -0
  132. package/dist/location/data/de.js +82 -0
  133. package/dist/location/data/de.js.map +1 -0
  134. package/dist/location/data/en.cjs +2 -0
  135. package/dist/location/data/en.cjs.map +1 -0
  136. package/dist/location/data/en.d.ts +9 -0
  137. package/dist/location/data/en.d.ts.map +1 -0
  138. package/dist/location/data/en.js +65 -0
  139. package/dist/location/data/en.js.map +1 -0
  140. package/dist/location/index.cjs +1 -0
  141. package/dist/location/index.d.ts +2 -0
  142. package/dist/location/index.d.ts.map +1 -0
  143. package/dist/location/index.js +2 -0
  144. package/dist/location/location.cjs +2 -0
  145. package/dist/location/location.cjs.map +1 -0
  146. package/dist/location/location.d.ts +28 -0
  147. package/dist/location/location.d.ts.map +1 -0
  148. package/dist/location/location.js +56 -0
  149. package/dist/location/location.js.map +1 -0
  150. package/dist/lorem/data.cjs +2 -0
  151. package/dist/lorem/data.cjs.map +1 -0
  152. package/dist/lorem/data.d.ts +5 -0
  153. package/dist/lorem/data.d.ts.map +1 -0
  154. package/dist/lorem/data.js +6 -0
  155. package/dist/lorem/data.js.map +1 -0
  156. package/dist/lorem/index.cjs +1 -0
  157. package/dist/lorem/index.d.ts +2 -0
  158. package/dist/lorem/index.d.ts.map +1 -0
  159. package/dist/lorem/index.js +2 -0
  160. package/dist/lorem/lorem.cjs +4 -0
  161. package/dist/lorem/lorem.cjs.map +1 -0
  162. package/dist/lorem/lorem.d.ts +18 -0
  163. package/dist/lorem/lorem.d.ts.map +1 -0
  164. package/dist/lorem/lorem.js +54 -0
  165. package/dist/lorem/lorem.js.map +1 -0
  166. package/dist/person/data/de.cjs +2 -0
  167. package/dist/person/data/de.cjs.map +1 -0
  168. package/dist/person/data/de.d.ts +12 -0
  169. package/dist/person/data/de.d.ts.map +1 -0
  170. package/dist/person/data/de.js +62 -0
  171. package/dist/person/data/de.js.map +1 -0
  172. package/dist/person/data/en.cjs +2 -0
  173. package/dist/person/data/en.cjs.map +1 -0
  174. package/dist/person/data/en.d.ts +12 -0
  175. package/dist/person/data/en.d.ts.map +1 -0
  176. package/dist/person/data/en.js +70 -0
  177. package/dist/person/data/en.js.map +1 -0
  178. package/dist/person/index.cjs +1 -0
  179. package/dist/person/index.d.ts +2 -0
  180. package/dist/person/index.d.ts.map +1 -0
  181. package/dist/person/index.js +2 -0
  182. package/dist/person/person.cjs +2 -0
  183. package/dist/person/person.cjs.map +1 -0
  184. package/dist/person/person.d.ts +9 -0
  185. package/dist/person/person.d.ts.map +1 -0
  186. package/dist/person/person.js +44 -0
  187. package/dist/person/person.js.map +1 -0
  188. package/dist/seed/create-seed.cjs +2 -0
  189. package/dist/seed/create-seed.cjs.map +1 -0
  190. package/dist/seed/create-seed.d.ts +17 -0
  191. package/dist/seed/create-seed.d.ts.map +1 -0
  192. package/dist/seed/create-seed.js +23 -0
  193. package/dist/seed/create-seed.js.map +1 -0
  194. package/dist/seed/index.cjs +1 -0
  195. package/dist/seed/index.d.ts +3 -0
  196. package/dist/seed/index.d.ts.map +1 -0
  197. package/dist/seed/index.js +3 -0
  198. package/dist/seed/mulberry32.cjs +2 -0
  199. package/dist/seed/mulberry32.cjs.map +1 -0
  200. package/dist/seed/mulberry32.d.ts +12 -0
  201. package/dist/seed/mulberry32.d.ts.map +1 -0
  202. package/dist/seed/mulberry32.js +13 -0
  203. package/dist/seed/mulberry32.js.map +1 -0
  204. package/dist/system/data.cjs +2 -0
  205. package/dist/system/data.cjs.map +1 -0
  206. package/dist/system/data.d.ts +29 -0
  207. package/dist/system/data.d.ts.map +1 -0
  208. package/dist/system/data.js +76 -0
  209. package/dist/system/data.js.map +1 -0
  210. package/dist/system/index.cjs +1 -0
  211. package/dist/system/index.d.ts +2 -0
  212. package/dist/system/index.d.ts.map +1 -0
  213. package/dist/system/index.js +2 -0
  214. package/dist/system/system.cjs +2 -0
  215. package/dist/system/system.cjs.map +1 -0
  216. package/dist/system/system.d.ts +32 -0
  217. package/dist/system/system.d.ts.map +1 -0
  218. package/dist/system/system.js +70 -0
  219. package/dist/system/system.js.map +1 -0
  220. package/dist/types.d.ts +41 -0
  221. package/dist/types.d.ts.map +1 -0
  222. package/package.json +155 -0
package/README.md ADDED
@@ -0,0 +1,89 @@
1
+ # @vielzeug/illusionist
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)
6
+
7
+ ## Installation
8
+
9
+ ```sh
10
+ pnpm add @vielzeug/illusionist
11
+ npm install @vielzeug/illusionist
12
+ yarn add @vielzeug/illusionist
13
+ ```
14
+
15
+ ## Quick Start
16
+
17
+ ```ts
18
+ import { createIllusion } from '@vielzeug/illusionist';
19
+ import { en } from '@vielzeug/illusionist/locales';
20
+
21
+ const illusion = createIllusion({ seed: 12345, locale: en });
22
+
23
+ illusion.person.fullName(); // "Ashley Harris"
24
+ illusion.internet.email(); // "samantha.sanchez@mail.com"
25
+ illusion.commerce.price(); // Money<USD>
26
+ illusion.date.past({ years: 5 }); // Temporal.ZonedDateTime
27
+ illusion.finance.iban(); // "IT0649896243786776403271206"
28
+ illusion.location.city(); // "Denver"
29
+ illusion.lorem.paragraph(); // "Dolor in fugiat anim dolor aute officia irure sunt..."
30
+ 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
+ ```
79
+
80
+ ## Documentation
81
+
82
+ - [Overview](https://vielzeug.dev/illusionist/)
83
+ - [Usage Guide](https://vielzeug.dev/illusionist/usage)
84
+ - [API Reference](https://vielzeug.dev/illusionist/api)
85
+ - [Examples](https://vielzeug.dev/illusionist/examples)
86
+
87
+ ## License
88
+
89
+ MIT © [Helmuth Saatkamp](https://github.com/helmuthdu) — part of the [Vielzeug](https://github.com/helmuthdu/vielzeug) monorepo.
package/dist/_dev.d.ts ADDED
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=_dev.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"_dev.d.ts","sourceRoot":"","sources":["../src/_dev.ts"],"names":[],"mappings":""}
@@ -0,0 +1,2 @@
1
+ function e(e,t=.5){return(e?.next()??crypto.getRandomValues(new Uint32Array(1))[0]/4294967296)<t}exports.boolean=e;
2
+ //# sourceMappingURL=boolean.cjs.map
@@ -0,0 +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"}
@@ -0,0 +1,4 @@
1
+ import type { RandomSource } from '@vielzeug/arsenal/random';
2
+ /** Generates a random boolean with an optional probability bias (0–1, default 0.5). */
3
+ export declare function boolean(source?: RandomSource, probability?: number): boolean;
4
+ //# sourceMappingURL=boolean.d.ts.map
@@ -0,0 +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"}
@@ -0,0 +1,8 @@
1
+ //#region src/_helpers/boolean.ts
2
+ function e(e, t = .5) {
3
+ return (e?.next() ?? crypto.getRandomValues(/* @__PURE__ */ new Uint32Array(1))[0] / 4294967296) < t;
4
+ }
5
+ //#endregion
6
+ export { e as boolean };
7
+
8
+ //# sourceMappingURL=boolean.js.map
@@ -0,0 +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"}
@@ -0,0 +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;
2
+ //# sourceMappingURL=float.cjs.map
@@ -0,0 +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"}
@@ -0,0 +1,9 @@
1
+ import type { RandomSource } from '@vielzeug/arsenal/random';
2
+ /**
3
+ * Generates a random float in `[min, max)`.
4
+ * Pass `min` = `max` for a constant; the result is still `min` (not `max`).
5
+ */
6
+ export declare function float(min: number, max: number, source?: RandomSource): number;
7
+ /** Generates a random float with a fixed number of decimal places. */
8
+ export declare function floatFixed(min: number, max: number, decimals?: number, source?: RandomSource): number;
9
+ //# sourceMappingURL=float.d.ts.map
@@ -0,0 +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"}
@@ -0,0 +1,14 @@
1
+ //#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;
6
+ }
7
+ function t(t, n, r = 2, i) {
8
+ let a = 10 ** r, o = e(t * a, n * a, i);
9
+ return Math.round(o) / a;
10
+ }
11
+ //#endregion
12
+ export { e as float, t as floatFixed };
13
+
14
+ //# sourceMappingURL=float.js.map
@@ -0,0 +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"}
@@ -0,0 +1,2 @@
1
+ let e=require("@vielzeug/arsenal/random");function t(t,n,r){return(0,e.random)(t,n,r)}exports.int=t;
2
+ //# sourceMappingURL=int.cjs.map
@@ -0,0 +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"}
@@ -0,0 +1,4 @@
1
+ import type { RandomSource } from '@vielzeug/arsenal/random';
2
+ /** Generates a random integer in `[min, max]` (inclusive). */
3
+ export declare function int(min: number, max: number, source?: RandomSource): number;
4
+ //# sourceMappingURL=int.d.ts.map
@@ -0,0 +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"}
@@ -0,0 +1,9 @@
1
+ import { random as e } from "@vielzeug/arsenal/random";
2
+ //#region src/_helpers/int.ts
3
+ function t(t, n, r) {
4
+ return e(t, n, r);
5
+ }
6
+ //#endregion
7
+ export { t as int };
8
+
9
+ //# sourceMappingURL=int.js.map
@@ -0,0 +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"}
@@ -0,0 +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;
2
+ //# sourceMappingURL=string.cjs.map
@@ -0,0 +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"}
@@ -0,0 +1,12 @@
1
+ import type { RandomSource } from '@vielzeug/arsenal/random';
2
+ /** Picks a random element from an array. Returns `undefined` for empty arrays. */
3
+ export declare function pick<T>(array: readonly T[], source?: RandomSource): T | undefined;
4
+ /** Generates a string of random digits with a fixed length. */
5
+ export declare function numericString(length: number, source?: RandomSource): string;
6
+ /** Generates a random hex string of the given length. */
7
+ export declare function hexString(length: number, source?: RandomSource): string;
8
+ /** Generates a random alphanumeric string of the given length. */
9
+ export declare function alphanumeric(length: number, source?: RandomSource): string;
10
+ /** Generates a random Base58 string (no 0, O, I, l) — used for Bitcoin-style addresses. */
11
+ export declare function base58String(length: number, source?: RandomSource): string;
12
+ //# sourceMappingURL=string.d.ts.map
@@ -0,0 +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"}
@@ -0,0 +1,38 @@
1
+ import { draw as e } from "@vielzeug/arsenal/random";
2
+ //#region src/_helpers/string.ts
3
+ function t(t, n) {
4
+ return e([...t], n);
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;
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;
18
+ }
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;
26
+ }
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;
34
+ }
35
+ //#endregion
36
+ export { i as alphanumeric, a as base58String, r as hexString, n as numericString, t as pick };
37
+
38
+ //# sourceMappingURL=string.js.map
@@ -0,0 +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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1,11 @@
1
+ //#region \0rolldown/runtime.js
2
+ var e = Object.defineProperty, t = (t, n) => {
3
+ let r = {};
4
+ for (var i in t) e(r, i, {
5
+ get: t[i],
6
+ enumerable: !0
7
+ });
8
+ return n || e(r, Symbol.toStringTag, { value: "Module" }), r;
9
+ };
10
+ //#endregion
11
+ export { t as __exportAll };
@@ -0,0 +1,2 @@
1
+ const e=require("../_virtual/_rolldown/runtime.cjs"),t=require("../_helpers/float.cjs"),n=require("../_helpers/int.cjs"),r=require("../_helpers/string.cjs"),i=require("./data.cjs");let a=require("@vielzeug/coins");var o=e.__exportAll({department:()=>f,price:()=>p,productAdjective:()=>c,productDescription:()=>m,productMaterial:()=>l,productName:()=>d,productNoun:()=>u}),s={EUR:a.EUR,GBP:a.GBP,USD:a.USD};function c(e){return r.pick(i.COMMERCE_DATA.productAdjectives,e.source)}function l(e){return r.pick(i.COMMERCE_DATA.productMaterials,e.source)}function u(e){return r.pick(i.COMMERCE_DATA.productNouns,e.source)}function d(e){return`${c(e)} ${l(e)} ${u(e)}`}function f(e){return r.pick(i.COMMERCE_DATA.departments,e.source)}function p(e,n={}){let r=n.min??.01,i=n.max??1e3,o=n.currency??`USD`,c=t.floatFixed(r,i,2,e.source);return(0,a.money)(c.toFixed(2),s[o])}function m(e){let t=n.int(1,2,e.source),a=[];for(let n=0;n<t;n++){let t=r.pick(i.COMMERCE_DATA.productAdjectives,e.source),n=r.pick(i.COMMERCE_DATA.productMaterials,e.source),o=r.pick(i.COMMERCE_DATA.productNouns,e.source),s=r.pick(i.COMMERCE_DATA.departments,e.source);a.push(`The ${t.toLowerCase()} ${n.toLowerCase()} ${o.toLowerCase()} is a great choice for your ${s.toLowerCase()} needs.`)}return a.join(` `)}Object.defineProperty(exports,"commerce_exports",{enumerable:!0,get:function(){return o}}),exports.department=f,exports.price=p,exports.productAdjective=c,exports.productDescription=m,exports.productMaterial=l,exports.productName=d,exports.productNoun=u;
2
+ //# sourceMappingURL=commerce.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"commerce.cjs","names":[],"sources":["../../src/commerce/commerce.ts"],"sourcesContent":["import { type Currency, EUR, GBP, type Money, money, USD } from '@vielzeug/coins';\n\nimport { floatFixed } from '../_helpers/float';\nimport { int } from '../_helpers/int';\nimport { pick } from '../_helpers/string';\nimport type { IllusionistContext } from '../types';\nimport { COMMERCE_DATA } from './data';\n\nconst CURRENCIES: Record<'USD' | 'EUR' | 'GBP', Currency> = { EUR, GBP, USD };\n\nexport type PriceOptions = {\n readonly min?: number;\n readonly max?: number;\n readonly currency?: 'USD' | 'EUR' | 'GBP';\n};\n\nexport function productAdjective(ctx: IllusionistContext): string {\n return pick(COMMERCE_DATA.productAdjectives, ctx.source)!;\n}\n\nexport function productMaterial(ctx: IllusionistContext): string {\n return pick(COMMERCE_DATA.productMaterials, ctx.source)!;\n}\n\nexport function productNoun(ctx: IllusionistContext): string {\n return pick(COMMERCE_DATA.productNouns, ctx.source)!;\n}\n\nexport function productName(ctx: IllusionistContext): string {\n return `${productAdjective(ctx)} ${productMaterial(ctx)} ${productNoun(ctx)}`;\n}\n\nexport function department(ctx: IllusionistContext): string {\n return pick(COMMERCE_DATA.departments, ctx.source)!;\n}\n\nexport function price(ctx: IllusionistContext, opts: PriceOptions = {}): Money {\n const min = opts.min ?? 0.01;\n const max = opts.max ?? 1000;\n const code = opts.currency ?? 'USD';\n const amount = floatFixed(min, max, 2, ctx.source);\n\n return money(amount.toFixed(2), CURRENCIES[code]);\n}\n\nexport function productDescription(ctx: IllusionistContext): string {\n const sentences = int(1, 2, ctx.source);\n const parts: string[] = [];\n\n for (let i = 0; i < sentences; i++) {\n const adjective = pick(COMMERCE_DATA.productAdjectives, ctx.source)!;\n const material = pick(COMMERCE_DATA.productMaterials, ctx.source)!;\n const noun = pick(COMMERCE_DATA.productNouns, ctx.source)!;\n const department = pick(COMMERCE_DATA.departments, ctx.source)!;\n\n parts.push(\n `The ${adjective.toLowerCase()} ${material.toLowerCase()} ${noun.toLowerC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AAA,cAAc,YAAa,EAAI,MAAM,EAE7D,EAAM,KACJ,OAAO,EAAU,YAAY,EAAE,GAAG,EAAS,YAAY,EAAE,GAAG,EAAK,YAAY,EAAE,8BAA8B,EAAW,YAAY,EAAE,QACxI,CACF,CAEA,OAAO,EAAM,KAAK,GAAG,CACvB"}
@@ -0,0 +1,15 @@
1
+ import { type Money } from '@vielzeug/coins';
2
+ import type { IllusionistContext } from '../types';
3
+ export type PriceOptions = {
4
+ readonly min?: number;
5
+ readonly max?: number;
6
+ readonly currency?: 'USD' | 'EUR' | 'GBP';
7
+ };
8
+ export declare function productAdjective(ctx: IllusionistContext): string;
9
+ export declare function productMaterial(ctx: IllusionistContext): string;
10
+ export declare function productNoun(ctx: IllusionistContext): string;
11
+ export declare function productName(ctx: IllusionistContext): string;
12
+ export declare function department(ctx: IllusionistContext): string;
13
+ export declare function price(ctx: IllusionistContext, opts?: PriceOptions): Money;
14
+ export declare function productDescription(ctx: IllusionistContext): string;
15
+ //# sourceMappingURL=commerce.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"commerce.d.ts","sourceRoot":"","sources":["../../src/commerce/commerce.ts"],"names":[],"mappings":"AAAA,OAAO,EAA2B,KAAK,KAAK,EAAc,MAAM,iBAAiB,CAAC;AAKlF,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAC;AAKnD,MAAM,MAAM,YAAY,GAAG;IACzB,QAAQ,CAAC,GAAG,CAAC,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,GAAG,CAAC,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,QAAQ,CAAC,EAAE,KAAK,GAAG,KAAK,GAAG,KAAK,CAAC;CAC3C,CAAC;AAEF,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,kBAAkB,GAAG,MAAM,CAEhE;AAED,wBAAgB,eAAe,CAAC,GAAG,EAAE,kBAAkB,GAAG,MAAM,CAE/D;AAED,wBAAgB,WAAW,CAAC,GAAG,EAAE,kBAAkB,GAAG,MAAM,CAE3D;AAED,wBAAgB,WAAW,CAAC,GAAG,EAAE,kBAAkB,GAAG,MAAM,CAE3D;AAED,wBAAgB,UAAU,CAAC,GAAG,EAAE,kBAAkB,GAAG,MAAM,CAE1D;AAED,wBAAgB,KAAK,CAAC,GAAG,EAAE,kBAAkB,EAAE,IAAI,GAAE,YAAiB,GAAG,KAAK,CAO7E;AAED,wBAAgB,kBAAkB,CAAC,GAAG,EAAE,kBAAkB,GAAG,MAAM,CAgBlE"}
@@ -0,0 +1,51 @@
1
+ import { __exportAll as e } from "../_virtual/_rolldown/runtime.js";
2
+ import { floatFixed as t } from "../_helpers/float.js";
3
+ import { int as n } from "../_helpers/int.js";
4
+ import { pick as r } from "../_helpers/string.js";
5
+ import { COMMERCE_DATA as i } from "./data.js";
6
+ import { EUR as a, GBP as o, USD as s, money as c } from "@vielzeug/coins";
7
+ //#region src/commerce/commerce.ts
8
+ var l = /* @__PURE__ */ e({
9
+ department: () => h,
10
+ price: () => g,
11
+ productAdjective: () => d,
12
+ productDescription: () => _,
13
+ productMaterial: () => f,
14
+ productName: () => m,
15
+ productNoun: () => p
16
+ }), u = {
17
+ EUR: a,
18
+ GBP: o,
19
+ USD: s
20
+ };
21
+ function d(e) {
22
+ return r(i.productAdjectives, e.source);
23
+ }
24
+ function f(e) {
25
+ return r(i.productMaterials, e.source);
26
+ }
27
+ function p(e) {
28
+ return r(i.productNouns, e.source);
29
+ }
30
+ function m(e) {
31
+ return `${d(e)} ${f(e)} ${p(e)}`;
32
+ }
33
+ function h(e) {
34
+ return r(i.departments, e.source);
35
+ }
36
+ function g(e, n = {}) {
37
+ let r = n.min ?? .01, i = n.max ?? 1e3, a = n.currency ?? "USD", o = t(r, i, 2, e.source);
38
+ return c(o.toFixed(2), u[a]);
39
+ }
40
+ function _(e) {
41
+ let t = n(1, 2, e.source), a = [];
42
+ for (let n = 0; n < t; n++) {
43
+ let t = r(i.productAdjectives, e.source), n = r(i.productMaterials, e.source), o = r(i.productNouns, e.source), s = r(i.departments, e.source);
44
+ a.push(`The ${t.toLowerCase()} ${n.toLowerCase()} ${o.toLowerCase()} is a great choice for your ${s.toLowerCase()} needs.`);
45
+ }
46
+ return a.join(" ");
47
+ }
48
+ //#endregion
49
+ export { l as commerce_exports, h as department, g as price, d as productAdjective, _ as productDescription, f as productMaterial, m as productName, p as productNoun };
50
+
51
+ //# sourceMappingURL=commerce.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"commerce.js","names":[],"sources":["../../src/commerce/commerce.ts"],"sourcesContent":["import { type Currency, EUR, GBP, type Money, money, USD } from '@vielzeug/coins';\n\nimport { floatFixed } from '../_helpers/float';\nimport { int } from '../_helpers/int';\nimport { pick } from '../_helpers/string';\nimport type { IllusionistContext } from '../types';\nimport { COMMERCE_DATA } from './data';\n\nconst CURRENCIES: Record<'USD' | 'EUR' | 'GBP', Currency> = { EUR, GBP, USD };\n\nexport type PriceOptions = {\n readonly min?: number;\n readonly max?: number;\n readonly currency?: 'USD' | 'EUR' | 'GBP';\n};\n\nexport function productAdjective(ctx: IllusionistContext): string {\n return pick(COMMERCE_DATA.productAdjectives, ctx.source)!;\n}\n\nexport function productMaterial(ctx: IllusionistContext): string {\n return pick(COMMERCE_DATA.productMaterials, ctx.source)!;\n}\n\nexport function productNoun(ctx: IllusionistContext): string {\n return pick(COMMERCE_DATA.productNouns, ctx.source)!;\n}\n\nexport function productName(ctx: IllusionistContext): string {\n return `${productAdjective(ctx)} ${productMaterial(ctx)} ${productNoun(ctx)}`;\n}\n\nexport function department(ctx: IllusionistContext): string {\n return pick(COMMERCE_DATA.departments, ctx.source)!;\n}\n\nexport function price(ctx: IllusionistContext, opts: PriceOptions = {}): Money {\n const min = opts.min ?? 0.01;\n const max = opts.max ?? 1000;\n const code = opts.currency ?? 'USD';\n const amount = floatFixed(min, max, 2, ctx.source);\n\n return money(amount.toFixed(2), CURRENCIES[code]);\n}\n\nexport function productDescription(ctx: IllusionistContext): string {\n const sentences = int(1, 2, ctx.source);\n const parts: string[] = [];\n\n for (let i = 0; i < sentences; i++) {\n const adjective = pick(COMMERCE_DATA.productAdjectives, ctx.source)!;\n const material = pick(COMMERCE_DATA.productMaterials, ctx.source)!;\n const noun = pick(COMMERCE_DATA.productNouns, ctx.source)!;\n const department = pick(COMMERCE_DATA.departments, ctx.source)!;\n\n parts.push(\n `The ${adjective.toLowerCase()} ${material.toLowerCase()} ${noun.toLowerCase()} is a great choice for your ${department.toLowerCase()} needs.`,\n );\n }\n\n return parts.join(' ');\n}\n"],"mappings":";;;;;;;;;;;;;;;IAQM,IAAsD;CAAE;CAAK;CAAK;AAAI;AAQ5E,SAAgB,EAAiB,GAAiC;CAChE,OAAO,EAAK,EAAc,mBAAmB,EAAI,MAAM;AACzD;AAEA,SAAgB,EAAgB,GAAiC;CAC/D,OAAO,EAAK,EAAc,kBAAkB,EAAI,MAAM;AACxD;AAEA,SAAgB,EAAY,GAAiC;CAC3D,OAAO,EAAK,EAAc,cAAc,EAAI,MAAM;AACpD;AAEA,SAAgB,EAAY,GAAiC;CAC3D,OAAO,GAAG,EAAiB,CAAG,EAAE,GAAG,EAAgB,CAAG,EAAE,GAAG,EAAY,CAAG;AAC5E;AAEA,SAAgB,EAAW,GAAiC;CAC1D,OAAO,EAAK,EAAc,aAAa,EAAI,MAAM;AACnD;AAEA,SAAgB,EAAM,GAAyB,IAAqB,CAAC,GAAU;CAC7E,IAAM,IAAM,EAAK,OAAO,KAClB,IAAM,EAAK,OAAO,KAClB,IAAO,EAAK,YAAY,OACxB,IAAS,EAAW,GAAK,GAAK,GAAG,EAAI,MAAM;CAEjD,OAAO,EAAM,EAAO,QAAQ,CAAC,GAAG,EAAW,EAAK;AAClD;AAEA,SAAgB,EAAmB,GAAiC;CAClE,IAAM,IAAY,EAAI,GAAG,GAAG,EAAI,MAAM,GAChC,IAAkB,CAAC;CAEzB,KAAK,IAAI,IAAI,GAAG,IAAI,GAAW,KAAK;EAClC,IAAM,IAAY,EAAK,EAAc,mBAAmB,EAAI,MAAM,GAC5D,IAAW,EAAK,EAAc,kBAAkB,EAAI,MAAM,GAC1D,IAAO,EAAK,EAAc,cAAc,EAAI,MAAM,GAClD,IAAa,EAAK,EAAc,aAAa,EAAI,MAAM;EAE7D,EAAM,KACJ,OAAO,EAAU,YAAY,EAAE,GAAG,EAAS,YAAY,EAAE,GAAG,EAAK,YAAY,EAAE,8BAA8B,EAAW,YAAY,EAAE,QACxI;CACF;CAEA,OAAO,EAAM,KAAK,GAAG;AACvB"}
@@ -0,0 +1,2 @@
1
+ var e={departments:[`Books`,`Movies`,`Music`,`Games`,`Electronics`,`Computers`,`Home`,`Garden`,`Tools`,`Grocery`,`Health`,`Beauty`,`Toys`,`Kids`,`Baby`,`Clothing`,`Shoes`,`Jewelry`,`Sports`,`Outdoors`,`Automotive`],productAdjectives:[`Small`,`Ergonomic`,`Rustic`,`Intelligent`,`Gorgeous`,`Incredible`,`Fantastic`,`Practical`,`Sleek`,`Awesome`,`Generic`,`Handmade`,`Licensed`,`Refined`,`Unbranded`,`Tasty`],productMaterials:[`Steel`,`Wooden`,`Concrete`,`Plastic`,`Cotton`,`Granite`,`Rubber`,`Metal`,`Soft`,`Fresh`,`Frozen`],productNouns:[`Chair`,`Car`,`Computer`,`Gloves`,`Pants`,`Shirt`,`Table`,`Shoes`,`Hat`,`Plate`,`Knife`,`Bottle`,`Coat`,`Lamp`,`Keyboard`,`Bag`,`Bench`,`Clock`,`Watch`,`Wallet`]};exports.COMMERCE_DATA=e;
2
+ //# sourceMappingURL=data.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"data.cjs","names":[],"sources":["../../src/commerce/data.ts"],"sourcesContent":["export const COMMERCE_DATA = {\n departments: [\n 'Books',\n 'Movies',\n 'Music',\n 'Games',\n 'Electronics',\n 'Computers',\n 'Home',\n 'Garden',\n 'Tools',\n 'Grocery',\n 'Health',\n 'Beauty',\n 'Toys',\n 'Kids',\n 'Baby',\n 'Clothing',\n 'Shoes',\n 'Jewelry',\n 'Sports',\n 'Outdoors',\n 'Automotive',\n ],\n productAdjectives: [\n 'Small',\n 'Ergonomic',\n 'Rustic',\n 'Intelligent',\n 'Gorgeous',\n 'Incredible',\n 'Fantastic',\n 'Practical',\n 'Sleek',\n 'Awesome',\n 'Generic',\n 'Handmade',\n 'Licensed',\n 'Refined',\n 'Unbranded',\n 'Tasty',\n ],\n productMaterials: [\n 'Steel',\n 'Wooden',\n 'Concrete',\n 'Plastic',\n 'Cotton',\n 'Granite',\n 'Rubber',\n 'Metal',\n 'Soft',\n 'Fresh',\n 'Frozen',\n ],\n productNouns: [\n 'Chair',\n 'Car',\n 'Computer',\n 'Gloves',\n 'Pants',\n 'Shirt',\n 'Table',\n 'Shoes',\n 'Hat',\n 'Plate',\n 'Knife',\n 'Bottle',\n 'Coat',\n 'Lamp',\n 'Keyboard',\n 'Bag',\n 'Bench',\n 'Clock',\n 'Watch',\n 'Wallet',\n ],\n} as const;\n"],"mappings":"AAAA,IAAa,EAAgB,CAC3B,YAAa,CACX,QACA,SACA,QACA,QACA,cACA,YACA,OACA,SACA,QACA,UACA,SACA,SACA,OACA,OACA,OACA,WACA,QACA,UACA,SACA,WACA,YACF,EACA,kBAAmB,CACjB,QACA,YACA,SACA,cACA,WACA,aACA,YACA,YACA,QACA,UACA,UACA,WACA,WACA,UACA,YACA,OACF,EACA,iBAAkB,CAChB,QACA,SACA,WACA,UACA,SACA,UACA,SACA,QACA,OACA,QACA,QACF,EACA,aAAc,CACZ,QACA,MACA,WACA,SACA,QACA,QACA,QACA,QACA,MACA,QACA,QACA,SACA,OACA,OACA,WACA,MACA,QACA,QACA,QACA,QACF,CACF"}
@@ -0,0 +1,7 @@
1
+ export declare const COMMERCE_DATA: {
2
+ readonly departments: readonly ["Books", "Movies", "Music", "Games", "Electronics", "Computers", "Home", "Garden", "Tools", "Grocery", "Health", "Beauty", "Toys", "Kids", "Baby", "Clothing", "Shoes", "Jewelry", "Sports", "Outdoors", "Automotive"];
3
+ readonly productAdjectives: readonly ["Small", "Ergonomic", "Rustic", "Intelligent", "Gorgeous", "Incredible", "Fantastic", "Practical", "Sleek", "Awesome", "Generic", "Handmade", "Licensed", "Refined", "Unbranded", "Tasty"];
4
+ readonly productMaterials: readonly ["Steel", "Wooden", "Concrete", "Plastic", "Cotton", "Granite", "Rubber", "Metal", "Soft", "Fresh", "Frozen"];
5
+ readonly productNouns: readonly ["Chair", "Car", "Computer", "Gloves", "Pants", "Shirt", "Table", "Shoes", "Hat", "Plate", "Knife", "Bottle", "Coat", "Lamp", "Keyboard", "Bag", "Bench", "Clock", "Watch", "Wallet"];
6
+ };
7
+ //# sourceMappingURL=data.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"data.d.ts","sourceRoot":"","sources":["../../src/commerce/data.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,aAAa;;;;;CA6EhB,CAAC"}
@@ -0,0 +1,83 @@
1
+ //#region src/commerce/data.ts
2
+ var e = {
3
+ departments: [
4
+ "Books",
5
+ "Movies",
6
+ "Music",
7
+ "Games",
8
+ "Electronics",
9
+ "Computers",
10
+ "Home",
11
+ "Garden",
12
+ "Tools",
13
+ "Grocery",
14
+ "Health",
15
+ "Beauty",
16
+ "Toys",
17
+ "Kids",
18
+ "Baby",
19
+ "Clothing",
20
+ "Shoes",
21
+ "Jewelry",
22
+ "Sports",
23
+ "Outdoors",
24
+ "Automotive"
25
+ ],
26
+ productAdjectives: [
27
+ "Small",
28
+ "Ergonomic",
29
+ "Rustic",
30
+ "Intelligent",
31
+ "Gorgeous",
32
+ "Incredible",
33
+ "Fantastic",
34
+ "Practical",
35
+ "Sleek",
36
+ "Awesome",
37
+ "Generic",
38
+ "Handmade",
39
+ "Licensed",
40
+ "Refined",
41
+ "Unbranded",
42
+ "Tasty"
43
+ ],
44
+ productMaterials: [
45
+ "Steel",
46
+ "Wooden",
47
+ "Concrete",
48
+ "Plastic",
49
+ "Cotton",
50
+ "Granite",
51
+ "Rubber",
52
+ "Metal",
53
+ "Soft",
54
+ "Fresh",
55
+ "Frozen"
56
+ ],
57
+ productNouns: [
58
+ "Chair",
59
+ "Car",
60
+ "Computer",
61
+ "Gloves",
62
+ "Pants",
63
+ "Shirt",
64
+ "Table",
65
+ "Shoes",
66
+ "Hat",
67
+ "Plate",
68
+ "Knife",
69
+ "Bottle",
70
+ "Coat",
71
+ "Lamp",
72
+ "Keyboard",
73
+ "Bag",
74
+ "Bench",
75
+ "Clock",
76
+ "Watch",
77
+ "Wallet"
78
+ ]
79
+ };
80
+ //#endregion
81
+ export { e as COMMERCE_DATA };
82
+
83
+ //# sourceMappingURL=data.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"data.js","names":[],"sources":["../../src/commerce/data.ts"],"sourcesContent":["export const COMMERCE_DATA = {\n departments: [\n 'Books',\n 'Movies',\n 'Music',\n 'Games',\n 'Electronics',\n 'Computers',\n 'Home',\n 'Garden',\n 'Tools',\n 'Grocery',\n 'Health',\n 'Beauty',\n 'Toys',\n 'Kids',\n 'Baby',\n 'Clothing',\n 'Shoes',\n 'Jewelry',\n 'Sports',\n 'Outdoors',\n 'Automotive',\n ],\n productAdjectives: [\n 'Small',\n 'Ergonomic',\n 'Rustic',\n 'Intelligent',\n 'Gorgeous',\n 'Incredible',\n 'Fantastic',\n 'Practical',\n 'Sleek',\n 'Awesome',\n 'Generic',\n 'Handmade',\n 'Licensed',\n 'Refined',\n 'Unbranded',\n 'Tasty',\n ],\n productMaterials: [\n 'Steel',\n 'Wooden',\n 'Concrete',\n 'Plastic',\n 'Cotton',\n 'Granite',\n 'Rubber',\n 'Metal',\n 'Soft',\n 'Fresh',\n 'Frozen',\n ],\n productNouns: [\n 'Chair',\n 'Car',\n 'Computer',\n 'Gloves',\n 'Pants',\n 'Shirt',\n 'Table',\n 'Shoes',\n 'Hat',\n 'Plate',\n 'Knife',\n 'Bottle',\n 'Coat',\n 'Lamp',\n 'Keyboard',\n 'Bag',\n 'Bench',\n 'Clock',\n 'Watch',\n 'Wallet',\n ],\n} as const;\n"],"mappings":";AAAA,IAAa,IAAgB;CAC3B,aAAa;EACX;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;CACF;CACA,mBAAmB;EACjB;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;CACF;CACA,kBAAkB;EAChB;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;CACF;CACA,cAAc;EACZ;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;CACF;AACF"}
@@ -0,0 +1 @@
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./commerce.cjs");exports.department=e.department,exports.price=e.price,exports.productAdjective=e.productAdjective,exports.productDescription=e.productDescription,exports.productMaterial=e.productMaterial,exports.productName=e.productName,exports.productNoun=e.productNoun;
@@ -0,0 +1,2 @@
1
+ export * from './commerce';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/commerce/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC"}
@@ -0,0 +1,2 @@
1
+ import { department as e, price as t, productAdjective as n, productDescription as r, productMaterial as i, productName as a, productNoun as o } from "./commerce.js";
2
+ export { e as department, t as price, n as productAdjective, r as productDescription, i as productMaterial, a as productName, o as productNoun };
@@ -0,0 +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;
2
+ //# sourceMappingURL=date.cjs.map
@@ -0,0 +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,MA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M,EACvC,CAKA,SAAgB,EAAM,EAAyB,EAAyB,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"}
@@ -0,0 +1,43 @@
1
+ import { Temporal } from '@vielzeug/tempo';
2
+ import type { IllusionistContext } from '../types';
3
+ type DateOptions = {
4
+ years?: number;
5
+ ref?: Temporal.ZonedDateTime;
6
+ };
7
+ /**
8
+ * Generates a past date within the given number of years from `ref` (default: now).
9
+ */
10
+ export declare function past(ctx: IllusionistContext, options?: DateOptions): Temporal.ZonedDateTime;
11
+ /**
12
+ * Generates a future date within the given number of years from `ref` (default: now).
13
+ */
14
+ export declare function future(ctx: IllusionistContext, options?: DateOptions): Temporal.ZonedDateTime;
15
+ /**
16
+ * Generates a recent date within the given number of days from `ref` (default: now).
17
+ */
18
+ export declare function recent(ctx: IllusionistContext, options?: {
19
+ days?: number;
20
+ ref?: Temporal.ZonedDateTime;
21
+ }): Temporal.ZonedDateTime;
22
+ /**
23
+ * Generates a date between `from` and `to`.
24
+ */
25
+ export declare function between(ctx: IllusionistContext, from: Temporal.ZonedDateTime, to: Temporal.ZonedDateTime): Temporal.ZonedDateTime;
26
+ /**
27
+ * Generates a random birthday — a date with a random year (default 18-80 years ago) and random month/day.
28
+ */
29
+ export declare function birthday(ctx: IllusionistContext, options?: {
30
+ minAge?: number;
31
+ maxAge?: number;
32
+ ref?: Temporal.ZonedDateTime;
33
+ }): Temporal.PlainDate;
34
+ /**
35
+ * Returns a random weekday name.
36
+ */
37
+ export declare function weekday(ctx: IllusionistContext, locale?: string): string;
38
+ /**
39
+ * Returns a random month name.
40
+ */
41
+ export declare function month(ctx: IllusionistContext, locale?: string): string;
42
+ export {};
43
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