@vielzeug/illusionist 2.3.2 → 26.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -50
- package/dist/_helpers/boolean.cjs +1 -1
- package/dist/_helpers/boolean.cjs.map +1 -1
- package/dist/_helpers/boolean.d.ts +1 -1
- package/dist/_helpers/boolean.d.ts.map +1 -1
- package/dist/_helpers/boolean.js +1 -8
- package/dist/_helpers/boolean.js.map +1 -1
- package/dist/_helpers/float.cjs +1 -1
- package/dist/_helpers/float.cjs.map +1 -1
- package/dist/_helpers/float.d.ts +1 -1
- package/dist/_helpers/float.d.ts.map +1 -1
- package/dist/_helpers/float.js +1 -12
- package/dist/_helpers/float.js.map +1 -1
- package/dist/_helpers/int.cjs +1 -1
- package/dist/_helpers/int.cjs.map +1 -1
- package/dist/_helpers/int.d.ts +1 -1
- package/dist/_helpers/int.d.ts.map +1 -1
- package/dist/_helpers/int.js +1 -8
- package/dist/_helpers/int.js.map +1 -1
- package/dist/_helpers/next-float.d.ts +1 -3
- package/dist/_helpers/next-float.d.ts.map +1 -1
- package/dist/_helpers/next-float.js +1 -8
- package/dist/_helpers/string.cjs +1 -1
- package/dist/_helpers/string.cjs.map +1 -1
- package/dist/_helpers/string.d.ts +1 -1
- package/dist/_helpers/string.d.ts.map +1 -1
- package/dist/_helpers/string.js +1 -28
- package/dist/_helpers/string.js.map +1 -1
- package/dist/_virtual/_rolldown/runtime.cjs +1 -1
- package/dist/_virtual/_rolldown/runtime.js +1 -11
- package/dist/commerce/commerce.cjs +1 -1
- package/dist/commerce/commerce.cjs.map +1 -1
- package/dist/commerce/commerce.js +1 -50
- package/dist/commerce/commerce.js.map +1 -1
- package/dist/commerce/data.js +1 -82
- package/dist/commerce/data.js.map +1 -1
- package/dist/date/date.cjs +1 -1
- package/dist/date/date.cjs.map +1 -1
- package/dist/date/date.d.ts.map +1 -1
- package/dist/date/date.js +1 -92
- package/dist/date/date.js.map +1 -1
- package/dist/errors.cjs +1 -1
- package/dist/errors.cjs.map +1 -1
- package/dist/errors.js +1 -9
- package/dist/errors.js.map +1 -1
- package/dist/factory.cjs +1 -1
- package/dist/factory.cjs.map +1 -1
- package/dist/factory.d.ts +0 -5
- package/dist/factory.d.ts.map +1 -1
- package/dist/factory.js +1 -45
- package/dist/factory.js.map +1 -1
- package/dist/finance/data.js +1 -59
- package/dist/finance/data.js.map +1 -1
- package/dist/finance/finance.cjs +1 -1
- package/dist/finance/finance.cjs.map +1 -1
- package/dist/finance/finance.js +1 -89
- package/dist/finance/finance.js.map +1 -1
- package/dist/illusionist.cjs +3 -3
- package/dist/illusionist.cjs.map +1 -1
- package/dist/illusionist.iife.js +3 -3
- package/dist/illusionist.iife.js.map +1 -1
- package/dist/illusionist.js +3 -3
- package/dist/illusionist.js.map +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.js +1 -12
- package/dist/internet/data.js +1 -83
- package/dist/internet/data.js.map +1 -1
- package/dist/internet/internet.cjs +1 -1
- package/dist/internet/internet.cjs.map +1 -1
- package/dist/internet/internet.js +1 -120
- package/dist/internet/internet.js.map +1 -1
- package/dist/locales/de.js +1 -11
- package/dist/locales/de.js.map +1 -1
- package/dist/locales/en.js +1 -11
- package/dist/locales/en.js.map +1 -1
- package/dist/locales/index.js +1 -3
- package/dist/location/data/de.js +1 -81
- package/dist/location/data/de.js.map +1 -1
- package/dist/location/data/en.js +1 -64
- package/dist/location/data/en.js.map +1 -1
- package/dist/location/location.cjs +1 -1
- package/dist/location/location.cjs.map +1 -1
- package/dist/location/location.js +1 -56
- package/dist/location/location.js.map +1 -1
- package/dist/lorem/data.js +1 -5
- package/dist/lorem/data.js.map +1 -1
- package/dist/lorem/lorem.cjs +3 -3
- package/dist/lorem/lorem.cjs.map +1 -1
- package/dist/lorem/lorem.js +3 -53
- package/dist/lorem/lorem.js.map +1 -1
- package/dist/person/data/de.js +1 -61
- package/dist/person/data/de.js.map +1 -1
- package/dist/person/data/en.js +1 -69
- package/dist/person/data/en.js.map +1 -1
- package/dist/person/person.cjs +1 -1
- package/dist/person/person.cjs.map +1 -1
- package/dist/person/person.js +1 -43
- package/dist/person/person.js.map +1 -1
- package/dist/seed/create-seed.cjs +1 -1
- package/dist/seed/create-seed.cjs.map +1 -1
- package/dist/seed/create-seed.d.ts +2 -2
- package/dist/seed/create-seed.d.ts.map +1 -1
- package/dist/seed/create-seed.js +1 -22
- package/dist/seed/create-seed.js.map +1 -1
- package/dist/seed/mulberry32.cjs +1 -1
- package/dist/seed/mulberry32.cjs.map +1 -1
- package/dist/seed/mulberry32.d.ts +1 -1
- package/dist/seed/mulberry32.d.ts.map +1 -1
- package/dist/seed/mulberry32.js +1 -12
- package/dist/seed/mulberry32.js.map +1 -1
- package/dist/system/data.js +1 -75
- package/dist/system/data.js.map +1 -1
- package/dist/system/system.cjs +1 -1
- package/dist/system/system.cjs.map +1 -1
- package/dist/system/system.d.ts.map +1 -1
- package/dist/system/system.js +1 -69
- package/dist/system/system.js.map +1 -1
- package/dist/types.d.ts +2 -3
- package/dist/types.d.ts.map +1 -1
- package/package.json +10 -82
- package/dist/_helpers/next-float.cjs +0 -2
- package/dist/_helpers/next-float.cjs.map +0 -1
- package/dist/_helpers/next-float.js.map +0 -1
- package/dist/commerce/index.cjs +0 -1
- package/dist/commerce/index.d.ts +0 -2
- package/dist/commerce/index.d.ts.map +0 -1
- package/dist/commerce/index.js +0 -2
- package/dist/date/index.cjs +0 -1
- package/dist/date/index.d.ts +0 -2
- package/dist/date/index.d.ts.map +0 -1
- package/dist/date/index.js +0 -2
- package/dist/finance/index.cjs +0 -1
- package/dist/finance/index.d.ts +0 -2
- package/dist/finance/index.d.ts.map +0 -1
- package/dist/finance/index.js +0 -2
- package/dist/internet/index.cjs +0 -1
- package/dist/internet/index.d.ts +0 -2
- package/dist/internet/index.d.ts.map +0 -1
- package/dist/internet/index.js +0 -2
- package/dist/location/index.cjs +0 -1
- package/dist/location/index.d.ts +0 -2
- package/dist/location/index.d.ts.map +0 -1
- package/dist/location/index.js +0 -2
- package/dist/lorem/index.cjs +0 -1
- package/dist/lorem/index.d.ts +0 -2
- package/dist/lorem/index.d.ts.map +0 -1
- package/dist/lorem/index.js +0 -2
- package/dist/person/index.cjs +0 -1
- package/dist/person/index.d.ts +0 -2
- package/dist/person/index.d.ts.map +0 -1
- package/dist/person/index.js +0 -2
- package/dist/seed/index.cjs +0 -1
- package/dist/seed/index.d.ts +0 -3
- package/dist/seed/index.d.ts.map +0 -1
- package/dist/seed/index.js +0 -3
- package/dist/system/index.cjs +0 -1
- package/dist/system/index.d.ts +0 -2
- package/dist/system/index.d.ts.map +0 -1
- package/dist/system/index.js +0 -2
package/README.md
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
# @vielzeug/illusionist
|
|
2
2
|
|
|
3
|
-
> Typed, deterministic, locale-aware fake data generator with seeded PRNG
|
|
4
|
-
|
|
5
|
-
[](https://www.npmjs.com/package/@vielzeug/illusionist) [](https://opensource.org/licenses/MIT)
|
|
3
|
+
> Typed, deterministic, locale-aware fake data generator with seeded PRNG
|
|
6
4
|
|
|
7
5
|
## Installation
|
|
8
6
|
|
|
@@ -28,53 +26,6 @@ illusion.finance.iban(); // "IT0649896243786776403271206"
|
|
|
28
26
|
illusion.location.city(); // "Denver"
|
|
29
27
|
illusion.lorem.paragraph(); // "Dolor in fugiat anim dolor aute officia irure sunt..."
|
|
30
28
|
illusion.system.semver(); // "7.4.0"
|
|
31
|
-
|
|
32
|
-
illusion.dispose(); // [Symbol.dispose]() also works
|
|
33
|
-
```
|
|
34
|
-
|
|
35
|
-
## Entry Points
|
|
36
|
-
|
|
37
|
-
- `@vielzeug/illusionist` — curated root exports + `createIllusion` factory
|
|
38
|
-
- `@vielzeug/illusionist/person` — names, genders, job titles
|
|
39
|
-
- `@vielzeug/illusionist/internet` — emails, URLs, IPs, user agents
|
|
40
|
-
- `@vielzeug/illusionist/commerce` — product names, prices, departments
|
|
41
|
-
- `@vielzeug/illusionist/date` — past/future dates, birthdays, weekdays
|
|
42
|
-
- `@vielzeug/illusionist/finance` — IBANs, credit cards, crypto addresses
|
|
43
|
-
- `@vielzeug/illusionist/location` — cities, streets, coordinates
|
|
44
|
-
- `@vielzeug/illusionist/lorem` — lorem ipsum text generation
|
|
45
|
-
- `@vielzeug/illusionist/system` — file paths, semver, UUIDs, cron
|
|
46
|
-
- `@vielzeug/illusionist/seed` — `createSeed`, `mulberry32` PRNG
|
|
47
|
-
- `@vielzeug/illusionist/locales` — locale objects (`en`, `de`); tree-shakeable, import only what you use
|
|
48
|
-
|
|
49
|
-
## Seeded Determinism
|
|
50
|
-
|
|
51
|
-
Pass a `seed` for reproducible output — same seed always produces the same sequence across all categories. Omit `seed` for cryptographic randomness via `crypto.getRandomValues`.
|
|
52
|
-
|
|
53
|
-
```ts
|
|
54
|
-
const a = createIllusion({ seed: 'test-fixture', locale: en });
|
|
55
|
-
const b = createIllusion({ seed: 'test-fixture', locale: en });
|
|
56
|
-
|
|
57
|
-
a.person.fullName() === b.person.fullName(); // true
|
|
58
|
-
```
|
|
59
|
-
|
|
60
|
-
## Locale Support
|
|
61
|
-
|
|
62
|
-
Initial locales are explicit, tree-shakeable objects exported from `@vielzeug/illusionist/locales`. Locale data ships only for locales you import; the root package includes no default locale.
|
|
63
|
-
|
|
64
|
-
```ts
|
|
65
|
-
import { de } from '@vielzeug/illusionist/locales';
|
|
66
|
-
|
|
67
|
-
const illusion = createIllusion({ seed: 42, locale: de });
|
|
68
|
-
|
|
69
|
-
illusion.person.firstName(); // "Mathilda"
|
|
70
|
-
illusion.location.city(); // "Bielefeld"
|
|
71
|
-
```
|
|
72
|
-
|
|
73
|
-
For dynamic app switching, load the locale before creating the synchronous instance:
|
|
74
|
-
|
|
75
|
-
```ts
|
|
76
|
-
const { de } = await import('@vielzeug/illusionist/locales');
|
|
77
|
-
const illusion = createIllusion({ locale: de });
|
|
78
29
|
```
|
|
79
30
|
|
|
80
31
|
## Documentation
|
|
@@ -83,6 +34,7 @@ const illusion = createIllusion({ locale: de });
|
|
|
83
34
|
- [Usage Guide](https://vielzeug.dev/illusionist/usage)
|
|
84
35
|
- [API Reference](https://vielzeug.dev/illusionist/api)
|
|
85
36
|
- [Examples](https://vielzeug.dev/illusionist/examples)
|
|
37
|
+
- [Migration Guide](https://vielzeug.dev/illusionist/migration)
|
|
86
38
|
|
|
87
39
|
## License
|
|
88
40
|
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
let e=require("@vielzeug/arsenal");function boolean(t,n=.5){return(0,e.randomFloat)(t)<n}exports.boolean=boolean;
|
|
2
2
|
//# sourceMappingURL=boolean.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"boolean.cjs","names":[],"sources":["../../src/_helpers/boolean.ts"],"sourcesContent":["import type { RandomSource } from '
|
|
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,4 +1,4 @@
|
|
|
1
|
-
import type { RandomSource } from '
|
|
1
|
+
import type { RandomSource } from '../types';
|
|
2
2
|
/** Generates a random boolean with an optional probability bias (0–1, default 0.5). */
|
|
3
3
|
export declare function boolean(source?: RandomSource, probability?: number): boolean;
|
|
4
4
|
//# sourceMappingURL=boolean.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"boolean.d.ts","sourceRoot":"","sources":["../../src/_helpers/boolean.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"boolean.d.ts","sourceRoot":"","sources":["../../src/_helpers/boolean.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAI7C,uFAAuF;AACvF,wBAAgB,OAAO,CAAC,MAAM,CAAC,EAAE,YAAY,EAAE,WAAW,SAAM,GAAG,OAAO,CAEzE"}
|
package/dist/_helpers/boolean.js
CHANGED
|
@@ -1,9 +1,2 @@
|
|
|
1
|
-
import
|
|
2
|
-
//#region src/_helpers/boolean.ts
|
|
3
|
-
function t(t, n = .5) {
|
|
4
|
-
return e(t) < n;
|
|
5
|
-
}
|
|
6
|
-
//#endregion
|
|
7
|
-
export { t as boolean };
|
|
8
|
-
|
|
1
|
+
import{nextFloat as e}from"./next-float.js";function boolean(t,n=.5){return e(t)<n}export{boolean};
|
|
9
2
|
//# sourceMappingURL=boolean.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"boolean.js","names":[],"sources":["../../src/_helpers/boolean.ts"],"sourcesContent":["import type { RandomSource } from '
|
|
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"}
|
package/dist/_helpers/float.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
let e=require("@vielzeug/arsenal");function float(t,n,r){return t>n?t:t+(0,e.randomFloat)(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}exports.float=float,exports.floatFixed=floatFixed;
|
|
2
2
|
//# sourceMappingURL=float.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"float.cjs","names":[],"sources":["../../src/_helpers/float.ts"],"sourcesContent":["import type { RandomSource } from '
|
|
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"}
|
package/dist/_helpers/float.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"float.d.ts","sourceRoot":"","sources":["../../src/_helpers/float.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"float.d.ts","sourceRoot":"","sources":["../../src/_helpers/float.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAI7C;;;GAGG;AACH,wBAAgB,KAAK,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,YAAY,GAAG,MAAM,CAI7E;AAED,sEAAsE;AACtE,wBAAgB,UAAU,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,QAAQ,SAAI,EAAE,MAAM,CAAC,EAAE,YAAY,GAAG,MAAM,CAKhG"}
|
package/dist/_helpers/float.js
CHANGED
|
@@ -1,13 +1,2 @@
|
|
|
1
|
-
import
|
|
2
|
-
//#region src/_helpers/float.ts
|
|
3
|
-
function t(t, n, r) {
|
|
4
|
-
return t > n ? t : t + e(r) * (n - t);
|
|
5
|
-
}
|
|
6
|
-
function n(e, n, r = 2, i) {
|
|
7
|
-
let a = 10 ** r, o = t(e * a, n * a, i);
|
|
8
|
-
return Math.round(o) / a;
|
|
9
|
-
}
|
|
10
|
-
//#endregion
|
|
11
|
-
export { t as float, n as floatFixed };
|
|
12
|
-
|
|
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};
|
|
13
2
|
//# sourceMappingURL=float.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"float.js","names":[],"sources":["../../src/_helpers/float.ts"],"sourcesContent":["import type { RandomSource } from '
|
|
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"}
|
package/dist/_helpers/int.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
let e=require("@vielzeug/arsenal
|
|
1
|
+
let e=require("@vielzeug/arsenal");function int(t,n,r){return(0,e.random)(t,n,r)}exports.int=int;
|
|
2
2
|
//# sourceMappingURL=int.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"int.cjs","names":[],"sources":["../../src/_helpers/int.ts"],"sourcesContent":["import
|
|
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"}
|
package/dist/_helpers/int.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { RandomSource } from '
|
|
1
|
+
import type { RandomSource } from '../types';
|
|
2
2
|
/** Generates a random integer in `[min, max]` (inclusive). */
|
|
3
3
|
export declare function int(min: number, max: number, source?: RandomSource): number;
|
|
4
4
|
//# sourceMappingURL=int.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"int.d.ts","sourceRoot":"","sources":["../../src/_helpers/int.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"int.d.ts","sourceRoot":"","sources":["../../src/_helpers/int.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAE7C,8DAA8D;AAC9D,wBAAgB,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,YAAY,GAAG,MAAM,CAE3E"}
|
package/dist/_helpers/int.js
CHANGED
|
@@ -1,9 +1,2 @@
|
|
|
1
|
-
import
|
|
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
|
-
|
|
1
|
+
import{random as e}from"@vielzeug/arsenal";function int(t,n,r){return e(t,n,r)}export{int};
|
|
9
2
|
//# sourceMappingURL=int.js.map
|
package/dist/_helpers/int.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"int.js","names":[],"sources":["../../src/_helpers/int.ts"],"sourcesContent":["import
|
|
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,4 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
/** Returns a float in `[0, 1)` from the source, falling back to `crypto.getRandomValues` when unset. */
|
|
3
|
-
export declare function nextFloat(source?: RandomSource): number;
|
|
1
|
+
export { randomFloat as nextFloat } from '@vielzeug/arsenal';
|
|
4
2
|
//# sourceMappingURL=next-float.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"next-float.d.ts","sourceRoot":"","sources":["../../src/_helpers/next-float.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"next-float.d.ts","sourceRoot":"","sources":["../../src/_helpers/next-float.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,IAAI,SAAS,EAAE,MAAM,mBAAmB,CAAC"}
|
|
@@ -1,8 +1 @@
|
|
|
1
|
-
|
|
2
|
-
function e(e) {
|
|
3
|
-
return e?.next() ?? crypto.getRandomValues(/* @__PURE__ */ new Uint32Array(1))[0] / 4294967296;
|
|
4
|
-
}
|
|
5
|
-
//#endregion
|
|
6
|
-
export { e as nextFloat };
|
|
7
|
-
|
|
8
|
-
//# sourceMappingURL=next-float.js.map
|
|
1
|
+
import{randomFloat as e}from"@vielzeug/arsenal";export{e as nextFloat};
|
package/dist/_helpers/string.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
let e=require("@vielzeug/arsenal");function pick(t,n){return t.length===0?void 0:t[Math.floor((0,e.randomFloat)(n)*t.length)]}function numericString(t,n){let r=``;for(let i=0;i<t;i++)r+=Math.floor((0,e.randomFloat)(n)*10);return r}function hexString(t,n){let r=``;for(let i=0;i<t;i++)r+=`0123456789abcdef`[Math.floor((0,e.randomFloat)(n)*16)];return r}function alphanumeric(t,n){let r=``;for(let i=0;i<t;i++)r+=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789`[Math.floor((0,e.randomFloat)(n)*62)];return r}function base58String(t,n){let r=``;for(let i=0;i<t;i++)r+=`123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz`[Math.floor((0,e.randomFloat)(n)*58)];return r}exports.alphanumeric=alphanumeric,exports.base58String=base58String,exports.hexString=hexString,exports.numericString=numericString,exports.pick=pick;
|
|
2
2
|
//# sourceMappingURL=string.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"string.cjs","names":[],"sources":["../../src/_helpers/string.ts"],"sourcesContent":["import type { RandomSource } from '
|
|
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,4 +1,4 @@
|
|
|
1
|
-
import type { RandomSource } from '
|
|
1
|
+
import type { RandomSource } from '../types';
|
|
2
2
|
/** Picks a random element from a readonly array. Returns `undefined` for empty arrays. */
|
|
3
3
|
export declare function pick<T>(array: readonly T[], source?: RandomSource): T | undefined;
|
|
4
4
|
/** Generates a string of random digits with a fixed length. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"string.d.ts","sourceRoot":"","sources":["../../src/_helpers/string.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"string.d.ts","sourceRoot":"","sources":["../../src/_helpers/string.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAI7C,0FAA0F;AAC1F,wBAAgB,IAAI,CAAC,CAAC,EAAE,KAAK,EAAE,SAAS,CAAC,EAAE,EAAE,MAAM,CAAC,EAAE,YAAY,GAAG,CAAC,GAAG,SAAS,CAEjF;AAED,+DAA+D;AAC/D,wBAAgB,aAAa,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,YAAY,GAAG,MAAM,CAQ3E;AAED,yDAAyD;AACzD,wBAAgB,SAAS,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,YAAY,GAAG,MAAM,CASvE;AAED,kEAAkE;AAClE,wBAAgB,YAAY,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,YAAY,GAAG,MAAM,CAS1E;AAED,2FAA2F;AAC3F,wBAAgB,YAAY,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,YAAY,GAAG,MAAM,CAS1E"}
|
package/dist/_helpers/string.js
CHANGED
|
@@ -1,29 +1,2 @@
|
|
|
1
|
-
import
|
|
2
|
-
//#region src/_helpers/string.ts
|
|
3
|
-
function t(t, n) {
|
|
4
|
-
return t.length === 0 ? void 0 : t[Math.floor(e(n) * t.length)];
|
|
5
|
-
}
|
|
6
|
-
function n(t, n) {
|
|
7
|
-
let r = "";
|
|
8
|
-
for (let i = 0; i < t; i++) r += Math.floor(e(n) * 10);
|
|
9
|
-
return r;
|
|
10
|
-
}
|
|
11
|
-
function r(t, n) {
|
|
12
|
-
let r = "";
|
|
13
|
-
for (let i = 0; i < t; i++) r += "0123456789abcdef"[Math.floor(e(n) * 16)];
|
|
14
|
-
return r;
|
|
15
|
-
}
|
|
16
|
-
function i(t, n) {
|
|
17
|
-
let r = "";
|
|
18
|
-
for (let i = 0; i < t; i++) r += "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"[Math.floor(e(n) * 62)];
|
|
19
|
-
return r;
|
|
20
|
-
}
|
|
21
|
-
function a(t, n) {
|
|
22
|
-
let r = "";
|
|
23
|
-
for (let i = 0; i < t; i++) r += "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"[Math.floor(e(n) * 58)];
|
|
24
|
-
return r;
|
|
25
|
-
}
|
|
26
|
-
//#endregion
|
|
27
|
-
export { i as alphanumeric, a as base58String, r as hexString, n as numericString, t as pick };
|
|
28
|
-
|
|
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};
|
|
29
2
|
//# sourceMappingURL=string.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"string.js","names":[],"sources":["../../src/_helpers/string.ts"],"sourcesContent":["import type { RandomSource } from '
|
|
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 +1 @@
|
|
|
1
|
-
var e=Object.defineProperty,
|
|
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};exports.__exportAll=__exportAll;
|
|
@@ -1,11 +1 @@
|
|
|
1
|
-
|
|
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 };
|
|
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,2 +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:()=>
|
|
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:()=>department,price:()=>price,productAdjective:()=>productAdjective,productDescription:()=>productDescription,productMaterial:()=>productMaterial,productName:()=>productName,productNoun:()=>productNoun}),s={EUR:a.EUR,GBP:a.GBP,USD:a.USD};function productAdjective(e){return r.pick(i.COMMERCE_DATA.productAdjectives,e.source)}function productMaterial(e){return r.pick(i.COMMERCE_DATA.productMaterials,e.source)}function productNoun(e){return r.pick(i.COMMERCE_DATA.productNouns,e.source)}function productName(e){return`${productAdjective(e)} ${productMaterial(e)} ${productNoun(e)}`}function department(e){return r.pick(i.COMMERCE_DATA.departments,e.source)}function price(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 productDescription(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=department,exports.price=price,exports.productAdjective=productAdjective,exports.productDescription=productDescription,exports.productMaterial=productMaterial,exports.productName=productName,exports.productNoun=productNoun;
|
|
2
2
|
//# sourceMappingURL=commerce.cjs.map
|
|
@@ -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":"
|
|
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,51 +1,2 @@
|
|
|
1
|
-
import
|
|
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
|
-
|
|
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};
|
|
51
2
|
//# 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":"
|
|
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"}
|
package/dist/commerce/data.js
CHANGED
|
@@ -1,83 +1,2 @@
|
|
|
1
|
-
|
|
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
|
-
|
|
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};
|
|
83
2
|
//# 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":"
|
|
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"}
|
package/dist/date/date.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
const e=require("../_virtual/_rolldown/runtime.cjs"),t=require("../_helpers/int.cjs");let n=require("@vielzeug/tempo");var r=e.__exportAll({between:()=>
|
|
1
|
+
const e=require("../_virtual/_rolldown/runtime.cjs"),t=require("../_helpers/int.cjs");let n=require("@vielzeug/tempo");var r=e.__exportAll({between:()=>between,birthday:()=>birthday,future:()=>future,month:()=>month,past:()=>past,recent:()=>recent,weekday:()=>weekday});function resolveRef(e){return e??n.Temporal.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.int(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.int(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.int(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.int(i,a,e.source),s=t.int(1,12,e.source),c=t.int(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.int(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.int(0,11,e.source)]}exports.between=between,exports.birthday=birthday,Object.defineProperty(exports,"date_exports",{enumerable:!0,get:function(){return r}}),exports.future=future,exports.month=month,exports.past=past,exports.recent=recent,exports.weekday=weekday;
|
|
2
2
|
//# sourceMappingURL=date.cjs.map
|