@vielzeug/illusionist 26.10.15 → 26.10.17

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 (91) hide show
  1. package/LICENSE +21 -0
  2. package/dist/_helpers/boolean.cjs.map +1 -1
  3. package/dist/_helpers/boolean.js +8 -1
  4. package/dist/_helpers/boolean.js.map +1 -1
  5. package/dist/_helpers/float.cjs.map +1 -1
  6. package/dist/_helpers/float.js +12 -1
  7. package/dist/_helpers/float.js.map +1 -1
  8. package/dist/_helpers/int.cjs.map +1 -1
  9. package/dist/_helpers/int.js +8 -1
  10. package/dist/_helpers/int.js.map +1 -1
  11. package/dist/_helpers/next-float.js +1 -1
  12. package/dist/_helpers/string.cjs.map +1 -1
  13. package/dist/_helpers/string.js +28 -1
  14. package/dist/_helpers/string.js.map +1 -1
  15. package/dist/_virtual/_rolldown/runtime.js +11 -1
  16. package/dist/commerce/commerce.cjs.map +1 -1
  17. package/dist/commerce/commerce.js +50 -1
  18. package/dist/commerce/commerce.js.map +1 -1
  19. package/dist/commerce/data.cjs.map +1 -1
  20. package/dist/commerce/data.js +82 -1
  21. package/dist/commerce/data.js.map +1 -1
  22. package/dist/date/date.cjs.map +1 -1
  23. package/dist/date/date.js +92 -1
  24. package/dist/date/date.js.map +1 -1
  25. package/dist/errors.cjs.map +1 -1
  26. package/dist/errors.js +9 -1
  27. package/dist/errors.js.map +1 -1
  28. package/dist/factory.cjs.map +1 -1
  29. package/dist/factory.js +35 -1
  30. package/dist/factory.js.map +1 -1
  31. package/dist/finance/data.cjs.map +1 -1
  32. package/dist/finance/data.js +59 -1
  33. package/dist/finance/data.js.map +1 -1
  34. package/dist/finance/finance.cjs.map +1 -1
  35. package/dist/finance/finance.js +89 -1
  36. package/dist/finance/finance.js.map +1 -1
  37. package/dist/illusionist.cjs.map +1 -1
  38. package/dist/illusionist.iife.js.map +1 -1
  39. package/dist/illusionist.js +1177 -3
  40. package/dist/illusionist.js.map +1 -1
  41. package/dist/index.js +12 -1
  42. package/dist/internet/data.cjs.map +1 -1
  43. package/dist/internet/data.js +83 -1
  44. package/dist/internet/data.js.map +1 -1
  45. package/dist/internet/internet.cjs.map +1 -1
  46. package/dist/internet/internet.js +121 -1
  47. package/dist/internet/internet.js.map +1 -1
  48. package/dist/locales/de.cjs.map +1 -1
  49. package/dist/locales/de.js +11 -1
  50. package/dist/locales/de.js.map +1 -1
  51. package/dist/locales/en.cjs.map +1 -1
  52. package/dist/locales/en.js +11 -1
  53. package/dist/locales/en.js.map +1 -1
  54. package/dist/locales/index.js +3 -1
  55. package/dist/location/data/de.cjs.map +1 -1
  56. package/dist/location/data/de.js +81 -1
  57. package/dist/location/data/de.js.map +1 -1
  58. package/dist/location/data/en.cjs.map +1 -1
  59. package/dist/location/data/en.js +64 -1
  60. package/dist/location/data/en.js.map +1 -1
  61. package/dist/location/location.cjs.map +1 -1
  62. package/dist/location/location.js +56 -1
  63. package/dist/location/location.js.map +1 -1
  64. package/dist/lorem/data.cjs.map +1 -1
  65. package/dist/lorem/data.js +5 -1
  66. package/dist/lorem/data.js.map +1 -1
  67. package/dist/lorem/lorem.cjs.map +1 -1
  68. package/dist/lorem/lorem.js +53 -3
  69. package/dist/lorem/lorem.js.map +1 -1
  70. package/dist/person/data/de.cjs.map +1 -1
  71. package/dist/person/data/de.js +61 -1
  72. package/dist/person/data/de.js.map +1 -1
  73. package/dist/person/data/en.cjs.map +1 -1
  74. package/dist/person/data/en.js +69 -1
  75. package/dist/person/data/en.js.map +1 -1
  76. package/dist/person/person.cjs.map +1 -1
  77. package/dist/person/person.js +43 -1
  78. package/dist/person/person.js.map +1 -1
  79. package/dist/seed/create-seed.cjs.map +1 -1
  80. package/dist/seed/create-seed.js +21 -1
  81. package/dist/seed/create-seed.js.map +1 -1
  82. package/dist/seed/mulberry32.cjs.map +1 -1
  83. package/dist/seed/mulberry32.js +12 -1
  84. package/dist/seed/mulberry32.js.map +1 -1
  85. package/dist/system/data.cjs.map +1 -1
  86. package/dist/system/data.js +75 -1
  87. package/dist/system/data.js.map +1 -1
  88. package/dist/system/system.cjs.map +1 -1
  89. package/dist/system/system.js +68 -1
  90. package/dist/system/system.js.map +1 -1
  91. package/package.json +8 -7
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Helmuth Saatkamp
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -1 +1 @@
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,QAAQ,EAAuB,EAAc,GAAc,CACzE,OAAA,EAAO,EAAA,YAAA,CAAU,CAAM,EAAI,CAC7B"}
1
+ {"version":3,"file":"boolean.cjs","names":["nextFloat","_vielzeug_arsenal","source","probability"],"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":"A,mCAKA,SAAgB,QAAQ,EAAuB,EAAc,GAAc,CACzE,OAAA,EAAOA,EAAAA,YAAAA,CAAUE,CAAM,EAAIC,CAC7B,C"}
@@ -1,2 +1,9 @@
1
- import{nextFloat as e}from"./next-float.js";function boolean(t,n=.5){return e(t)<n}export{boolean};
1
+ import { nextFloat as e } from "./next-float.js";
2
+ //#region src/_helpers/boolean.ts
3
+ function boolean(t, n = .5) {
4
+ return e(t) < n;
5
+ }
6
+ //#endregion
7
+ export { boolean };
8
+
2
9
  //# sourceMappingURL=boolean.js.map
@@ -1 +1 @@
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":"4CAKA,SAAgB,QAAQ,EAAuB,EAAc,GAAc,CACzE,OAAO,EAAU,CAAM,EAAI,CAC7B"}
1
+ {"version":3,"file":"boolean.js","names":["nextFloat","source","probability"],"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,QAAQ,GAAuB,IAAc,IAAc;CACzE,OAAOA,EAAUC,CAAM,IAAIC;AAC7B"}
@@ -1 +1 @@
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,MAAM,EAAa,EAAa,EAA+B,CAG7E,OAFI,EAAM,EAAY,EAEf,GAAA,EAAM,EAAA,YAAA,CAAU,CAAM,GAAK,EAAM,EAC1C,CAGA,SAAgB,WAAW,EAAa,EAAa,EAAW,EAAG,EAA+B,CAChG,IAAM,EAAS,IAAM,EACf,EAAS,MAAM,EAAM,EAAQ,EAAM,EAAQ,CAAM,EAEvD,OAAO,KAAK,MAAM,CAAM,EAAI,CAC9B"}
1
+ {"version":3,"file":"float.cjs","names":["nextFloat","_vielzeug_arsenal","min","max","source","factor","decimals","scaled"],"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":"A,mCAQA,SAAgB,MAAM,EAAa,EAAa,EAA+B,CAG7E,OAFIE,EAAMC,EAAYD,EAEfA,GAAA,EAAMF,EAAAA,YAAAA,CAAUI,CAAM,GAAKD,EAAMD,EAC1C,CAGA,SAAgB,WAAW,EAAa,EAAa,EAAW,EAAG,EAA+B,CAChG,IAAMG,EAAS,IAAMC,EACfC,EAAS,MAAML,EAAMG,EAAQF,EAAME,EAAQD,CAAM,EAEvD,OAAO,KAAK,MAAMG,CAAM,EAAIF,CAC9B,C"}
@@ -1,2 +1,13 @@
1
- import{nextFloat as e}from"./next-float.js";function float(t,n,r){return t>n?t:t+e(r)*(n-t)}function floatFixed(e,t,n=2,r){let i=10**n,a=float(e*i,t*i,r);return Math.round(a)/i}export{float,floatFixed};
1
+ import { nextFloat as e } from "./next-float.js";
2
+ //#region src/_helpers/float.ts
3
+ function float(t, n, r) {
4
+ return t > n ? t : t + e(r) * (n - t);
5
+ }
6
+ function floatFixed(e, t, n = 2, r) {
7
+ let i = 10 ** n, a = float(e * i, t * i, r);
8
+ return Math.round(a) / i;
9
+ }
10
+ //#endregion
11
+ export { float, floatFixed };
12
+
2
13
  //# sourceMappingURL=float.js.map
@@ -1 +1 @@
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":"4CAQA,SAAgB,MAAM,EAAa,EAAa,EAA+B,CAG7E,OAFI,EAAM,EAAY,EAEf,EAAM,EAAU,CAAM,GAAK,EAAM,EAC1C,CAGA,SAAgB,WAAW,EAAa,EAAa,EAAW,EAAG,EAA+B,CAChG,IAAM,EAAS,IAAM,EACf,EAAS,MAAM,EAAM,EAAQ,EAAM,EAAQ,CAAM,EAEvD,OAAO,KAAK,MAAM,CAAM,EAAI,CAC9B"}
1
+ {"version":3,"file":"float.js","names":["min","max","nextFloat","source","factor","decimals","scaled"],"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,MAAM,GAAa,GAAa,GAA+B;CAG7E,OAFIA,IAAMC,IAAYD,IAEfA,IAAME,EAAUC,CAAM,KAAKF,IAAMD;AAC1C;AAGA,SAAgB,WAAW,GAAa,GAAa,IAAW,GAAG,GAA+B;CAChG,IAAMI,IAAS,MAAMC,GACfC,IAAS,MAAMN,IAAMI,GAAQH,IAAMG,GAAQD,CAAM;CAEvD,OAAO,KAAK,MAAMG,CAAM,IAAIF;AAC9B"}
@@ -1 +1 @@
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,IAAI,EAAa,EAAa,EAA+B,CAC3E,OAAA,EAAO,EAAA,OAAA,CAAO,EAAK,EAAK,CAAM,CAChC"}
1
+ {"version":3,"file":"int.cjs","names":["random","_vielzeug_arsenal","min","max","source"],"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":"A,mCAKA,SAAgB,IAAI,EAAa,EAAa,EAA+B,CAC3E,OAAA,EAAOA,EAAAA,OAAAA,CAAOE,EAAKC,EAAKC,CAAM,CAChC,C"}
@@ -1,2 +1,9 @@
1
- import{random as e}from"@vielzeug/arsenal";function int(t,n,r){return e(t,n,r)}export{int};
1
+ import { random as e } from "@vielzeug/arsenal";
2
+ //#region src/_helpers/int.ts
3
+ function int(t, n, r) {
4
+ return e(t, n, r);
5
+ }
6
+ //#endregion
7
+ export { int };
8
+
2
9
  //# sourceMappingURL=int.js.map
@@ -1 +1 @@
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":"2CAKA,SAAgB,IAAI,EAAa,EAAa,EAA+B,CAC3E,OAAO,EAAO,EAAK,EAAK,CAAM,CAChC"}
1
+ {"version":3,"file":"int.js","names":["random","min","max","source"],"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,IAAI,GAAa,GAAa,GAA+B;CAC3E,OAAOA,EAAOC,GAAKC,GAAKC,CAAM;AAChC"}
@@ -1 +1 @@
1
- import{randomFloat as e}from"@vielzeug/arsenal";export{e as nextFloat};
1
+ export { randomFloat as nextFloat } from "@vielzeug/arsenal";
@@ -1 +1 @@
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,KAAQ,EAAqB,EAAsC,CACjF,OAAO,EAAM,SAAW,EAAI,IAAA,GAAY,EAAM,KAAK,OAAA,EAAM,EAAA,YAAA,CAAU,CAAM,EAAI,EAAM,MAAM,EAC3F,CAGA,SAAgB,cAAc,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,UAAU,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,aAAa,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,aAAa,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
+ {"version":3,"file":"string.cjs","names":["nextFloat","_vielzeug_arsenal","array","source","result","length"],"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":"A,mCAKA,SAAgB,KAAQ,EAAqB,EAAsC,CACjF,OAAOE,EAAM,SAAW,EAAI,IAAA,GAAYA,EAAM,KAAK,OAAA,EAAMF,EAAAA,YAAAA,CAAUG,CAAM,EAAID,EAAM,MAAM,EAC3F,CAGA,SAAgB,cAAc,EAAgB,EAA+B,CAC3E,IAAIE,EAAS,GAEb,IAAK,IAAI,EAAI,EAAG,EAAIC,EAAQ,IAC1B,GAAU,KAAK,OAAA,EAAML,EAAAA,YAAAA,CAAUG,CAAM,EAAI,EAAE,EAG7C,OAAOC,CACT,CAGA,SAAgB,UAAU,EAAgB,EAA+B,CACvE,IACIA,EAAS,GAEb,IAAK,IAAI,EAAI,EAAG,EAAIC,EAAQ,IAC1B,GAAU,mBAAM,KAAK,OAAA,EAAML,EAAAA,YAAAA,CAAUG,CAAM,EAAI,EAAE,GAGnD,OAAOC,CACT,CAGA,SAAgB,aAAa,EAAgB,EAA+B,CAC1E,IACIA,EAAS,GAEb,IAAK,IAAI,EAAI,EAAG,EAAIC,EAAQ,IAC1B,GAAU,iEAAM,KAAK,OAAA,EAAML,EAAAA,YAAAA,CAAUG,CAAM,EAAI,EAAY,GAG7D,OAAOC,CACT,CAGA,SAAgB,aAAa,EAAgB,EAA+B,CAC1E,IACIA,EAAS,GAEb,IAAK,IAAI,EAAI,EAAG,EAAIC,EAAQ,IAC1B,GAAU,6DAAM,KAAK,OAAA,EAAML,EAAAA,YAAAA,CAAUG,CAAM,EAAI,EAAY,GAG7D,OAAOC,CACT,C"}
@@ -1,2 +1,29 @@
1
- import{nextFloat as e}from"./next-float.js";function pick(t,n){return t.length===0?void 0:t[Math.floor(e(n)*t.length)]}function numericString(t,n){let r=``;for(let i=0;i<t;i++)r+=Math.floor(e(n)*10);return r}function hexString(t,n){let r=``;for(let i=0;i<t;i++)r+=`0123456789abcdef`[Math.floor(e(n)*16)];return r}function alphanumeric(t,n){let r=``;for(let i=0;i<t;i++)r+=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789`[Math.floor(e(n)*62)];return r}function base58String(t,n){let r=``;for(let i=0;i<t;i++)r+=`123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz`[Math.floor(e(n)*58)];return r}export{alphanumeric,base58String,hexString,numericString,pick};
1
+ import { nextFloat as e } from "./next-float.js";
2
+ //#region src/_helpers/string.ts
3
+ function pick(t, n) {
4
+ return t.length === 0 ? void 0 : t[Math.floor(e(n) * t.length)];
5
+ }
6
+ function numericString(t, n) {
7
+ let r = "";
8
+ for (let i = 0; i < t; i++) r += Math.floor(e(n) * 10);
9
+ return r;
10
+ }
11
+ function hexString(t, n) {
12
+ let r = "";
13
+ for (let i = 0; i < t; i++) r += "0123456789abcdef"[Math.floor(e(n) * 16)];
14
+ return r;
15
+ }
16
+ function alphanumeric(t, n) {
17
+ let r = "";
18
+ for (let i = 0; i < t; i++) r += "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"[Math.floor(e(n) * 62)];
19
+ return r;
20
+ }
21
+ function base58String(t, n) {
22
+ let r = "";
23
+ for (let i = 0; i < t; i++) r += "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"[Math.floor(e(n) * 58)];
24
+ return r;
25
+ }
26
+ //#endregion
27
+ export { alphanumeric, base58String, hexString, numericString, pick };
28
+
2
29
  //# sourceMappingURL=string.js.map
@@ -1 +1 @@
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":"4CAKA,SAAgB,KAAQ,EAAqB,EAAsC,CACjF,OAAO,EAAM,SAAW,EAAI,IAAA,GAAY,EAAM,KAAK,MAAM,EAAU,CAAM,EAAI,EAAM,MAAM,EAC3F,CAGA,SAAgB,cAAc,EAAgB,EAA+B,CAC3E,IAAI,EAAS,GAEb,IAAK,IAAI,EAAI,EAAG,EAAI,EAAQ,IAC1B,GAAU,KAAK,MAAM,EAAU,CAAM,EAAI,EAAE,EAG7C,OAAO,CACT,CAGA,SAAgB,UAAU,EAAgB,EAA+B,CACvE,IACI,EAAS,GAEb,IAAK,IAAI,EAAI,EAAG,EAAI,EAAQ,IAC1B,GAAU,mBAAM,KAAK,MAAM,EAAU,CAAM,EAAI,EAAE,GAGnD,OAAO,CACT,CAGA,SAAgB,aAAa,EAAgB,EAA+B,CAC1E,IACI,EAAS,GAEb,IAAK,IAAI,EAAI,EAAG,EAAI,EAAQ,IAC1B,GAAU,iEAAM,KAAK,MAAM,EAAU,CAAM,EAAI,EAAY,GAG7D,OAAO,CACT,CAGA,SAAgB,aAAa,EAAgB,EAA+B,CAC1E,IACI,EAAS,GAEb,IAAK,IAAI,EAAI,EAAG,EAAI,EAAQ,IAC1B,GAAU,6DAAM,KAAK,MAAM,EAAU,CAAM,EAAI,EAAY,GAG7D,OAAO,CACT"}
1
+ {"version":3,"file":"string.js","names":["array","nextFloat","source","result","length"],"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,KAAQ,GAAqB,GAAsC;CACjF,OAAOA,EAAM,WAAW,IAAI,KAAA,IAAYA,EAAM,KAAK,MAAMC,EAAUC,CAAM,IAAIF,EAAM,MAAM;AAC3F;AAGA,SAAgB,cAAc,GAAgB,GAA+B;CAC3E,IAAIG,IAAS;CAEb,KAAK,IAAI,IAAI,GAAG,IAAIC,GAAQ,KAC1B,KAAU,KAAK,MAAMH,EAAUC,CAAM,IAAI,EAAE;CAG7C,OAAOC;AACT;AAGA,SAAgB,UAAU,GAAgB,GAA+B;CACvE,IACIA,IAAS;CAEb,KAAK,IAAI,IAAI,GAAG,IAAIC,GAAQ,KAC1B,KAAU,mBAAM,KAAK,MAAMH,EAAUC,CAAM,IAAI,EAAE;CAGnD,OAAOC;AACT;AAGA,SAAgB,aAAa,GAAgB,GAA+B;CAC1E,IACIA,IAAS;CAEb,KAAK,IAAI,IAAI,GAAG,IAAIC,GAAQ,KAC1B,KAAU,iEAAM,KAAK,MAAMH,EAAUC,CAAM,IAAI,EAAY;CAG7D,OAAOC;AACT;AAGA,SAAgB,aAAa,GAAgB,GAA+B;CAC1E,IACIA,IAAS;CAEb,KAAK,IAAI,IAAI,GAAG,IAAIC,GAAQ,KAC1B,KAAU,6DAAM,KAAK,MAAMH,EAAUC,CAAM,IAAI,EAAY;CAG7D,OAAOC;AACT"}
@@ -1 +1,11 @@
1
- var e=Object.defineProperty,__exportAll=(t,n)=>{let r={};for(var i in t)e(r,i,{get:t[i],enumerable:!0});return n||e(r,Symbol.toStringTag,{value:`Module`}),r};export{__exportAll};
1
+ //#region \0rolldown/runtime.js
2
+ var e = Object.defineProperty, __exportAll = (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 { __exportAll };
@@ -1 +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.toLowerCase()} is a great choice for your ${department.toLowerCase()} needs.`,\n );\n }\n\n return parts.join(' ');\n}\n"],"mappings":"mcAQM,EAAsD,CAAE,IAAA,EAAA,IAAK,IAAA,EAAA,IAAK,IAAA,EAAA,GAAI,EAQ5E,SAAgB,iBAAiB,EAAiC,CAChE,OAAO,EAAA,KAAK,EAAA,cAAc,kBAAmB,EAAI,MAAM,CACzD,CAEA,SAAgB,gBAAgB,EAAiC,CAC/D,OAAO,EAAA,KAAK,EAAA,cAAc,iBAAkB,EAAI,MAAM,CACxD,CAEA,SAAgB,YAAY,EAAiC,CAC3D,OAAO,EAAA,KAAK,EAAA,cAAc,aAAc,EAAI,MAAM,CACpD,CAEA,SAAgB,YAAY,EAAiC,CAC3D,MAAO,GAAG,iBAAiB,CAAG,EAAE,GAAG,gBAAgB,CAAG,EAAE,GAAG,YAAY,CAAG,GAC5E,CAEA,SAAgB,WAAW,EAAiC,CAC1D,OAAO,EAAA,KAAK,EAAA,cAAc,YAAa,EAAI,MAAM,CACnD,CAEA,SAAgB,MAAM,EAAyB,EAAqB,CAAC,EAAU,CAC7E,IAAM,EAAM,EAAK,KAAO,IAClB,EAAM,EAAK,KAAO,IAClB,EAAO,EAAK,UAAY,MACxB,EAAS,EAAA,WAAW,EAAK,EAAK,EAAG,EAAI,MAAM,EAEjD,OAAA,EAAO,EAAA,MAAA,CAAM,EAAO,QAAQ,CAAC,EAAG,EAAW,EAAK,CAClD,CAEA,SAAgB,mBAAmB,EAAiC,CAClE,IAAM,EAAY,EAAA,IAAI,EAAG,EAAG,EAAI,MAAM,EAChC,EAAkB,CAAC,EAEzB,IAAK,IAAI,EAAI,EAAG,EAAI,EAAW,IAAK,CAClC,IAAM,EAAY,EAAA,KAAK,EAAA,cAAc,kBAAmB,EAAI,MAAM,EAC5D,EAAW,EAAA,KAAK,EAAA,cAAc,iBAAkB,EAAI,MAAM,EAC1D,EAAO,EAAA,KAAK,EAAA,cAAc,aAAc,EAAI,MAAM,EAClD,EAAa,EAAA,KAAK,EAAA,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"}
1
+ {"version":3,"file":"commerce.cjs","names":["pick","COMMERCE_DATA","floatFixed","money","int","require_runtime","require_float","require_int","require_string","require_data","_vielzeug_coins","commerce_exports","CURRENCIES","ctx","min","opts","max","code","amount","sentences","parts","i","adjective","material","noun","department"],"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":"A,mcAQMY,EAAsD,CAAE,IAAAF,EAAA,IAAK,IAAAA,EAAA,IAAK,IAAAA,EAAA,GAAI,EAQ5E,SAAgB,iBAAiB,EAAiC,CAChE,OAAOV,EAAAA,KAAKC,EAAAA,cAAc,kBAAmBY,EAAI,MAAM,CACzD,CAEA,SAAgB,gBAAgB,EAAiC,CAC/D,OAAOb,EAAAA,KAAKC,EAAAA,cAAc,iBAAkBY,EAAI,MAAM,CACxD,CAEA,SAAgB,YAAY,EAAiC,CAC3D,OAAOb,EAAAA,KAAKC,EAAAA,cAAc,aAAcY,EAAI,MAAM,CACpD,CAEA,SAAgB,YAAY,EAAiC,CAC3D,MAAO,GAAG,iBAAiBA,CAAG,EAAE,GAAG,gBAAgBA,CAAG,EAAE,GAAG,YAAYA,CAAG,GAC5E,CAEA,SAAgB,WAAW,EAAiC,CAC1D,OAAOb,EAAAA,KAAKC,EAAAA,cAAc,YAAaY,EAAI,MAAM,CACnD,CAEA,SAAgB,MAAM,EAAyB,EAAqB,CAAC,EAAU,CAC7E,IAAMC,EAAMC,EAAK,KAAO,IAClBC,EAAMD,EAAK,KAAO,IAClBE,EAAOF,EAAK,UAAY,MACxBG,EAAShB,EAAAA,WAAWY,EAAKE,EAAK,EAAGH,EAAI,MAAM,EAEjD,OAAA,EAAOV,EAAAA,MAAAA,CAAMe,EAAO,QAAQ,CAAC,EAAGN,EAAWK,EAAK,CAClD,CAEA,SAAgB,mBAAmB,EAAiC,CAClE,IAAME,EAAYf,EAAAA,IAAI,EAAG,EAAGS,EAAI,MAAM,EAChCO,EAAkB,CAAC,EAEzB,IAAK,IAAIC,EAAI,EAAGA,EAAIF,EAAW,IAAK,CAClC,IAAMG,EAAYtB,EAAAA,KAAKC,EAAAA,cAAc,kBAAmBY,EAAI,MAAM,EAC5DU,EAAWvB,EAAAA,KAAKC,EAAAA,cAAc,iBAAkBY,EAAI,MAAM,EAC1DW,EAAOxB,EAAAA,KAAKC,EAAAA,cAAc,aAAcY,EAAI,MAAM,EAClDY,EAAazB,EAAAA,KAAKC,EAAAA,cAAc,YAAaY,EAAI,MAAM,EAE7DO,EAAM,KACJ,OAAOE,EAAU,YAAY,EAAE,GAAGC,EAAS,YAAY,EAAE,GAAGC,EAAK,YAAY,EAAE,8BAA8BC,EAAW,YAAY,EAAE,QACxI,CACF,CAEA,OAAOL,EAAM,KAAK,GAAG,CACvB,C"}
@@ -1,2 +1,51 @@
1
- import{__exportAll as e}from"../_virtual/_rolldown/runtime.js";import{floatFixed as t}from"../_helpers/float.js";import{int as n}from"../_helpers/int.js";import{pick as r}from"../_helpers/string.js";import{COMMERCE_DATA as i}from"./data.js";import{EUR as a,GBP as o,USD as s,money as c}from"@vielzeug/coins";var l=e({department:()=>department,price:()=>price,productAdjective:()=>productAdjective,productDescription:()=>productDescription,productMaterial:()=>productMaterial,productName:()=>productName,productNoun:()=>productNoun}),u={EUR:a,GBP:o,USD:s};function productAdjective(e){return r(i.productAdjectives,e.source)}function productMaterial(e){return r(i.productMaterials,e.source)}function productNoun(e){return r(i.productNouns,e.source)}function productName(e){return`${productAdjective(e)} ${productMaterial(e)} ${productNoun(e)}`}function department(e){return r(i.departments,e.source)}function price(e,n={}){let r=n.min??.01,i=n.max??1e3,a=n.currency??`USD`,o=t(r,i,2,e.source);return c(o.toFixed(2),u[a])}function productDescription(e){let t=n(1,2,e.source),a=[];for(let n=0;n<t;n++){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);a.push(`The ${t.toLowerCase()} ${n.toLowerCase()} ${o.toLowerCase()} is a great choice for your ${s.toLowerCase()} needs.`)}return a.join(` `)}export{l as commerce_exports,department,price,productAdjective,productDescription,productMaterial,productName,productNoun};
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: () => department,
10
+ price: () => price,
11
+ productAdjective: () => productAdjective,
12
+ productDescription: () => productDescription,
13
+ productMaterial: () => productMaterial,
14
+ productName: () => productName,
15
+ productNoun: () => productNoun
16
+ }), u = {
17
+ EUR: a,
18
+ GBP: o,
19
+ USD: s
20
+ };
21
+ function productAdjective(e) {
22
+ return r(i.productAdjectives, e.source);
23
+ }
24
+ function productMaterial(e) {
25
+ return r(i.productMaterials, e.source);
26
+ }
27
+ function productNoun(e) {
28
+ return r(i.productNouns, e.source);
29
+ }
30
+ function productName(e) {
31
+ return `${productAdjective(e)} ${productMaterial(e)} ${productNoun(e)}`;
32
+ }
33
+ function department(e) {
34
+ return r(i.departments, e.source);
35
+ }
36
+ function price(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 productDescription(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, department, price, productAdjective, productDescription, productMaterial, productName, productNoun };
50
+
2
51
  //# sourceMappingURL=commerce.js.map
@@ -1 +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":"qhBAQM,EAAsD,CAAE,MAAK,MAAK,KAAI,EAQ5E,SAAgB,iBAAiB,EAAiC,CAChE,OAAO,EAAK,EAAc,kBAAmB,EAAI,MAAM,CACzD,CAEA,SAAgB,gBAAgB,EAAiC,CAC/D,OAAO,EAAK,EAAc,iBAAkB,EAAI,MAAM,CACxD,CAEA,SAAgB,YAAY,EAAiC,CAC3D,OAAO,EAAK,EAAc,aAAc,EAAI,MAAM,CACpD,CAEA,SAAgB,YAAY,EAAiC,CAC3D,MAAO,GAAG,iBAAiB,CAAG,EAAE,GAAG,gBAAgB,CAAG,EAAE,GAAG,YAAY,CAAG,GAC5E,CAEA,SAAgB,WAAW,EAAiC,CAC1D,OAAO,EAAK,EAAc,YAAa,EAAI,MAAM,CACnD,CAEA,SAAgB,MAAM,EAAyB,EAAqB,CAAC,EAAU,CAC7E,IAAM,EAAM,EAAK,KAAO,IAClB,EAAM,EAAK,KAAO,IAClB,EAAO,EAAK,UAAY,MACxB,EAAS,EAAW,EAAK,EAAK,EAAG,EAAI,MAAM,EAEjD,OAAO,EAAM,EAAO,QAAQ,CAAC,EAAG,EAAW,EAAK,CAClD,CAEA,SAAgB,mBAAmB,EAAiC,CAClE,IAAM,EAAY,EAAI,EAAG,EAAG,EAAI,MAAM,EAChC,EAAkB,CAAC,EAEzB,IAAK,IAAI,EAAI,EAAG,EAAI,EAAW,IAAK,CAClC,IAAM,EAAY,EAAK,EAAc,kBAAmB,EAAI,MAAM,EAC5D,EAAW,EAAK,EAAc,iBAAkB,EAAI,MAAM,EAC1D,EAAO,EAAK,EAAc,aAAc,EAAI,MAAM,EAClD,EAAa,EAAK,EAAc,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"}
1
+ {"version":3,"file":"commerce.js","names":["commerce_exports","CURRENCIES","pick","COMMERCE_DATA","ctx","min","opts","max","code","amount","floatFixed","money","sentences","int","parts","i","adjective","material","noun","department"],"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":";;;;;;;;;;;;;;;A,IAQMC,IAAsD;CAAE;CAAK;CAAK;AAAI;AAQ5E,SAAgB,iBAAiB,GAAiC;CAChE,OAAOC,EAAKC,EAAc,mBAAmBC,EAAI,MAAM;AACzD;AAEA,SAAgB,gBAAgB,GAAiC;CAC/D,OAAOF,EAAKC,EAAc,kBAAkBC,EAAI,MAAM;AACxD;AAEA,SAAgB,YAAY,GAAiC;CAC3D,OAAOF,EAAKC,EAAc,cAAcC,EAAI,MAAM;AACpD;AAEA,SAAgB,YAAY,GAAiC;CAC3D,OAAO,GAAG,iBAAiBA,CAAG,EAAE,GAAG,gBAAgBA,CAAG,EAAE,GAAG,YAAYA,CAAG;AAC5E;AAEA,SAAgB,WAAW,GAAiC;CAC1D,OAAOF,EAAKC,EAAc,aAAaC,EAAI,MAAM;AACnD;AAEA,SAAgB,MAAM,GAAyB,IAAqB,CAAC,GAAU;CAC7E,IAAMC,IAAMC,EAAK,OAAO,KAClBC,IAAMD,EAAK,OAAO,KAClBE,IAAOF,EAAK,YAAY,OACxBG,IAASC,EAAWL,GAAKE,GAAK,GAAGH,EAAI,MAAM;CAEjD,OAAOO,EAAMF,EAAO,QAAQ,CAAC,GAAGR,EAAWO,EAAK;AAClD;AAEA,SAAgB,mBAAmB,GAAiC;CAClE,IAAMI,IAAYC,EAAI,GAAG,GAAGT,EAAI,MAAM,GAChCU,IAAkB,CAAC;CAEzB,KAAK,IAAIC,IAAI,GAAGA,IAAIH,GAAW,KAAK;EAClC,IAAMI,IAAYd,EAAKC,EAAc,mBAAmBC,EAAI,MAAM,GAC5Da,IAAWf,EAAKC,EAAc,kBAAkBC,EAAI,MAAM,GAC1Dc,IAAOhB,EAAKC,EAAc,cAAcC,EAAI,MAAM,GAClDe,IAAajB,EAAKC,EAAc,aAAaC,EAAI,MAAM;EAE7D,EAAM,KACJ,OAAOY,EAAU,YAAY,EAAE,GAAGC,EAAS,YAAY,EAAE,GAAGC,EAAK,YAAY,EAAE,8BAA8BC,EAAW,YAAY,EAAE,QACxI;CACF;CAEA,OAAOL,EAAM,KAAK,GAAG;AACvB"}
@@ -1 +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"}
1
+ {"version":3,"file":"data.cjs","names":["COMMERCE_DATA"],"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,IAAaA,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,E"}
@@ -1,2 +1,83 @@
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`]};export{e as COMMERCE_DATA};
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
+
2
83
  //# sourceMappingURL=data.js.map
@@ -1 +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,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"}
1
+ {"version":3,"file":"data.js","names":["COMMERCE_DATA"],"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,IAAaA,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"}
@@ -1 +1 @@
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.source)]!;\n}\n"],"mappings":"8QAUA,SAAS,WAAW,EAAsD,CACxE,OAAO,GAAO,EAAA,SAAS,IAAI,iBAAiB,KAAK,CACnD,CAKA,SAAgB,KAAK,EAAyB,EAA+C,CAC3F,IAAM,EAAM,WAAW,GAAS,GAAG,EAE7B,GADQ,GAAS,OAAS,GACL,IAAM,GAAK,GAAK,GAG3C,OAAO,EAAI,IAAI,CAAE,QAAS,CAAC,EAAA,IAAI,EAAY,EAAY,EAAI,MAAM,CAAE,CAAC,CACtE,CAKA,SAAgB,OAAO,EAAyB,EAA+C,CAC7F,IAAM,EAAM,WAAW,GAAS,GAAG,EAE7B,GADQ,GAAS,OAAS,GACL,IAAM,GAAK,GAAK,GAE3C,OAAO,EAAI,IAAI,CAAE,QAAS,EAAA,IAAI,EAAG,EAAY,EAAI,MAAM,CAAE,CAAC,CAC5D,CAKA,SAAgB,OACd,EACA,EACwB,CACxB,IAAM,EAAM,WAAW,GAAS,GAAG,EAE7B,GADO,GAAS,MAAQ,GACJ,GAAK,GAAK,GAEpC,OAAO,EAAI,IAAI,CAAE,QAAS,CAAC,EAAA,IAAI,EAAG,EAAY,EAAI,MAAM,CAAE,CAAC,CAC7D,CAKA,SAAgB,QACd,EACA,EACA,EACwB,CACxB,IAAM,EAAS,EAAK,UAAU,CAAC,CAAC,iBAC1B,EAAO,EAAG,UAAU,CAAC,CAAC,iBAE5B,GAAI,EAAS,EACX,OAAO,EAGT,IAAM,EAAS,EAAO,EAChB,EAAc,OAAO,EAAS,WAAc,EAC5C,EAAgB,KAAK,MAAM,EAAI,OAAO,KAAK,EAAI,CAAW,EAEhE,OAAO,EAAK,IAAI,CAAE,QAAS,CAAc,CAAC,CAC5C,CAKA,SAAgB,SACd,EACA,EACoB,CACpB,IAAM,EAAM,WAAW,GAAS,GAAG,EAC7B,EAAS,GAAS,QAAU,GAC5B,EAAS,GAAS,QAAU,GAC5B,EAAM,EAAA,IAAI,EAAQ,EAAQ,EAAI,MAAM,EACpC,EAAQ,EAAA,IAAI,EAAG,GAAI,EAAI,MAAM,EAC7B,EAAM,EAAA,IAAI,EAAG,GAAI,EAAI,MAAM,EAEjC,OAAO,EAAI,YAAY,CAAC,CAAC,SAAS,CAAE,MAAO,CAAI,CAAC,CAAC,CAAC,KAAK,CAAE,MAAK,OAAM,CAAC,CACvE,CAKA,SAAgB,QAAQ,EAAyB,EAAyB,CAMxE,QAJY,GAAU,EAAI,OAAO,QAEvB,KAAO,CAAC,SAAU,WAAY,WAAY,aAAc,UAAW,UAAW,SAAS,EAAI,CAHvF,SAAU,UAAW,YAAa,WAAY,SAAU,WAAY,QAGmB,EAAA,CAEpF,EAAA,IAAI,EAAG,EAAG,EAAI,MAAM,EACvC,CAKA,SAAgB,MAAM,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"}
1
+ {"version":3,"file":"date.cjs","names":["Temporal","int","require_runtime","require_int","_vielzeug_tempo","date_exports","ref","options","maxSeconds","ctx","fromNs","from","toNs","to","spanNs","spanSeconds","offsetSeconds","minAge","maxAge","age","month","day","locale"],"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":"A,8QAUA,SAAS,WAAW,EAAsD,CACxE,OAAOM,GAAON,EAAAA,SAAS,IAAI,iBAAiB,KAAK,CACnD,CAKA,SAAgB,KAAK,EAAyB,EAA+C,CAC3F,IAAMM,EAAM,WAAWC,GAAS,GAAG,EAE7BC,GADQD,GAAS,OAAS,GACL,IAAM,GAAK,GAAK,GAG3C,OAAOD,EAAI,IAAI,CAAE,QAAS,CAACL,EAAAA,IAAI,EAAYO,EAAYC,EAAI,MAAM,CAAE,CAAC,CACtE,CAKA,SAAgB,OAAO,EAAyB,EAA+C,CAC7F,IAAMH,EAAM,WAAWC,GAAS,GAAG,EAE7BC,GADQD,GAAS,OAAS,GACL,IAAM,GAAK,GAAK,GAE3C,OAAOD,EAAI,IAAI,CAAE,QAASL,EAAAA,IAAI,EAAGO,EAAYC,EAAI,MAAM,CAAE,CAAC,CAC5D,CAKA,SAAgB,OACd,EACA,EACwB,CACxB,IAAMH,EAAM,WAAWC,GAAS,GAAG,EAE7BC,GADOD,GAAS,MAAQ,GACJ,GAAK,GAAK,GAEpC,OAAOD,EAAI,IAAI,CAAE,QAAS,CAACL,EAAAA,IAAI,EAAGO,EAAYC,EAAI,MAAM,CAAE,CAAC,CAC7D,CAKA,SAAgB,QACd,EACA,EACA,EACwB,CACxB,IAAMC,EAASC,EAAK,UAAU,CAAC,CAAC,iBAC1BC,EAAOC,EAAG,UAAU,CAAC,CAAC,iBAE5B,GAAIH,EAASE,EACX,OAAOD,EAGT,IAAMG,EAASF,EAAOF,EAChBK,EAAc,OAAOD,EAAS,WAAc,EAC5CE,EAAgB,KAAK,MAAMP,EAAI,OAAO,KAAK,EAAIM,CAAW,EAEhE,OAAOJ,EAAK,IAAI,CAAE,QAASK,CAAc,CAAC,CAC5C,CAKA,SAAgB,SACd,EACA,EACoB,CACpB,IAAMV,EAAM,WAAWC,GAAS,GAAG,EAC7BU,EAASV,GAAS,QAAU,GAC5BW,EAASX,GAAS,QAAU,GAC5BY,EAAMlB,EAAAA,IAAIgB,EAAQC,EAAQT,EAAI,MAAM,EACpCW,EAAQnB,EAAAA,IAAI,EAAG,GAAIQ,EAAI,MAAM,EAC7BY,EAAMpB,EAAAA,IAAI,EAAG,GAAIQ,EAAI,MAAM,EAEjC,OAAOH,EAAI,YAAY,CAAC,CAAC,SAAS,CAAE,MAAOa,CAAI,CAAC,CAAC,CAAC,KAAK,CAAE,MAAK,OAAM,CAAC,CACvE,CAKA,SAAgB,QAAQ,EAAyB,EAAyB,CAMxE,QAJYG,GAAUb,EAAI,OAAO,QAEvB,KAAO,CAAC,SAAU,WAAY,WAAY,aAAc,UAAW,UAAW,SAAS,EAAI,CAHvF,SAAU,UAAW,YAAa,WAAY,SAAU,WAAY,QAGmB,EAAA,CAEpFR,EAAAA,IAAI,EAAG,EAAGQ,EAAI,MAAM,EACvC,CAKA,SAAgB,MAAM,EAAyB,EAAyB,CAkCtE,QAnBYa,GAAUb,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,CAEWR,EAAAA,IAAI,EAAG,GAAIQ,EAAI,MAAM,EACxC,C"}
package/dist/date/date.js CHANGED
@@ -1,2 +1,93 @@
1
- import{__exportAll as e}from"../_virtual/_rolldown/runtime.js";import{int as t}from"../_helpers/int.js";import{Temporal as n}from"@vielzeug/tempo";var r=e({between:()=>between,birthday:()=>birthday,future:()=>future,month:()=>month,past:()=>past,recent:()=>recent,weekday:()=>weekday});function resolveRef(e){return e??n.Now.zonedDateTimeISO(`UTC`)}function past(e,n){let r=resolveRef(n?.ref),i=(n?.years??1)*365*24*60*60;return r.add({seconds:-t(1,i,e.source)})}function future(e,n){let r=resolveRef(n?.ref),i=(n?.years??1)*365*24*60*60;return r.add({seconds:t(1,i,e.source)})}function recent(e,n){let r=resolveRef(n?.ref),i=(n?.days??1)*24*60*60;return r.add({seconds:-t(1,i,e.source)})}function between(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 birthday(e,n){let r=resolveRef(n?.ref),i=n?.minAge??18,a=n?.maxAge??80,o=t(i,a,e.source),s=t(1,12,e.source),c=t(1,28,e.source);return r.toPlainDate().subtract({years:o}).with({day:c,month:s})}function weekday(e,n){return((n??e.locale.code)===`de`?[`Montag`,`Dienstag`,`Mittwoch`,`Donnerstag`,`Freitag`,`Samstag`,`Sonntag`]:[`Monday`,`Tuesday`,`Wednesday`,`Thursday`,`Friday`,`Saturday`,`Sunday`])[t(0,6,e.source)]}function month(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(0,11,e.source)]}export{between,birthday,r as date_exports,future,month,past,recent,weekday};
1
+ import { __exportAll as e } from "../_virtual/_rolldown/runtime.js";
2
+ import { int as t } from "../_helpers/int.js";
3
+ import { Temporal as n } from "@vielzeug/tempo";
4
+ //#region src/date/date.ts
5
+ var r = /* @__PURE__ */ e({
6
+ between: () => between,
7
+ birthday: () => birthday,
8
+ future: () => future,
9
+ month: () => month,
10
+ past: () => past,
11
+ recent: () => recent,
12
+ weekday: () => weekday
13
+ });
14
+ function resolveRef(e) {
15
+ return e ?? n.Now.zonedDateTimeISO("UTC");
16
+ }
17
+ function past(e, n) {
18
+ let r = resolveRef(n?.ref), i = (n?.years ?? 1) * 365 * 24 * 60 * 60;
19
+ return r.add({ seconds: -t(1, i, e.source) });
20
+ }
21
+ function future(e, n) {
22
+ let r = resolveRef(n?.ref), i = (n?.years ?? 1) * 365 * 24 * 60 * 60;
23
+ return r.add({ seconds: t(1, i, e.source) });
24
+ }
25
+ function recent(e, n) {
26
+ let r = resolveRef(n?.ref), i = (n?.days ?? 1) * 24 * 60 * 60;
27
+ return r.add({ seconds: -t(1, i, e.source) });
28
+ }
29
+ function between(e, t, n) {
30
+ let r = t.toInstant().epochNanoseconds, i = n.toInstant().epochNanoseconds;
31
+ if (r > i) return t;
32
+ let a = i - r, o = Number(a / 1000000000n), s = Math.floor(e.source.next() * o);
33
+ return t.add({ seconds: s });
34
+ }
35
+ function birthday(e, n) {
36
+ let r = resolveRef(n?.ref), i = n?.minAge ?? 18, a = n?.maxAge ?? 80, o = t(i, a, e.source), s = t(1, 12, e.source), c = t(1, 28, e.source);
37
+ return r.toPlainDate().subtract({ years: o }).with({
38
+ day: c,
39
+ month: s
40
+ });
41
+ }
42
+ function weekday(e, n) {
43
+ return ((n ?? e.locale.code) === "de" ? [
44
+ "Montag",
45
+ "Dienstag",
46
+ "Mittwoch",
47
+ "Donnerstag",
48
+ "Freitag",
49
+ "Samstag",
50
+ "Sonntag"
51
+ ] : [
52
+ "Monday",
53
+ "Tuesday",
54
+ "Wednesday",
55
+ "Thursday",
56
+ "Friday",
57
+ "Saturday",
58
+ "Sunday"
59
+ ])[t(0, 6, e.source)];
60
+ }
61
+ function month(e, n) {
62
+ return ((n ?? e.locale.code) === "de" ? [
63
+ "Januar",
64
+ "Februar",
65
+ "März",
66
+ "April",
67
+ "Mai",
68
+ "Juni",
69
+ "Juli",
70
+ "August",
71
+ "September",
72
+ "Oktober",
73
+ "November",
74
+ "Dezember"
75
+ ] : [
76
+ "January",
77
+ "February",
78
+ "March",
79
+ "April",
80
+ "May",
81
+ "June",
82
+ "July",
83
+ "August",
84
+ "September",
85
+ "October",
86
+ "November",
87
+ "December"
88
+ ])[t(0, 11, e.source)];
89
+ }
90
+ //#endregion
91
+ export { between, birthday, r as date_exports, future, month, past, recent, weekday };
92
+
2
93
  //# sourceMappingURL=date.js.map
@@ -1 +1 @@
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":"8RAUA,SAAS,WAAW,EAAsD,CACxE,OAAO,GAAO,EAAS,IAAI,iBAAiB,KAAK,CACnD,CAKA,SAAgB,KAAK,EAAyB,EAA+C,CAC3F,IAAM,EAAM,WAAW,GAAS,GAAG,EAE7B,GADQ,GAAS,OAAS,GACL,IAAM,GAAK,GAAK,GAG3C,OAAO,EAAI,IAAI,CAAE,QAAS,CAAC,EAAI,EAAY,EAAY,EAAI,MAAM,CAAE,CAAC,CACtE,CAKA,SAAgB,OAAO,EAAyB,EAA+C,CAC7F,IAAM,EAAM,WAAW,GAAS,GAAG,EAE7B,GADQ,GAAS,OAAS,GACL,IAAM,GAAK,GAAK,GAE3C,OAAO,EAAI,IAAI,CAAE,QAAS,EAAI,EAAG,EAAY,EAAI,MAAM,CAAE,CAAC,CAC5D,CAKA,SAAgB,OACd,EACA,EACwB,CACxB,IAAM,EAAM,WAAW,GAAS,GAAG,EAE7B,GADO,GAAS,MAAQ,GACJ,GAAK,GAAK,GAEpC,OAAO,EAAI,IAAI,CAAE,QAAS,CAAC,EAAI,EAAG,EAAY,EAAI,MAAM,CAAE,CAAC,CAC7D,CAKA,SAAgB,QACd,EACA,EACA,EACwB,CACxB,IAAM,EAAS,EAAK,UAAU,CAAC,CAAC,iBAC1B,EAAO,EAAG,UAAU,CAAC,CAAC,iBAE5B,GAAI,EAAS,EACX,OAAO,EAGT,IAAM,EAAS,EAAO,EAChB,EAAc,OAAO,EAAS,WAAc,EAC5C,EAAgB,KAAK,MAAM,EAAI,OAAO,KAAK,EAAI,CAAW,EAEhE,OAAO,EAAK,IAAI,CAAE,QAAS,CAAc,CAAC,CAC5C,CAKA,SAAgB,SACd,EACA,EACoB,CACpB,IAAM,EAAM,WAAW,GAAS,GAAG,EAC7B,EAAS,GAAS,QAAU,GAC5B,EAAS,GAAS,QAAU,GAC5B,EAAM,EAAI,EAAQ,EAAQ,EAAI,MAAM,EACpC,EAAQ,EAAI,EAAG,GAAI,EAAI,MAAM,EAC7B,EAAM,EAAI,EAAG,GAAI,EAAI,MAAM,EAEjC,OAAO,EAAI,YAAY,CAAC,CAAC,SAAS,CAAE,MAAO,CAAI,CAAC,CAAC,CAAC,KAAK,CAAE,MAAK,OAAM,CAAC,CACvE,CAKA,SAAgB,QAAQ,EAAyB,EAAyB,CAMxE,QAJY,GAAU,EAAI,OAAO,QAEvB,KAAO,CAAC,SAAU,WAAY,WAAY,aAAc,UAAW,UAAW,SAAS,EAAI,CAHvF,SAAU,UAAW,YAAa,WAAY,SAAU,WAAY,QAGmB,EAAA,CAEpF,EAAI,EAAG,EAAG,EAAI,MAAM,EACvC,CAKA,SAAgB,MAAM,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,EAAI,EAAG,GAAI,EAAI,MAAM,EACxC"}
1
+ {"version":3,"file":"date.js","names":["date_exports","ref","Temporal","options","maxSeconds","int","ctx","fromNs","from","toNs","to","spanNs","spanSeconds","offsetSeconds","minAge","maxAge","age","month","day","locale"],"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,WAAW,GAAsD;CACxE,OAAOC,KAAOC,EAAS,IAAI,iBAAiB,KAAK;AACnD;AAKA,SAAgB,KAAK,GAAyB,GAA+C;CAC3F,IAAMD,IAAM,WAAWE,GAAS,GAAG,GAE7BC,KADQD,GAAS,SAAS,KACL,MAAM,KAAK,KAAK;CAG3C,OAAOF,EAAI,IAAI,EAAE,SAAS,CAACI,EAAI,GAAYD,GAAYE,EAAI,MAAM,EAAE,CAAC;AACtE;AAKA,SAAgB,OAAO,GAAyB,GAA+C;CAC7F,IAAML,IAAM,WAAWE,GAAS,GAAG,GAE7BC,KADQD,GAAS,SAAS,KACL,MAAM,KAAK,KAAK;CAE3C,OAAOF,EAAI,IAAI,EAAE,SAASI,EAAI,GAAGD,GAAYE,EAAI,MAAM,EAAE,CAAC;AAC5D;AAKA,SAAgB,OACd,GACA,GACwB;CACxB,IAAML,IAAM,WAAWE,GAAS,GAAG,GAE7BC,KADOD,GAAS,QAAQ,KACJ,KAAK,KAAK;CAEpC,OAAOF,EAAI,IAAI,EAAE,SAAS,CAACI,EAAI,GAAGD,GAAYE,EAAI,MAAM,EAAE,CAAC;AAC7D;AAKA,SAAgB,QACd,GACA,GACA,GACwB;CACxB,IAAMC,IAASC,EAAK,UAAU,CAAC,CAAC,kBAC1BC,IAAOC,EAAG,UAAU,CAAC,CAAC;CAE5B,IAAIH,IAASE,GACX,OAAOD;CAGT,IAAMG,IAASF,IAAOF,GAChBK,IAAc,OAAOD,IAAS,WAAc,GAC5CE,IAAgB,KAAK,MAAMP,EAAI,OAAO,KAAK,IAAIM,CAAW;CAEhE,OAAOJ,EAAK,IAAI,EAAE,SAASK,EAAc,CAAC;AAC5C;AAKA,SAAgB,SACd,GACA,GACoB;CACpB,IAAMZ,IAAM,WAAWE,GAAS,GAAG,GAC7BW,IAASX,GAAS,UAAU,IAC5BY,IAASZ,GAAS,UAAU,IAC5Ba,IAAMX,EAAIS,GAAQC,GAAQT,EAAI,MAAM,GACpCW,IAAQZ,EAAI,GAAG,IAAIC,EAAI,MAAM,GAC7BY,IAAMb,EAAI,GAAG,IAAIC,EAAI,MAAM;CAEjC,OAAOL,EAAI,YAAY,CAAC,CAAC,SAAS,EAAE,OAAOe,EAAI,CAAC,CAAC,CAAC,KAAK;EAAE;EAAK;CAAM,CAAC;AACvE;AAKA,SAAgB,QAAQ,GAAyB,GAAyB;CAMxE,SAJYG,KAAUb,EAAI,OAAO,UAEvB,OAAO;EAAC;EAAU;EAAY;EAAY;EAAc;EAAW;EAAW;CAAS,IAAI;EAHvF;EAAU;EAAW;EAAa;EAAY;EAAU;EAAY;CAGmB,EAAA,CAEpFD,EAAI,GAAG,GAAGC,EAAI,MAAM;AACvC;AAKA,SAAgB,MAAM,GAAyB,GAAyB;CAkCtE,SAnBYa,KAAUb,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,CAEWD,EAAI,GAAG,IAAIC,EAAI,MAAM;AACxC"}
@@ -1 +1 @@
1
- {"version":3,"file":"errors.cjs","names":[],"sources":["../src/errors.ts"],"sourcesContent":["/** Base class for all illusionist errors. Use `instanceof IllusionistError` to catch any illusionist-originated error. */\nexport class IllusionistError extends Error {\n constructor(message: string, opts?: ErrorOptions) {\n super(message, opts);\n this.name = new.target.name;\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\n\n/** Thrown when the seeded random source produces an invalid value. */\nexport class IllusionistSeedError extends IllusionistError {}\n"],"mappings":"AACA,IAAa,iBAAb,cAAsC,KAAM,CAC1C,YAAY,EAAiB,EAAqB,CAChD,MAAM,EAAS,CAAI,EACnB,KAAK,KAAO,WAAW,KACvB,OAAO,eAAe,KAAM,WAAW,SAAS,CAClD,CACF,EAGa,qBAAb,cAA0C,gBAAiB,CAAC"}
1
+ {"version":3,"file":"errors.cjs","names":["message","opts"],"sources":["../src/errors.ts"],"sourcesContent":["/** Base class for all illusionist errors. Use `instanceof IllusionistError` to catch any illusionist-originated error. */\nexport class IllusionistError extends Error {\n constructor(message: string, opts?: ErrorOptions) {\n super(message, opts);\n this.name = new.target.name;\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\n\n/** Thrown when the seeded random source produces an invalid value. */\nexport class IllusionistSeedError extends IllusionistError {}\n"],"mappings":"AACA,IAAa,iBAAb,cAAsC,KAAM,CAC1C,YAAY,EAAiB,EAAqB,CAChD,MAAMA,EAASC,CAAI,EACnB,KAAK,KAAO,WAAW,KACvB,OAAO,eAAe,KAAM,WAAW,SAAS,CAClD,CACF,EAGa,qBAAb,cAA0C,gBAAiB,CAAC,E"}
package/dist/errors.js CHANGED
@@ -1,2 +1,10 @@
1
- var IllusionistError=class extends Error{constructor(e,t){super(e,t),this.name=new.target.name,Object.setPrototypeOf(this,new.target.prototype)}},IllusionistSeedError=class extends IllusionistError{};export{IllusionistError,IllusionistSeedError};
1
+ //#region src/errors.ts
2
+ var IllusionistError = class extends Error {
3
+ constructor(e, t) {
4
+ super(e, t), this.name = new.target.name, Object.setPrototypeOf(this, new.target.prototype);
5
+ }
6
+ }, IllusionistSeedError = class extends IllusionistError {};
7
+ //#endregion
8
+ export { IllusionistError, IllusionistSeedError };
9
+
2
10
  //# sourceMappingURL=errors.js.map