@vielzeug/illusionist 3.0.0 → 26.10.1
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 +1 -1
- package/dist/_helpers/boolean.cjs +1 -1
- package/dist/_helpers/boolean.cjs.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.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.js +1 -8
- package/dist/_helpers/int.js.map +1 -1
- package/dist/_helpers/next-float.js +1 -2
- 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 +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 +1 -1
- package/dist/factory.js +1 -35
- 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 -121
- 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 +3 -3
- package/dist/seed/create-seed.js +1 -21
- 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.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 +1 -1
- package/dist/system/system.js +1 -68
- package/dist/system/system.js.map +1 -1
- package/package.json +7 -79
- 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
|
@@ -38,4 +38,4 @@ illusion.system.semver(); // "7.4.0"
|
|
|
38
38
|
|
|
39
39
|
## License
|
|
40
40
|
|
|
41
|
-
MIT © [Helmuth Saatkamp](https://github.com/helmuthdu)
|
|
41
|
+
MIT © [Helmuth Saatkamp](https://github.com/helmuthdu): part of the [Vielzeug](https://github.com/helmuthdu/vielzeug) monorepo.
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
let e=require("@vielzeug/arsenal");function
|
|
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 '../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,
|
|
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"}
|
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 '../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":"
|
|
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
|
-
let e=require("@vielzeug/arsenal");function
|
|
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 '../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,
|
|
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.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 '../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":"
|
|
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");function
|
|
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 { 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,
|
|
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.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 { 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":"
|
|
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,2 +1 @@
|
|
|
1
|
-
import
|
|
2
|
-
export { e as nextFloat };
|
|
1
|
+
import{randomFloat as e}from"@vielzeug/arsenal";export{e as nextFloat};
|
package/dist/_helpers/string.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
let e=require("@vielzeug/arsenal");function
|
|
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 '../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)
|
|
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"}
|
|
@@ -7,6 +7,6 @@ export declare function numericString(length: number, source?: RandomSource): st
|
|
|
7
7
|
export declare function hexString(length: number, source?: RandomSource): string;
|
|
8
8
|
/** Generates a random alphanumeric string of the given length. */
|
|
9
9
|
export declare function alphanumeric(length: number, source?: RandomSource): string;
|
|
10
|
-
/** Generates a random Base58 string (no 0, O, I, l)
|
|
10
|
+
/** Generates a random Base58 string (no 0, O, I, l): used for Bitcoin-style addresses. */
|
|
11
11
|
export declare function base58String(length: number, source?: RandomSource): string;
|
|
12
12
|
//# sourceMappingURL=string.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
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,
|
|
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,0FAA0F;AAC1F,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 '../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)
|
|
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
|
package/dist/date/date.cjs.map
CHANGED
|
@@ -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
|
|
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"}
|
package/dist/date/date.d.ts
CHANGED
|
@@ -24,7 +24,7 @@ export declare function recent(ctx: IllusionistContext, options?: {
|
|
|
24
24
|
*/
|
|
25
25
|
export declare function between(ctx: IllusionistContext, from: Temporal.ZonedDateTime, to: Temporal.ZonedDateTime): Temporal.ZonedDateTime;
|
|
26
26
|
/**
|
|
27
|
-
* Generates a random birthday
|
|
27
|
+
* Generates a random birthday: a date with a random year (default 18-80 years ago) and random month/day.
|
|
28
28
|
*/
|
|
29
29
|
export declare function birthday(ctx: IllusionistContext, options?: {
|
|
30
30
|
minAge?: number;
|
package/dist/date/date.js
CHANGED
|
@@ -1,93 +1,2 @@
|
|
|
1
|
-
import
|
|
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: () => c,
|
|
7
|
-
birthday: () => l,
|
|
8
|
-
future: () => o,
|
|
9
|
-
month: () => d,
|
|
10
|
-
past: () => a,
|
|
11
|
-
recent: () => s,
|
|
12
|
-
weekday: () => u
|
|
13
|
-
});
|
|
14
|
-
function i(e) {
|
|
15
|
-
return e ?? n.Now.zonedDateTimeISO("UTC");
|
|
16
|
-
}
|
|
17
|
-
function a(e, n) {
|
|
18
|
-
let r = i(n?.ref), a = (n?.years ?? 1) * 365 * 24 * 60 * 60;
|
|
19
|
-
return r.add({ seconds: -t(1, a, e.source) });
|
|
20
|
-
}
|
|
21
|
-
function o(e, n) {
|
|
22
|
-
let r = i(n?.ref), a = (n?.years ?? 1) * 365 * 24 * 60 * 60;
|
|
23
|
-
return r.add({ seconds: t(1, a, e.source) });
|
|
24
|
-
}
|
|
25
|
-
function s(e, n) {
|
|
26
|
-
let r = i(n?.ref), a = (n?.days ?? 1) * 24 * 60 * 60;
|
|
27
|
-
return r.add({ seconds: -t(1, a, e.source) });
|
|
28
|
-
}
|
|
29
|
-
function c(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 l(e, n) {
|
|
36
|
-
let r = i(n?.ref), a = n?.minAge ?? 18, o = n?.maxAge ?? 80, s = t(a, o, e.source), c = t(1, 12, e.source), l = t(1, 28, e.source);
|
|
37
|
-
return r.toPlainDate().subtract({ years: s }).with({
|
|
38
|
-
day: l,
|
|
39
|
-
month: c
|
|
40
|
-
});
|
|
41
|
-
}
|
|
42
|
-
function u(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 d(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 { c as between, l as birthday, r as date_exports, o as future, d as month, a as past, s as recent, u as weekday };
|
|
92
|
-
|
|
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};
|
|
93
2
|
//# sourceMappingURL=date.js.map
|