@vielzeug/illusionist 2.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +89 -0
- package/dist/_dev.d.ts +2 -0
- package/dist/_dev.d.ts.map +1 -0
- package/dist/_helpers/boolean.cjs +2 -0
- package/dist/_helpers/boolean.cjs.map +1 -0
- package/dist/_helpers/boolean.d.ts +4 -0
- package/dist/_helpers/boolean.d.ts.map +1 -0
- package/dist/_helpers/boolean.js +8 -0
- package/dist/_helpers/boolean.js.map +1 -0
- package/dist/_helpers/float.cjs +2 -0
- package/dist/_helpers/float.cjs.map +1 -0
- package/dist/_helpers/float.d.ts +9 -0
- package/dist/_helpers/float.d.ts.map +1 -0
- package/dist/_helpers/float.js +14 -0
- package/dist/_helpers/float.js.map +1 -0
- package/dist/_helpers/int.cjs +2 -0
- package/dist/_helpers/int.cjs.map +1 -0
- package/dist/_helpers/int.d.ts +4 -0
- package/dist/_helpers/int.d.ts.map +1 -0
- package/dist/_helpers/int.js +9 -0
- package/dist/_helpers/int.js.map +1 -0
- package/dist/_helpers/string.cjs +2 -0
- package/dist/_helpers/string.cjs.map +1 -0
- package/dist/_helpers/string.d.ts +12 -0
- package/dist/_helpers/string.d.ts.map +1 -0
- package/dist/_helpers/string.js +38 -0
- package/dist/_helpers/string.js.map +1 -0
- package/dist/_virtual/_rolldown/runtime.cjs +1 -0
- package/dist/_virtual/_rolldown/runtime.js +11 -0
- package/dist/commerce/commerce.cjs +2 -0
- package/dist/commerce/commerce.cjs.map +1 -0
- package/dist/commerce/commerce.d.ts +15 -0
- package/dist/commerce/commerce.d.ts.map +1 -0
- package/dist/commerce/commerce.js +51 -0
- package/dist/commerce/commerce.js.map +1 -0
- package/dist/commerce/data.cjs +2 -0
- package/dist/commerce/data.cjs.map +1 -0
- package/dist/commerce/data.d.ts +7 -0
- package/dist/commerce/data.d.ts.map +1 -0
- package/dist/commerce/data.js +83 -0
- package/dist/commerce/data.js.map +1 -0
- package/dist/commerce/index.cjs +1 -0
- package/dist/commerce/index.d.ts +2 -0
- package/dist/commerce/index.d.ts.map +1 -0
- package/dist/commerce/index.js +2 -0
- package/dist/date/date.cjs +2 -0
- package/dist/date/date.cjs.map +1 -0
- package/dist/date/date.d.ts +43 -0
- package/dist/date/date.d.ts.map +1 -0
- package/dist/date/date.js +93 -0
- package/dist/date/date.js.map +1 -0
- package/dist/date/index.cjs +1 -0
- package/dist/date/index.d.ts +2 -0
- package/dist/date/index.d.ts.map +1 -0
- package/dist/date/index.js +2 -0
- package/dist/errors.cjs +2 -0
- package/dist/errors.cjs.map +1 -0
- package/dist/errors.d.ts +8 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +10 -0
- package/dist/errors.js.map +1 -0
- package/dist/factory.cjs +2 -0
- package/dist/factory.cjs.map +1 -0
- package/dist/factory.d.ts +46 -0
- package/dist/factory.d.ts.map +1 -0
- package/dist/factory.js +46 -0
- package/dist/factory.js.map +1 -0
- package/dist/finance/data.cjs +2 -0
- package/dist/finance/data.cjs.map +1 -0
- package/dist/finance/data.d.ts +32 -0
- package/dist/finance/data.d.ts.map +1 -0
- package/dist/finance/data.js +60 -0
- package/dist/finance/data.js.map +1 -0
- package/dist/finance/finance.cjs +2 -0
- package/dist/finance/finance.cjs.map +1 -0
- package/dist/finance/finance.d.ts +20 -0
- package/dist/finance/finance.d.ts.map +1 -0
- package/dist/finance/finance.js +90 -0
- package/dist/finance/finance.js.map +1 -0
- package/dist/finance/index.cjs +1 -0
- package/dist/finance/index.d.ts +2 -0
- package/dist/finance/index.d.ts.map +1 -0
- package/dist/finance/index.js +2 -0
- package/dist/iife-entry.d.ts +4 -0
- package/dist/iife-entry.d.ts.map +1 -0
- package/dist/illusionist.cjs +4 -0
- package/dist/illusionist.cjs.map +1 -0
- package/dist/illusionist.iife.js +4 -0
- package/dist/illusionist.iife.js.map +1 -0
- package/dist/illusionist.js +4 -0
- package/dist/illusionist.js.map +1 -0
- package/dist/index.cjs +1 -0
- package/dist/index.d.ts +13 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +12 -0
- package/dist/internet/data.cjs +2 -0
- package/dist/internet/data.cjs.map +1 -0
- package/dist/internet/data.d.ts +10 -0
- package/dist/internet/data.d.ts.map +1 -0
- package/dist/internet/data.js +84 -0
- package/dist/internet/data.js.map +1 -0
- package/dist/internet/index.cjs +1 -0
- package/dist/internet/index.d.ts +2 -0
- package/dist/internet/index.d.ts.map +1 -0
- package/dist/internet/index.js +2 -0
- package/dist/internet/internet.cjs +2 -0
- package/dist/internet/internet.cjs.map +1 -0
- package/dist/internet/internet.d.ts +31 -0
- package/dist/internet/internet.d.ts.map +1 -0
- package/dist/internet/internet.js +121 -0
- package/dist/internet/internet.js.map +1 -0
- package/dist/locales/de.cjs +2 -0
- package/dist/locales/de.cjs.map +1 -0
- package/dist/locales/de.d.ts +22 -0
- package/dist/locales/de.d.ts.map +1 -0
- package/dist/locales/de.js +12 -0
- package/dist/locales/de.js.map +1 -0
- package/dist/locales/en.cjs +2 -0
- package/dist/locales/en.cjs.map +1 -0
- package/dist/locales/en.d.ts +22 -0
- package/dist/locales/en.d.ts.map +1 -0
- package/dist/locales/en.js +12 -0
- package/dist/locales/en.js.map +1 -0
- package/dist/locales/index.cjs +1 -0
- package/dist/locales/index.d.ts +3 -0
- package/dist/locales/index.d.ts.map +1 -0
- package/dist/locales/index.js +3 -0
- package/dist/location/data/de.cjs +2 -0
- package/dist/location/data/de.cjs.map +1 -0
- package/dist/location/data/de.d.ts +9 -0
- package/dist/location/data/de.d.ts.map +1 -0
- package/dist/location/data/de.js +82 -0
- package/dist/location/data/de.js.map +1 -0
- package/dist/location/data/en.cjs +2 -0
- package/dist/location/data/en.cjs.map +1 -0
- package/dist/location/data/en.d.ts +9 -0
- package/dist/location/data/en.d.ts.map +1 -0
- package/dist/location/data/en.js +65 -0
- package/dist/location/data/en.js.map +1 -0
- package/dist/location/index.cjs +1 -0
- package/dist/location/index.d.ts +2 -0
- package/dist/location/index.d.ts.map +1 -0
- package/dist/location/index.js +2 -0
- package/dist/location/location.cjs +2 -0
- package/dist/location/location.cjs.map +1 -0
- package/dist/location/location.d.ts +28 -0
- package/dist/location/location.d.ts.map +1 -0
- package/dist/location/location.js +56 -0
- package/dist/location/location.js.map +1 -0
- package/dist/lorem/data.cjs +2 -0
- package/dist/lorem/data.cjs.map +1 -0
- package/dist/lorem/data.d.ts +5 -0
- package/dist/lorem/data.d.ts.map +1 -0
- package/dist/lorem/data.js +6 -0
- package/dist/lorem/data.js.map +1 -0
- package/dist/lorem/index.cjs +1 -0
- package/dist/lorem/index.d.ts +2 -0
- package/dist/lorem/index.d.ts.map +1 -0
- package/dist/lorem/index.js +2 -0
- package/dist/lorem/lorem.cjs +4 -0
- package/dist/lorem/lorem.cjs.map +1 -0
- package/dist/lorem/lorem.d.ts +18 -0
- package/dist/lorem/lorem.d.ts.map +1 -0
- package/dist/lorem/lorem.js +54 -0
- package/dist/lorem/lorem.js.map +1 -0
- package/dist/person/data/de.cjs +2 -0
- package/dist/person/data/de.cjs.map +1 -0
- package/dist/person/data/de.d.ts +12 -0
- package/dist/person/data/de.d.ts.map +1 -0
- package/dist/person/data/de.js +62 -0
- package/dist/person/data/de.js.map +1 -0
- package/dist/person/data/en.cjs +2 -0
- package/dist/person/data/en.cjs.map +1 -0
- package/dist/person/data/en.d.ts +12 -0
- package/dist/person/data/en.d.ts.map +1 -0
- package/dist/person/data/en.js +70 -0
- package/dist/person/data/en.js.map +1 -0
- package/dist/person/index.cjs +1 -0
- package/dist/person/index.d.ts +2 -0
- package/dist/person/index.d.ts.map +1 -0
- package/dist/person/index.js +2 -0
- package/dist/person/person.cjs +2 -0
- package/dist/person/person.cjs.map +1 -0
- package/dist/person/person.d.ts +9 -0
- package/dist/person/person.d.ts.map +1 -0
- package/dist/person/person.js +44 -0
- package/dist/person/person.js.map +1 -0
- package/dist/seed/create-seed.cjs +2 -0
- package/dist/seed/create-seed.cjs.map +1 -0
- package/dist/seed/create-seed.d.ts +17 -0
- package/dist/seed/create-seed.d.ts.map +1 -0
- package/dist/seed/create-seed.js +23 -0
- package/dist/seed/create-seed.js.map +1 -0
- package/dist/seed/index.cjs +1 -0
- package/dist/seed/index.d.ts +3 -0
- package/dist/seed/index.d.ts.map +1 -0
- package/dist/seed/index.js +3 -0
- package/dist/seed/mulberry32.cjs +2 -0
- package/dist/seed/mulberry32.cjs.map +1 -0
- package/dist/seed/mulberry32.d.ts +12 -0
- package/dist/seed/mulberry32.d.ts.map +1 -0
- package/dist/seed/mulberry32.js +13 -0
- package/dist/seed/mulberry32.js.map +1 -0
- package/dist/system/data.cjs +2 -0
- package/dist/system/data.cjs.map +1 -0
- package/dist/system/data.d.ts +29 -0
- package/dist/system/data.d.ts.map +1 -0
- package/dist/system/data.js +76 -0
- package/dist/system/data.js.map +1 -0
- package/dist/system/index.cjs +1 -0
- package/dist/system/index.d.ts +2 -0
- package/dist/system/index.d.ts.map +1 -0
- package/dist/system/index.js +2 -0
- package/dist/system/system.cjs +2 -0
- package/dist/system/system.cjs.map +1 -0
- package/dist/system/system.d.ts +32 -0
- package/dist/system/system.d.ts.map +1 -0
- package/dist/system/system.js +70 -0
- package/dist/system/system.js.map +1 -0
- package/dist/types.d.ts +41 -0
- package/dist/types.d.ts.map +1 -0
- package/package.json +155 -0
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import { __exportAll as e } from "../_virtual/_rolldown/runtime.js";
|
|
2
|
+
import { int as t } from "../_helpers/int.js";
|
|
3
|
+
import { Temporal as n, shift as r } from "@vielzeug/tempo";
|
|
4
|
+
//#region src/date/date.ts
|
|
5
|
+
var i = /* @__PURE__ */ e({
|
|
6
|
+
between: () => l,
|
|
7
|
+
birthday: () => u,
|
|
8
|
+
future: () => s,
|
|
9
|
+
month: () => f,
|
|
10
|
+
past: () => o,
|
|
11
|
+
recent: () => c,
|
|
12
|
+
weekday: () => d
|
|
13
|
+
});
|
|
14
|
+
function a(e) {
|
|
15
|
+
return e ?? n.Now.zonedDateTimeISO("UTC");
|
|
16
|
+
}
|
|
17
|
+
function o(e, n) {
|
|
18
|
+
let i = a(n?.ref), o = (n?.years ?? 1) * 365 * 24 * 60 * 60;
|
|
19
|
+
return r(i, { seconds: -t(1, o, e.source) });
|
|
20
|
+
}
|
|
21
|
+
function s(e, n) {
|
|
22
|
+
let i = a(n?.ref), o = (n?.years ?? 1) * 365 * 24 * 60 * 60;
|
|
23
|
+
return r(i, { seconds: t(1, o, e.source) });
|
|
24
|
+
}
|
|
25
|
+
function c(e, n) {
|
|
26
|
+
let i = a(n?.ref), o = (n?.days ?? 1) * 24 * 60 * 60;
|
|
27
|
+
return r(i, { seconds: -t(1, o, e.source) });
|
|
28
|
+
}
|
|
29
|
+
function l(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 u(e, n) {
|
|
36
|
+
let r = a(n?.ref), i = n?.minAge ?? 18, o = n?.maxAge ?? 80, s = t(i, o, e.source), c = t(1, 12, e.source), l = t(1, 28, e.source);
|
|
37
|
+
return r.toPlainDate().subtract({ years: s }).with({
|
|
38
|
+
day: l,
|
|
39
|
+
month: c
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
function d(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 f(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 { l as between, u as birthday, i as date_exports, s as future, f as month, o as past, c as recent, d as weekday };
|
|
92
|
+
|
|
93
|
+
//# sourceMappingURL=date.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"date.js","names":[],"sources":["../../src/date/date.ts"],"sourcesContent":["import { shift, Temporal } from '@vielzeug/tempo';\n\nimport { int } from '../_helpers/int';\nimport type { IllusionistContext } from '../types';\n\ntype DateOptions = {\n years?: number;\n ref?: Temporal.ZonedDateTime;\n};\n\nfunction resolveRef(ref?: Temporal.ZonedDateTime): Temporal.ZonedDateTime {\n return ref ?? Temporal.Now.zonedDateTimeISO('UTC');\n}\n\n/**\n * Generates a past date within the given number of years from `ref` (default: now).\n */\nexport function past(ctx: IllusionistContext, options?: DateOptions): Temporal.ZonedDateTime {\n const ref = resolveRef(options?.ref);\n const years = options?.years ?? 1;\n const maxSeconds = years * 365 * 24 * 60 * 60;\n const minSeconds = 1;\n\n return shift(ref, { seconds: -int(minSeconds, maxSeconds, ctx.source) });\n}\n\n/**\n * Generates a future date within the given number of years from `ref` (default: now).\n */\nexport function future(ctx: IllusionistContext, options?: DateOptions): Temporal.ZonedDateTime {\n const ref = resolveRef(options?.ref);\n const years = options?.years ?? 1;\n const maxSeconds = years * 365 * 24 * 60 * 60;\n\n return shift(ref, { seconds: int(1, maxSeconds, ctx.source) });\n}\n\n/**\n * Generates a recent date within the given number of days from `ref` (default: now).\n */\nexport function recent(\n ctx: IllusionistContext,\n options?: { days?: number; ref?: Temporal.ZonedDateTime },\n): Temporal.ZonedDateTime {\n const ref = resolveRef(options?.ref);\n const days = options?.days ?? 1;\n const maxSeconds = days * 24 * 60 * 60;\n\n return shift(ref, { seconds: -int(1, maxSeconds, ctx.source) });\n}\n\n/**\n * Generates a date between `from` and `to`.\n */\nexport function between(\n ctx: IllusionistContext,\n from: Temporal.ZonedDateTime,\n to: Temporal.ZonedDateTime,\n): Temporal.ZonedDateTime {\n const fromNs = from.toInstant().epochNanoseconds;\n const toNs = to.toInstant().epochNanoseconds;\n\n if (fromNs > toNs) {\n return from;\n }\n\n const spanNs = toNs - fromNs;\n const spanSeconds = Number(spanNs / 1_000_000_000n);\n const offsetSeconds = Math.floor(ctx.source.next() * spanSeconds);\n\n return from.add({ seconds: offsetSeconds });\n}\n\n/**\n * Generates a random birthday — a date with a random year (default 18-80 years ago) and random month/day.\n */\nexport function birthday(\n ctx: IllusionistContext,\n options?: { minAge?: number; maxAge?: number; ref?: Temporal.ZonedDateTime },\n): Temporal.PlainDate {\n const ref = resolveRef(options?.ref);\n const minAge = options?.minAge ?? 18;\n const maxAge = options?.maxAge ?? 80;\n const age = int(minAge, maxAge, ctx.source);\n const month = int(1, 12, ctx.source);\n const day = int(1, 28, ctx.source);\n\n return ref.toPlainDate().subtract({ years: age }).with({ day, month });\n}\n\n/**\n * Returns a random weekday name.\n */\nexport function weekday(ctx: IllusionistContext, locale?: string): string {\n const days = ['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday'];\n const loc = locale ?? ctx.locale.code;\n const localized =\n loc === 'de' ? ['Montag', 'Dienstag', 'Mittwoch', 'Donnerstag', 'Freitag', 'Samstag', 'Sonntag'] : days;\n\n return localized[int(0, 6, ctx.source)]!;\n}\n\n/**\n * Returns a random month name.\n */\nexport function month(ctx: IllusionistContext, locale?: string): string {\n const months = [\n 'January',\n 'February',\n 'March',\n 'April',\n 'May',\n 'June',\n 'July',\n 'August',\n 'September',\n 'October',\n 'November',\n 'December',\n ];\n const loc = locale ?? ctx.locale.code;\n const localized =\n loc === 'de'\n ? [\n 'Januar',\n 'Februar',\n 'März',\n 'April',\n 'Mai',\n 'Juni',\n 'Juli',\n 'August',\n 'September',\n 'Oktober',\n 'November',\n 'Dezember',\n ]\n : months;\n\n return localized[int(0, 11, ctx.source)]!;\n}\n"],"mappings":";;;;;;;;;;;;;AAUA,SAAS,EAAW,GAAsD;CACxE,OAAO,KAAO,EAAS,IAAI,iBAAiB,KAAK;AACnD;AAKA,SAAgB,EAAK,GAAyB,GAA+C;CAC3F,IAAM,IAAM,EAAW,GAAS,GAAG,GAE7B,KADQ,GAAS,SAAS,KACL,MAAM,KAAK,KAAK;CAG3C,OAAO,EAAM,GAAK,EAAE,SAAS,CAAC,EAAI,GAAY,GAAY,EAAI,MAAM,EAAE,CAAC;AACzE;AAKA,SAAgB,EAAO,GAAyB,GAA+C;CAC7F,IAAM,IAAM,EAAW,GAAS,GAAG,GAE7B,KADQ,GAAS,SAAS,KACL,MAAM,KAAK,KAAK;CAE3C,OAAO,EAAM,GAAK,EAAE,SAAS,EAAI,GAAG,GAAY,EAAI,MAAM,EAAE,CAAC;AAC/D;AAKA,SAAgB,EACd,GACA,GACwB;CACxB,IAAM,IAAM,EAAW,GAAS,GAAG,GAE7B,KADO,GAAS,QAAQ,KACJ,KAAK,KAAK;CAEpC,OAAO,EAAM,GAAK,EAAE,SAAS,CAAC,EAAI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 +1 @@
|
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./date.cjs");exports.between=e.between,exports.birthday=e.birthday,exports.future=e.future,exports.month=e.month,exports.past=e.past,exports.recent=e.recent,exports.weekday=e.weekday;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/date/index.ts"],"names":[],"mappings":"AAAA,cAAc,QAAQ,CAAC"}
|
package/dist/errors.cjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.cjs","names":[],"sources":["../src/errors.ts"],"sourcesContent":["/** Base class for all illusionist errors. Use `instanceof IllusionistError` to catch any illusionist-originated error. */\nexport class IllusionistError extends Error {\n constructor(message: string, opts?: ErrorOptions) {\n super(message, opts);\n this.name = new.target.name;\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\n\n/** Thrown when the seeded random source produces an invalid value. */\nexport class IllusionistSeedError extends IllusionistError {}\n"],"mappings":"AACA,IAAa,EAAb,cAAsC,KAAM,CAC1C,YAAY,EAAiB,EAAqB,CAChD,MAAM,EAAS,CAAI,EACnB,KAAK,KAAO,WAAW,KACvB,OAAO,eAAe,KAAM,WAAW,SAAS,CAClD,CACF,EAGa,EAAb,cAA0C,CAAiB,CAAC"}
|
package/dist/errors.d.ts
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/** Base class for all illusionist errors. Use `instanceof IllusionistError` to catch any illusionist-originated error. */
|
|
2
|
+
export declare class IllusionistError extends Error {
|
|
3
|
+
constructor(message: string, opts?: ErrorOptions);
|
|
4
|
+
}
|
|
5
|
+
/** Thrown when the seeded random source produces an invalid value. */
|
|
6
|
+
export declare class IllusionistSeedError extends IllusionistError {
|
|
7
|
+
}
|
|
8
|
+
//# sourceMappingURL=errors.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA,0HAA0H;AAC1H,qBAAa,gBAAiB,SAAQ,KAAK;gBAC7B,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,YAAY;CAKjD;AAED,sEAAsE;AACtE,qBAAa,oBAAqB,SAAQ,gBAAgB;CAAG"}
|
package/dist/errors.js
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
//#region src/errors.ts
|
|
2
|
+
var e = class extends Error {
|
|
3
|
+
constructor(e, t) {
|
|
4
|
+
super(e, t), this.name = new.target.name, Object.setPrototypeOf(this, new.target.prototype);
|
|
5
|
+
}
|
|
6
|
+
}, t = class extends e {};
|
|
7
|
+
//#endregion
|
|
8
|
+
export { e as IllusionistError, t as IllusionistSeedError };
|
|
9
|
+
|
|
10
|
+
//# sourceMappingURL=errors.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.js","names":[],"sources":["../src/errors.ts"],"sourcesContent":["/** Base class for all illusionist errors. Use `instanceof IllusionistError` to catch any illusionist-originated error. */\nexport class IllusionistError extends Error {\n constructor(message: string, opts?: ErrorOptions) {\n super(message, opts);\n this.name = new.target.name;\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\n\n/** Thrown when the seeded random source produces an invalid value. */\nexport class IllusionistSeedError extends IllusionistError {}\n"],"mappings":";AACA,IAAa,IAAb,cAAsC,MAAM;CAC1C,YAAY,GAAiB,GAAqB;EAGhD,AAFA,MAAM,GAAS,CAAI,GACnB,KAAK,OAAO,WAAW,MACvB,OAAO,eAAe,MAAM,WAAW,SAAS;CAClD;AACF,GAGa,IAAb,cAA0C,EAAiB,CAAC"}
|
package/dist/factory.cjs
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
const e=require("./commerce/commerce.cjs"),t=require("./date/date.cjs"),n=require("./finance/finance.cjs"),r=require("./internet/internet.cjs"),i=require("./location/location.cjs"),a=require("./lorem/lorem.cjs"),o=require("./person/person.cjs"),s=require("./seed/create-seed.cjs"),c=require("./system/system.cjs");function l(l){let{locale:u,seed:d}=l,f=s.createSeed(d),p=new AbortController,m=!1,h={locale:u,source:f},g=e=>{let t={};for(let[n,r]of Object.entries(e))typeof r==`function`&&(t[n]=(...e)=>r(h,...e));return t},_=()=>{m||(m=!0,p.abort())};return{commerce:g(e.commerce_exports),date:g(t.date_exports),get disposalSignal(){return p.signal},dispose:_,get disposed(){return m},finance:g(n.finance_exports),internet:g(r.internet_exports),locale:u,location:g(i.location_exports),lorem:g(a.lorem_exports),person:g(o.person_exports),seed:d,system:g(c.system_exports),[Symbol.dispose]:_}}exports.createIllusion=l;
|
|
2
|
+
//# sourceMappingURL=factory.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"factory.cjs","names":[],"sources":["../src/factory.ts"],"sourcesContent":["import type { RandomSource } from '@vielzeug/arsenal/random';\nimport * as commerceApi from './commerce/commerce';\nimport * as dateApi from './date/date';\nimport * as financeApi from './finance/finance';\nimport * as internetApi from './internet/internet';\nimport * as locationApi from './location/location';\nimport * as loremApi from './lorem/lorem';\nimport * as personApi from './person/person';\nimport { createSeed } from './seed/create-seed';\nimport * as systemApi from './system/system';\nimport type { IllusionistContext, IllusionistLocale, IllusionistOptions } from './types';\n\nexport type { IllusionistOptions } from './types';\n\nexport type Illusionist = {\n readonly person: typeof personApi;\n readonly internet: typeof internetApi;\n readonly commerce: typeof commerceApi;\n readonly date: typeof dateApi;\n readonly finance: typeof financeApi;\n readonly location: typeof locationApi;\n readonly lorem: typeof loremApi;\n readonly system: typeof systemApi;\n\n /** The seed used to initialize this instance, or `undefined` for cryptographic randomness. */\n readonly seed: number | string | undefined;\n /** The active locale data. */\n readonly locale: IllusionistLocale;\n\n dispose(): void;\n readonly disposed: boolean;\n readonly disposalSignal: AbortSignal;\n [Symbol.dispose](): void;\n};\n\n/**\n * Creates a bound illusionist instance with all categories sharing a single seeded\n * random source and locale.\n *\n * @example\n * ```ts\n * import { en } from '@vielzeug/illusionist/locales';\n *\n * const illusionist = createIllusion({ seed: 12345, locale: en });\n *\n * illusionist.person.fullName(); // deterministic — same seed → same result\n * illusionist.internet.email();\n * illusionist.commerce.price();\n * illusionist.dispose(); // [Symbol.dispose]() also works\n * ```\n */\nexport function createIllusion(options: IllusionistOptions): Illusionist {\n const { locale, seed } = options;\n const source: RandomSource = createSeed(seed);\n const controller = new AbortController();\n let disposed = false;\n\n const ctx: IllusionistContext = { locale, source };\n\n const bind = <T extends Record<string, (ctx: IllusionistContext, ...args: never[]) => unknown>>(api: T): T => {\n const bound = {} as Record<string, (...args: never[]) => unknown>;\n\n for (const [key, fn] of Object.entries(api)) {\n if (typeof fn === 'function') {\n bound[key] = (...args: never[]) => (fn as (ctx: IllusionistContext, ...args: never[]) => unknown)(ctx, ...args);\n }\n }\n\n return bound as T;\n };\n\n const dispose = (): void => {\n if (disposed) return;\n\n disposed = true;\n controller.abort();\n };\n\n return {\n commerce: bind(commerceApi),\n date: bind(dateApi),\n get disposalSignal(): AbortSignal {\n return controller.signal;\n },\n dispose,\n get disposed(): boolean {\n return disposed;\n },\n finance: bind(financeApi),\n internet: bind(internetApi),\n locale,\n location: bind(locationApi),\n lorem: bind(loremApi),\n person: bind(personApi),\n seed,\n system: bind(systemApi),\n [Symbol.dispose]: dispose,\n };\n}\n"],"mappings":"0TAmDA,SAAgB,EAAe,EAA0C,CACvE,GAAM,CAAE,SAAQ,QAAS,EACnB,EAAuB,EAAA,WAAW,CAAI,EACtC,EAAa,IAAI,gBACnB,EAAW,GAET,EAA0B,CAAE,SAAQ,QAAO,EAE3C,EAA0F,GAAc,CAC5G,IAAM,EAAQ,CAAC,EAEf,IAAK,GAAM,CAAC,EAAK,KAAO,OAAO,QAAQ,CAAG,EACpC,OAAO,GAAO,aAChB,EAAM,IAAQ,GAAG,IAAmB,EAA8D,EAAK,GAAG,CAAI,GAIlH,OAAO,CACT,EAEM,MAAsB,CACtB,IAEJ,EAAW,GACX,EAAW,MAAM,EACnB,EAEA,MAAO,CACL,SAAU,EAAK,EAAA,gBAAW,EAC1B,KAAM,EAAK,EAAA,YAAO,EAClB,IAAI,gBAA8B,CAChC,OAAO,EAAW,MACpB,EACA,UACA,IAAI,UAAoB,CACtB,OAAO,CACT,EACA,QAAS,EAAK,EAAA,eAAU,EACxB,SAAU,EAAK,EAAA,gBAAW,EAC1B,SACA,SAAU,EAAK,EAAA,gBAAW,EAC1B,MAAO,EAAK,EAAA,aAAQ,EACpB,OAAQ,EAAK,EAAA,cAAS,EACtB,OACA,OAAQ,EAAK,EAAA,cAAS,GACrB,OAAO,SAAU,CACpB,CACF"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import * as commerceApi from './commerce/commerce';
|
|
2
|
+
import * as dateApi from './date/date';
|
|
3
|
+
import * as financeApi from './finance/finance';
|
|
4
|
+
import * as internetApi from './internet/internet';
|
|
5
|
+
import * as locationApi from './location/location';
|
|
6
|
+
import * as loremApi from './lorem/lorem';
|
|
7
|
+
import * as personApi from './person/person';
|
|
8
|
+
import * as systemApi from './system/system';
|
|
9
|
+
import type { IllusionistLocale, IllusionistOptions } from './types';
|
|
10
|
+
export type { IllusionistOptions } from './types';
|
|
11
|
+
export type Illusionist = {
|
|
12
|
+
readonly person: typeof personApi;
|
|
13
|
+
readonly internet: typeof internetApi;
|
|
14
|
+
readonly commerce: typeof commerceApi;
|
|
15
|
+
readonly date: typeof dateApi;
|
|
16
|
+
readonly finance: typeof financeApi;
|
|
17
|
+
readonly location: typeof locationApi;
|
|
18
|
+
readonly lorem: typeof loremApi;
|
|
19
|
+
readonly system: typeof systemApi;
|
|
20
|
+
/** The seed used to initialize this instance, or `undefined` for cryptographic randomness. */
|
|
21
|
+
readonly seed: number | string | undefined;
|
|
22
|
+
/** The active locale data. */
|
|
23
|
+
readonly locale: IllusionistLocale;
|
|
24
|
+
dispose(): void;
|
|
25
|
+
readonly disposed: boolean;
|
|
26
|
+
readonly disposalSignal: AbortSignal;
|
|
27
|
+
[Symbol.dispose](): void;
|
|
28
|
+
};
|
|
29
|
+
/**
|
|
30
|
+
* Creates a bound illusionist instance with all categories sharing a single seeded
|
|
31
|
+
* random source and locale.
|
|
32
|
+
*
|
|
33
|
+
* @example
|
|
34
|
+
* ```ts
|
|
35
|
+
* import { en } from '@vielzeug/illusionist/locales';
|
|
36
|
+
*
|
|
37
|
+
* const illusionist = createIllusion({ seed: 12345, locale: en });
|
|
38
|
+
*
|
|
39
|
+
* illusionist.person.fullName(); // deterministic — same seed → same result
|
|
40
|
+
* illusionist.internet.email();
|
|
41
|
+
* illusionist.commerce.price();
|
|
42
|
+
* illusionist.dispose(); // [Symbol.dispose]() also works
|
|
43
|
+
* ```
|
|
44
|
+
*/
|
|
45
|
+
export declare function createIllusion(options: IllusionistOptions): Illusionist;
|
|
46
|
+
//# sourceMappingURL=factory.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"factory.d.ts","sourceRoot":"","sources":["../src/factory.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,WAAW,MAAM,qBAAqB,CAAC;AACnD,OAAO,KAAK,OAAO,MAAM,aAAa,CAAC;AACvC,OAAO,KAAK,UAAU,MAAM,mBAAmB,CAAC;AAChD,OAAO,KAAK,WAAW,MAAM,qBAAqB,CAAC;AACnD,OAAO,KAAK,WAAW,MAAM,qBAAqB,CAAC;AACnD,OAAO,KAAK,QAAQ,MAAM,eAAe,CAAC;AAC1C,OAAO,KAAK,SAAS,MAAM,iBAAiB,CAAC;AAE7C,OAAO,KAAK,SAAS,MAAM,iBAAiB,CAAC;AAC7C,OAAO,KAAK,EAAsB,iBAAiB,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAC;AAEzF,YAAY,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAC;AAElD,MAAM,MAAM,WAAW,GAAG;IACxB,QAAQ,CAAC,MAAM,EAAE,OAAO,SAAS,CAAC;IAClC,QAAQ,CAAC,QAAQ,EAAE,OAAO,WAAW,CAAC;IACtC,QAAQ,CAAC,QAAQ,EAAE,OAAO,WAAW,CAAC;IACtC,QAAQ,CAAC,IAAI,EAAE,OAAO,OAAO,CAAC;IAC9B,QAAQ,CAAC,OAAO,EAAE,OAAO,UAAU,CAAC;IACpC,QAAQ,CAAC,QAAQ,EAAE,OAAO,WAAW,CAAC;IACtC,QAAQ,CAAC,KAAK,EAAE,OAAO,QAAQ,CAAC;IAChC,QAAQ,CAAC,MAAM,EAAE,OAAO,SAAS,CAAC;IAElC,8FAA8F;IAC9F,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAAC;IAC3C,8BAA8B;IAC9B,QAAQ,CAAC,MAAM,EAAE,iBAAiB,CAAC;IAEnC,OAAO,IAAI,IAAI,CAAC;IAChB,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAC;IAC3B,QAAQ,CAAC,cAAc,EAAE,WAAW,CAAC;IACrC,CAAC,MAAM,CAAC,OAAO,CAAC,IAAI,IAAI,CAAC;CAC1B,CAAC;AAEF;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,cAAc,CAAC,OAAO,EAAE,kBAAkB,GAAG,WAAW,CA+CvE"}
|
package/dist/factory.js
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { commerce_exports as e } from "./commerce/commerce.js";
|
|
2
|
+
import { date_exports as t } from "./date/date.js";
|
|
3
|
+
import { finance_exports as n } from "./finance/finance.js";
|
|
4
|
+
import { internet_exports as r } from "./internet/internet.js";
|
|
5
|
+
import { location_exports as i } from "./location/location.js";
|
|
6
|
+
import { lorem_exports as a } from "./lorem/lorem.js";
|
|
7
|
+
import { person_exports as o } from "./person/person.js";
|
|
8
|
+
import { createSeed as s } from "./seed/create-seed.js";
|
|
9
|
+
import { system_exports as c } from "./system/system.js";
|
|
10
|
+
//#region src/factory.ts
|
|
11
|
+
function l(l) {
|
|
12
|
+
let { locale: u, seed: d } = l, f = s(d), p = new AbortController(), m = !1, h = {
|
|
13
|
+
locale: u,
|
|
14
|
+
source: f
|
|
15
|
+
}, g = (e) => {
|
|
16
|
+
let t = {};
|
|
17
|
+
for (let [n, r] of Object.entries(e)) typeof r == "function" && (t[n] = (...e) => r(h, ...e));
|
|
18
|
+
return t;
|
|
19
|
+
}, _ = () => {
|
|
20
|
+
m || (m = !0, p.abort());
|
|
21
|
+
};
|
|
22
|
+
return {
|
|
23
|
+
commerce: g(e),
|
|
24
|
+
date: g(t),
|
|
25
|
+
get disposalSignal() {
|
|
26
|
+
return p.signal;
|
|
27
|
+
},
|
|
28
|
+
dispose: _,
|
|
29
|
+
get disposed() {
|
|
30
|
+
return m;
|
|
31
|
+
},
|
|
32
|
+
finance: g(n),
|
|
33
|
+
internet: g(r),
|
|
34
|
+
locale: u,
|
|
35
|
+
location: g(i),
|
|
36
|
+
lorem: g(a),
|
|
37
|
+
person: g(o),
|
|
38
|
+
seed: d,
|
|
39
|
+
system: g(c),
|
|
40
|
+
[Symbol.dispose]: _
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
//#endregion
|
|
44
|
+
export { l as createIllusion };
|
|
45
|
+
|
|
46
|
+
//# sourceMappingURL=factory.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"factory.js","names":[],"sources":["../src/factory.ts"],"sourcesContent":["import type { RandomSource } from '@vielzeug/arsenal/random';\nimport * as commerceApi from './commerce/commerce';\nimport * as dateApi from './date/date';\nimport * as financeApi from './finance/finance';\nimport * as internetApi from './internet/internet';\nimport * as locationApi from './location/location';\nimport * as loremApi from './lorem/lorem';\nimport * as personApi from './person/person';\nimport { createSeed } from './seed/create-seed';\nimport * as systemApi from './system/system';\nimport type { IllusionistContext, IllusionistLocale, IllusionistOptions } from './types';\n\nexport type { IllusionistOptions } from './types';\n\nexport type Illusionist = {\n readonly person: typeof personApi;\n readonly internet: typeof internetApi;\n readonly commerce: typeof commerceApi;\n readonly date: typeof dateApi;\n readonly finance: typeof financeApi;\n readonly location: typeof locationApi;\n readonly lorem: typeof loremApi;\n readonly system: typeof systemApi;\n\n /** The seed used to initialize this instance, or `undefined` for cryptographic randomness. */\n readonly seed: number | string | undefined;\n /** The active locale data. */\n readonly locale: IllusionistLocale;\n\n dispose(): void;\n readonly disposed: boolean;\n readonly disposalSignal: AbortSignal;\n [Symbol.dispose](): void;\n};\n\n/**\n * Creates a bound illusionist instance with all categories sharing a single seeded\n * random source and locale.\n *\n * @example\n * ```ts\n * import { en } from '@vielzeug/illusionist/locales';\n *\n * const illusionist = createIllusion({ seed: 12345, locale: en });\n *\n * illusionist.person.fullName(); // deterministic — same seed → same result\n * illusionist.internet.email();\n * illusionist.commerce.price();\n * illusionist.dispose(); // [Symbol.dispose]() also works\n * ```\n */\nexport function createIllusion(options: IllusionistOptions): Illusionist {\n const { locale, seed } = options;\n const source: RandomSource = createSeed(seed);\n const controller = new AbortController();\n let disposed = false;\n\n const ctx: IllusionistContext = { locale, source };\n\n const bind = <T extends Record<string, (ctx: IllusionistContext, ...args: never[]) => unknown>>(api: T): T => {\n const bound = {} as Record<string, (...args: never[]) => unknown>;\n\n for (const [key, fn] of Object.entries(api)) {\n if (typeof fn === 'function') {\n bound[key] = (...args: never[]) => (fn as (ctx: IllusionistContext, ...args: never[]) => unknown)(ctx, ...args);\n }\n }\n\n return bound as T;\n };\n\n const dispose = (): void => {\n if (disposed) return;\n\n disposed = true;\n controller.abort();\n };\n\n return {\n commerce: bind(commerceApi),\n date: bind(dateApi),\n get disposalSignal(): AbortSignal {\n return controller.signal;\n },\n dispose,\n get disposed(): boolean {\n return disposed;\n },\n finance: bind(financeApi),\n internet: bind(internetApi),\n locale,\n location: bind(locationApi),\n lorem: bind(loremApi),\n person: bind(personApi),\n seed,\n system: bind(systemApi),\n [Symbol.dispose]: dispose,\n };\n}\n"],"mappings":";;;;;;;;;;AAmDA,SAAgB,EAAe,GAA0C;CACvE,IAAM,EAAE,WAAQ,YAAS,GACnB,IAAuB,EAAW,CAAI,GACtC,IAAa,IAAI,gBAAgB,GACnC,IAAW,IAET,IAA0B;EAAE;EAAQ;CAAO,GAE3C,KAA0F,MAAc;EAC5G,IAAM,IAAQ,CAAC;EAEf,KAAK,IAAM,CAAC,GAAK,MAAO,OAAO,QAAQ,CAAG,GACxC,AAAI,OAAO,KAAO,eAChB,EAAM,MAAQ,GAAG,MAAmB,EAA8D,GAAK,GAAG,CAAI;EAIlH,OAAO;CACT,GAEM,UAAsB;EACtB,MAEJ,IAAW,IACX,EAAW,MAAM;CACnB;CAEA,OAAO;EACL,UAAU,EAAK,CAAW;EAC1B,MAAM,EAAK,CAAO;EAClB,IAAI,iBAA8B;GAChC,OAAO,EAAW;EACpB;EACA;EACA,IAAI,WAAoB;GACtB,OAAO;EACT;EACA,SAAS,EAAK,CAAU;EACxB,UAAU,EAAK,CAAW;EAC1B;EACA,UAAU,EAAK,CAAW;EAC1B,OAAO,EAAK,CAAQ;EACpB,QAAQ,EAAK,CAAS;EACtB;EACA,QAAQ,EAAK,CAAS;GACrB,OAAO,UAAU;CACpB;AACF"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
var e={banks:[`Deutsche Bank`,`Commerzbank`,`Sparkasse`,`Barclays`,`HSBC`,`BNP Paribas`,`Santander`,`ING`,`UniCredit`,`UBS`],creditCardIins:{amex:[`34`,`37`],mastercard:[`51`,`52`,`53`,`54`,`55`],visa:[`4`]},ibanCountryCodes:{AT:`AT`,BE:`BE`,CH:`CH`,DE:`DE`,ES:`ES`,FR:`FR`,GB:`GB`,IT:`IT`,NL:`NL`},ibanLengths:{AT:20,BE:16,CH:21,DE:22,ES:24,FR:27,GB:22,IT:27,NL:18},transactionTypes:[`payment`,`transfer`,`deposit`,`withdrawal`,`refund`,`fee`]};exports.FINANCE_DATA=e;
|
|
2
|
+
//# sourceMappingURL=data.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"data.cjs","names":[],"sources":["../../src/finance/data.ts"],"sourcesContent":["export const FINANCE_DATA = {\n banks: [\n 'Deutsche Bank',\n 'Commerzbank',\n 'Sparkasse',\n 'Barclays',\n 'HSBC',\n 'BNP Paribas',\n 'Santander',\n 'ING',\n 'UniCredit',\n 'UBS',\n ],\n creditCardIins: { amex: ['34', '37'], mastercard: ['51', '52', '53', '54', '55'], visa: ['4'] },\n ibanCountryCodes: { AT: 'AT', BE: 'BE', CH: 'CH', DE: 'DE', ES: 'ES', FR: 'FR', GB: 'GB', IT: 'IT', NL: 'NL' },\n ibanLengths: { AT: 20, BE: 16, CH: 21, DE: 22, ES: 24, FR: 27, GB: 22, IT: 27, NL: 18 },\n transactionTypes: ['payment', 'transfer', 'deposit', 'withdrawal', 'refund', 'fee'],\n} as const;\n"],"mappings":"AAAA,IAAa,EAAe,CAC1B,MAAO,CACL,gBACA,cACA,YACA,WACA,OACA,cACA,YACA,MACA,YACA,KACF,EACA,eAAgB,CAAE,KAAM,CAAC,KAAM,IAAI,EAAG,WAAY,CAAC,KAAM,KAAM,KAAM,KAAM,IAAI,EAAG,KAAM,CAAC,GAAG,CAAE,EAC9F,iBAAkB,CAAE,GAAI,KAAM,GAAI,KAAM,GAAI,KAAM,GAAI,KAAM,GAAI,KAAM,GAAI,KAAM,GAAI,KAAM,GAAI,KAAM,GAAI,IAAK,EAC7G,YAAa,CAAE,GAAI,GAAI,GAAI,GAAI,GAAI,GAAI,GAAI,GAAI,GAAI,GAAI,GAAI,GAAI,GAAI,GAAI,GAAI,GAAI,GAAI,EAAG,EACtF,iBAAkB,CAAC,UAAW,WAAY,UAAW,aAAc,SAAU,KAAK,CACpF"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
export declare const FINANCE_DATA: {
|
|
2
|
+
readonly banks: readonly ["Deutsche Bank", "Commerzbank", "Sparkasse", "Barclays", "HSBC", "BNP Paribas", "Santander", "ING", "UniCredit", "UBS"];
|
|
3
|
+
readonly creditCardIins: {
|
|
4
|
+
readonly amex: readonly ["34", "37"];
|
|
5
|
+
readonly mastercard: readonly ["51", "52", "53", "54", "55"];
|
|
6
|
+
readonly visa: readonly ["4"];
|
|
7
|
+
};
|
|
8
|
+
readonly ibanCountryCodes: {
|
|
9
|
+
readonly AT: "AT";
|
|
10
|
+
readonly BE: "BE";
|
|
11
|
+
readonly CH: "CH";
|
|
12
|
+
readonly DE: "DE";
|
|
13
|
+
readonly ES: "ES";
|
|
14
|
+
readonly FR: "FR";
|
|
15
|
+
readonly GB: "GB";
|
|
16
|
+
readonly IT: "IT";
|
|
17
|
+
readonly NL: "NL";
|
|
18
|
+
};
|
|
19
|
+
readonly ibanLengths: {
|
|
20
|
+
readonly AT: 20;
|
|
21
|
+
readonly BE: 16;
|
|
22
|
+
readonly CH: 21;
|
|
23
|
+
readonly DE: 22;
|
|
24
|
+
readonly ES: 24;
|
|
25
|
+
readonly FR: 27;
|
|
26
|
+
readonly GB: 22;
|
|
27
|
+
readonly IT: 27;
|
|
28
|
+
readonly NL: 18;
|
|
29
|
+
};
|
|
30
|
+
readonly transactionTypes: readonly ["payment", "transfer", "deposit", "withdrawal", "refund", "fee"];
|
|
31
|
+
};
|
|
32
|
+
//# sourceMappingURL=data.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"data.d.ts","sourceRoot":"","sources":["../../src/finance/data.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,YAAY;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAiBf,CAAC"}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
//#region src/finance/data.ts
|
|
2
|
+
var e = {
|
|
3
|
+
banks: [
|
|
4
|
+
"Deutsche Bank",
|
|
5
|
+
"Commerzbank",
|
|
6
|
+
"Sparkasse",
|
|
7
|
+
"Barclays",
|
|
8
|
+
"HSBC",
|
|
9
|
+
"BNP Paribas",
|
|
10
|
+
"Santander",
|
|
11
|
+
"ING",
|
|
12
|
+
"UniCredit",
|
|
13
|
+
"UBS"
|
|
14
|
+
],
|
|
15
|
+
creditCardIins: {
|
|
16
|
+
amex: ["34", "37"],
|
|
17
|
+
mastercard: [
|
|
18
|
+
"51",
|
|
19
|
+
"52",
|
|
20
|
+
"53",
|
|
21
|
+
"54",
|
|
22
|
+
"55"
|
|
23
|
+
],
|
|
24
|
+
visa: ["4"]
|
|
25
|
+
},
|
|
26
|
+
ibanCountryCodes: {
|
|
27
|
+
AT: "AT",
|
|
28
|
+
BE: "BE",
|
|
29
|
+
CH: "CH",
|
|
30
|
+
DE: "DE",
|
|
31
|
+
ES: "ES",
|
|
32
|
+
FR: "FR",
|
|
33
|
+
GB: "GB",
|
|
34
|
+
IT: "IT",
|
|
35
|
+
NL: "NL"
|
|
36
|
+
},
|
|
37
|
+
ibanLengths: {
|
|
38
|
+
AT: 20,
|
|
39
|
+
BE: 16,
|
|
40
|
+
CH: 21,
|
|
41
|
+
DE: 22,
|
|
42
|
+
ES: 24,
|
|
43
|
+
FR: 27,
|
|
44
|
+
GB: 22,
|
|
45
|
+
IT: 27,
|
|
46
|
+
NL: 18
|
|
47
|
+
},
|
|
48
|
+
transactionTypes: [
|
|
49
|
+
"payment",
|
|
50
|
+
"transfer",
|
|
51
|
+
"deposit",
|
|
52
|
+
"withdrawal",
|
|
53
|
+
"refund",
|
|
54
|
+
"fee"
|
|
55
|
+
]
|
|
56
|
+
};
|
|
57
|
+
//#endregion
|
|
58
|
+
export { e as FINANCE_DATA };
|
|
59
|
+
|
|
60
|
+
//# sourceMappingURL=data.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"data.js","names":[],"sources":["../../src/finance/data.ts"],"sourcesContent":["export const FINANCE_DATA = {\n banks: [\n 'Deutsche Bank',\n 'Commerzbank',\n 'Sparkasse',\n 'Barclays',\n 'HSBC',\n 'BNP Paribas',\n 'Santander',\n 'ING',\n 'UniCredit',\n 'UBS',\n ],\n creditCardIins: { amex: ['34', '37'], mastercard: ['51', '52', '53', '54', '55'], visa: ['4'] },\n ibanCountryCodes: { AT: 'AT', BE: 'BE', CH: 'CH', DE: 'DE', ES: 'ES', FR: 'FR', GB: 'GB', IT: 'IT', NL: 'NL' },\n ibanLengths: { AT: 20, BE: 16, CH: 21, DE: 22, ES: 24, FR: 27, GB: 22, IT: 27, NL: 18 },\n transactionTypes: ['payment', 'transfer', 'deposit', 'withdrawal', 'refund', 'fee'],\n} as const;\n"],"mappings":";AAAA,IAAa,IAAe;CAC1B,OAAO;EACL;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;CACF;CACA,gBAAgB;EAAE,MAAM,CAAC,MAAM,IAAI;EAAG,YAAY;GAAC;GAAM;GAAM;GAAM;GAAM;EAAI;EAAG,MAAM,CAAC,GAAG;CAAE;CAC9F,kBAAkB;EAAE,IAAI;EAAM,IAAI;EAAM,IAAI;EAAM,IAAI;EAAM,IAAI;EAAM,IAAI;EAAM,IAAI;EAAM,IAAI;EAAM,IAAI;CAAK;CAC7G,aAAa;EAAE,IAAI;EAAI,IAAI;EAAI,IAAI;EAAI,IAAI;EAAI,IAAI;EAAI,IAAI;EAAI,IAAI;EAAI,IAAI;EAAI,IAAI;CAAG;CACtF,kBAAkB;EAAC;EAAW;EAAY;EAAW;EAAc;EAAU;CAAK;AACpF"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
const e=require("../_virtual/_rolldown/runtime.cjs"),t=require("../_helpers/float.cjs"),n=require("../_helpers/int.cjs"),r=require("../_helpers/string.cjs"),i=require("./data.cjs");let a=require("@vielzeug/coins");var o=e.__exportAll({amount:()=>h,bank:()=>C,bic:()=>_,bitcoinAddress:()=>b,creditCardCVV:()=>y,creditCardNumber:()=>v,ethereumAddress:()=>x,iban:()=>g,transactionType:()=>S}),s={EUR:a.EUR,GBP:a.GBP,USD:a.USD},c=[`visa`,`mastercard`,`amex`],l=Object.keys(i.FINANCE_DATA.ibanCountryCodes),u=`ABCDEFGHIJKLMNOPQRSTUVWXYZ`;function d(e,t){let n=``;for(let r=0;r<e;r++)n+=u[Math.floor(t.source.next()*26)];return n}function f(e){let t=0;for(let n of e)t=(t*10+Number(n))%97;return t}function p(e,t){return(98-f(`${t}${e}00`.replace(/[A-Z]/g,e=>String(e.charCodeAt(0)-55)))).toString().padStart(2,`0`)}function m(e){let t=e.split(``).map(Number),n=0,r=!0;for(let e=t.length-1;e>=0;e--){let i=t[e];r&&(i*=2,i>9&&(i-=9)),n+=i,r=!r}let i=(10-n%10)%10;return String(i)}function h(e,n={}){let r=n.min??100,i=n.max??1e4,o=n.currency??`USD`,c=t.floatFixed(r,i,2,e.source);return(0,a.money)(c.toFixed(2),s[o])}function g(e,t){let n=t??r.pick(l,e.source);if(!(n in i.FINANCE_DATA.ibanLengths))throw RangeError(`iban: unsupported country code "${t}". Supported: ${l.join(`, `)}`);let a=i.FINANCE_DATA.ibanLengths[n]-4,o=r.numericString(a,e.source);return`${n}${p(n,o)}${o}`}function _(e){return`${d(4,e)}${d(2,e)}${r.alphanumeric(2,e.source).toUpperCase()}${n.int(0,1,e.source)===1?r.alphanumeric(3,e.source).toUpperCase():``}`}function v(e,t){let n=t??r.pick(c,e.source),a=r.pick(i.FINANCE_DATA.creditCardIins[n],e.source),o=a+r.numericString((n===`amex`?15:16)-a.length-1,e.source);return`${o}${m(o)}`}function y(e,t){let n=(t??r.pick(c,e.source))===`amex`?4:3;return r.numericString(n,e.source)}function b(e){let t=r.pick([`1`,`3`,`bc1`],e.source),i=n.int(25,34,e.source);return`${t}${r.base58String(i,e.source)}`}function x(e){return`0x${r.hexString(40,e.source)}`}function S(e){return r.pick(i.FINANCE_DATA.transactionTypes,e.source)}function C(e){return r.pick(i.FINANCE_DATA.banks,e.source)}exports.amount=h,exports.bank=C,exports.bic=_,exports.bitcoinAddress=b,exports.creditCardCVV=y,exports.creditCardNumber=v,exports.ethereumAddress=x,Object.defineProperty(exports,"finance_exports",{enumerable:!0,get:function(){return o}}),exports.iban=g,exports.transactionType=S;
|
|
2
|
+
//# sourceMappingURL=finance.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"finance.cjs","names":[],"sources":["../../src/finance/finance.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 { alphanumeric, base58String, hexString, numericString, pick } from '../_helpers/string';\nimport type { IllusionistContext } from '../types';\nimport { FINANCE_DATA } from './data';\n\nconst CURRENCIES: Record<'USD' | 'EUR' | 'GBP', Currency> = { EUR, GBP, USD };\n\nconst CREDIT_CARD_TYPES = ['visa', 'mastercard', 'amex'] as const;\ntype CreditCardType = (typeof CREDIT_CARD_TYPES)[number];\n\nconst IBAN_COUNTRIES = Object.keys(FINANCE_DATA.ibanCountryCodes) as (keyof typeof FINANCE_DATA.ibanCountryCodes)[];\n\nconst LETTERS = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';\n\nfunction letters(count: number, ctx: IllusionistContext): string {\n let result = '';\n\n for (let i = 0; i < count; i++) {\n result += LETTERS[Math.floor(ctx.source.next() * LETTERS.length)];\n }\n\n return result;\n}\n\n/** Computes `n mod 97` for an arbitrarily long numeric string. */\nfunction mod97(numeric: string): number {\n let remainder = 0;\n\n for (const ch of numeric) {\n remainder = (remainder * 10 + Number(ch)) % 97;\n }\n\n return remainder;\n}\n\n/** Computes the two IBAN check digits so the resulting IBAN passes the mod-97 validation. */\nfunction ibanCheckDigits(country: string, bban: string): string {\n const rearranged = `${bban}${country}00`;\n const numeric = rearranged.replace(/[A-Z]/g, (c) => String(c.charCodeAt(0) - 55));\n const check = 98 - mod97(numeric);\n\n return check.toString().padStart(2, '0');\n}\n\n/** Computes the Luhn check digit for a partial card number (the final digit is appended). */\nfunction luhnCheckDigit(partial: string): string {\n const digits = partial.split('').map(Number);\n let sum = 0;\n let double = true;\n\n for (let i = digits.length - 1; i >= 0; i--) {\n let d = digits[i]!;\n\n if (double) {\n d *= 2;\n if (d > 9) d -= 9;\n }\n\n sum += d;\n double = !double;\n }\n\n const check = (10 - (sum % 10)) % 10;\n\n return String(check);\n}\n\nexport type AmountOptions = {\n readonly min?: number;\n readonly max?: number;\n readonly currency?: 'USD' | 'EUR' | 'GBP';\n};\n\nexport function amount(ctx: IllusionistContext, opts: AmountOptions = {}): Money {\n const min = opts.min ?? 100;\n const max = opts.max ?? 10000;\n const code = opts.currency ?? 'USD';\n const value = floatFixed(min, max, 2, ctx.source);\n\n return money(value.toFixed(2), CURRENCIES[code]);\n}\n\nexport function iban(ctx: IllusionistContext, countryCode?: string): string {\n const country = (countryCode ?? pick(IBAN_COUNTRIES, ctx.source)!) as keyof typeof FINANCE_DATA.ibanLengths;\n\n if (!(country in FINANCE_DATA.ibanLengths)) {\n throw new RangeError(`iban: unsupported country code \"${countryCode}\". Supported: ${IBAN_COUNTRIES.join(', ')}`);\n }\n\n const totalLength = FINANCE_DATA.ibanLengths[country];\n const bbanLength = totalLength - 4;\n const bban = numericString(bbanLength, ctx.source);\n const checkDigits = ibanCheckDigits(country, bban);\n\n return `${country}${checkDigits}${bban}`;\n}\n\nexport function bic(ctx: IllusionistContext): string {\n const bankCode = letters(4, ctx);\n const country = letters(2, ctx);\n const location = alphanumeric(2, ctx.source).toUpperCase();\n const useBranch = int(0, 1, ctx.source) === 1;\n const branch = useBranch ? alphanumeric(3, ctx.source).toUpperCase() : '';\n\n return `${bankCode}${country}${location}${branch}`;\n}\n\nexport function creditCardNumber(ctx: IllusionistContext, type?: CreditCardType): string {\n const cardType = type ?? pick(CREDIT_CARD_TYPES, ctx.source)!;\n const iin = pick(FINANCE_DATA.creditCardIins[cardType], ctx.source)!;\n const totalLength = cardType === 'amex' ? 15 : 16;\n const partial = iin + numericString(totalLength - iin.length - 1, ctx.source);\n const checkDigit = luhnCheckDigit(partial);\n\n return `${partial}${checkDigit}`;\n}\n\nexport function creditCardCVV(ctx: IllusionistContext, type?: CreditCardType): string {\n const cardType = type ?? pick(CREDIT_CARD_TYPES, ctx.source)!;\n const length = cardType === 'amex' ? 4 : 3;\n\n return numericString(length, ctx.source);\n}\n\nexport function bitcoinAddress(ctx: IllusionistContext): string {\n const prefix = pick(['1', '3', 'bc1'], ctx.source)!;\n const suffixLength = int(25, 34, ctx.source);\n\n return `${prefix}${base58String(suffixLength, ctx.source)}`;\n}\n\nexport function ethereumAddress(ctx: IllusionistContext): string {\n return `0x${hexString(40, ctx.source)}`;\n}\n\nexport function transactionType(ctx: IllusionistContext): string {\n return pick(FINANCE_DATA.transactionTypes, ctx.source)!;\n}\n\nexport function bank(ctx: IllusionistContext): string {\n return pick(FINANCE_DATA.banks, ctx.source)!;\n}\n"],"mappings":"sYAQM,EAAsD,CAAE,IAAA,EAAA,IAAK,IAAA,EAAA,IAAK,IAAA,EAAA,GAAI,EAEtE,EAAoB,CAAC,OAAQ,aAAc,MAAM,EAGjD,EAAiB,OAAO,KAAK,EAAA,aAAa,gBAAgB,EAE1D,EAAU,6BAEhB,SAAS,EAAQ,EAAe,EAAiC,CAC/D,IAAI,EAAS,GAEb,IAAK,IAAI,EAAI,EAAG,EAAI,EAAO,IACzB,GAAU,EAAQ,KAAK,MAAM,EAAI,OAAO,KAAK,EAAI,EAAc,GAGjE,OAAO,CACT,CAGA,SAAS,EAAM,EAAyB,CACtC,IAAI,EAAY,EAEhB,IAAK,IAAM,KAAM,EACf,GAAa,EAAY,GAAK,OAAO,CAAE,GAAK,GAG9C,OAAO,CACT,CAGA,SAAS,EAAgB,EAAiB,EAAsB,CAK9D,OAFc,GAAK,EADH,GADM,IAAO,EAAQ,IACV,QAAQ,SAAW,GAAM,OAAO,EAAE,WAAW,CAAC,EAAI,EAAE,CACtD,CAAO,EAAA,CAEnB,SAAS,CAAC,CAAC,SAAS,EAAG,GAAG,CACzC,CAGA,SAAS,EAAe,EAAyB,CAC/C,IAAM,EAAS,EAAQ,MAAM,EAAE,CAAC,CAAC,IAAI,MAAM,EACvC,EAAM,EACN,EAAS,GAEb,IAAK,IAAI,EAAI,EAAO,OAAS,EAAG,GAAK,EAAG,IAAK,CAC3C,IAAI,EAAI,EAAO,GAEX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5E,MAAO,GAAG,IAFS,EAAe,CAEd,GACtB,CAEA,SAAgB,EAAc,EAAyB,EAA+B,CAEpF,IAAM,GADW,GAAQ,EAAA,KAAK,EAAmB,EAAI,MAAM,KAC/B,OAAS,EAAI,EAEzC,OAAO,EAAA,cAAc,EAAQ,EAAI,MAAM,CACzC,CAEA,SAAgB,EAAe,EAAiC,CAC9D,IAAM,EAAS,EAAA,KAAK,CAAC,IAAK,IAAK,KAAK,EAAG,EAAI,MAAM,EAC3C,EAAe,EAAA,IAAI,GAAI,GAAI,EAAI,MAAM,EAE3C,MAAO,GAAG,IAAS,EAAA,aAAa,EAAc,EAAI,MAAM,GAC1D,CAEA,SAAgB,EAAgB,EAAiC,CAC/D,MAAO,KAAK,EAAA,UAAU,GAAI,EAAI,MAAM,GACtC,CAEA,SAAgB,EAAgB,EAAiC,CAC/D,OAAO,EAAA,KAAK,EAAA,aAAa,iBAAkB,EAAI,MAAM,CACvD,CAEA,SAAgB,EAAK,EAAiC,CACpD,OAAO,EAAA,KAAK,EAAA,aAAa,MAAO,EAAI,MAAM,CAC5C"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { type Money } from '@vielzeug/coins';
|
|
2
|
+
import type { IllusionistContext } from '../types';
|
|
3
|
+
declare const CREDIT_CARD_TYPES: readonly ["visa", "mastercard", "amex"];
|
|
4
|
+
type CreditCardType = (typeof CREDIT_CARD_TYPES)[number];
|
|
5
|
+
export type AmountOptions = {
|
|
6
|
+
readonly min?: number;
|
|
7
|
+
readonly max?: number;
|
|
8
|
+
readonly currency?: 'USD' | 'EUR' | 'GBP';
|
|
9
|
+
};
|
|
10
|
+
export declare function amount(ctx: IllusionistContext, opts?: AmountOptions): Money;
|
|
11
|
+
export declare function iban(ctx: IllusionistContext, countryCode?: string): string;
|
|
12
|
+
export declare function bic(ctx: IllusionistContext): string;
|
|
13
|
+
export declare function creditCardNumber(ctx: IllusionistContext, type?: CreditCardType): string;
|
|
14
|
+
export declare function creditCardCVV(ctx: IllusionistContext, type?: CreditCardType): string;
|
|
15
|
+
export declare function bitcoinAddress(ctx: IllusionistContext): string;
|
|
16
|
+
export declare function ethereumAddress(ctx: IllusionistContext): string;
|
|
17
|
+
export declare function transactionType(ctx: IllusionistContext): string;
|
|
18
|
+
export declare function bank(ctx: IllusionistContext): string;
|
|
19
|
+
export {};
|
|
20
|
+
//# sourceMappingURL=finance.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"finance.d.ts","sourceRoot":"","sources":["../../src/finance/finance.ts"],"names":[],"mappings":"AAAA,OAAO,EAA2B,KAAK,KAAK,EAAc,MAAM,iBAAiB,CAAC;AAKlF,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAC;AAKnD,QAAA,MAAM,iBAAiB,yCAA0C,CAAC;AAClE,KAAK,cAAc,GAAG,CAAC,OAAO,iBAAiB,CAAC,CAAC,MAAM,CAAC,CAAC;AA2DzD,MAAM,MAAM,aAAa,GAAG;IAC1B,QAAQ,CAAC,GAAG,CAAC,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,GAAG,CAAC,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,QAAQ,CAAC,EAAE,KAAK,GAAG,KAAK,GAAG,KAAK,CAAC;CAC3C,CAAC;AAEF,wBAAgB,MAAM,CAAC,GAAG,EAAE,kBAAkB,EAAE,IAAI,GAAE,aAAkB,GAAG,KAAK,CAO/E;AAED,wBAAgB,IAAI,CAAC,GAAG,EAAE,kBAAkB,EAAE,WAAW,CAAC,EAAE,MAAM,GAAG,MAAM,CAa1E;AAED,wBAAgB,GAAG,CAAC,GAAG,EAAE,kBAAkB,GAAG,MAAM,CAQnD;AAED,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,kBAAkB,EAAE,IAAI,CAAC,EAAE,cAAc,GAAG,MAAM,CAQvF;AAED,wBAAgB,aAAa,CAAC,GAAG,EAAE,kBAAkB,EAAE,IAAI,CAAC,EAAE,cAAc,GAAG,MAAM,CAKpF;AAED,wBAAgB,cAAc,CAAC,GAAG,EAAE,kBAAkB,GAAG,MAAM,CAK9D;AAED,wBAAgB,eAAe,CAAC,GAAG,EAAE,kBAAkB,GAAG,MAAM,CAE/D;AAED,wBAAgB,eAAe,CAAC,GAAG,EAAE,kBAAkB,GAAG,MAAM,CAE/D;AAED,wBAAgB,IAAI,CAAC,GAAG,EAAE,kBAAkB,GAAG,MAAM,CAEpD"}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import { __exportAll as e } from "../_virtual/_rolldown/runtime.js";
|
|
2
|
+
import { floatFixed as t } from "../_helpers/float.js";
|
|
3
|
+
import { int as n } from "../_helpers/int.js";
|
|
4
|
+
import { alphanumeric as r, base58String as i, hexString as a, numericString as o, pick as s } from "../_helpers/string.js";
|
|
5
|
+
import { FINANCE_DATA as c } from "./data.js";
|
|
6
|
+
import { EUR as l, GBP as u, USD as d, money as f } from "@vielzeug/coins";
|
|
7
|
+
//#region src/finance/finance.ts
|
|
8
|
+
var p = /* @__PURE__ */ e({
|
|
9
|
+
amount: () => S,
|
|
10
|
+
bank: () => A,
|
|
11
|
+
bic: () => w,
|
|
12
|
+
bitcoinAddress: () => D,
|
|
13
|
+
creditCardCVV: () => E,
|
|
14
|
+
creditCardNumber: () => T,
|
|
15
|
+
ethereumAddress: () => O,
|
|
16
|
+
iban: () => C,
|
|
17
|
+
transactionType: () => k
|
|
18
|
+
}), m = {
|
|
19
|
+
EUR: l,
|
|
20
|
+
GBP: u,
|
|
21
|
+
USD: d
|
|
22
|
+
}, h = [
|
|
23
|
+
"visa",
|
|
24
|
+
"mastercard",
|
|
25
|
+
"amex"
|
|
26
|
+
], g = Object.keys(c.ibanCountryCodes), _ = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
|
|
27
|
+
function v(e, t) {
|
|
28
|
+
let n = "";
|
|
29
|
+
for (let r = 0; r < e; r++) n += _[Math.floor(t.source.next() * 26)];
|
|
30
|
+
return n;
|
|
31
|
+
}
|
|
32
|
+
function y(e) {
|
|
33
|
+
let t = 0;
|
|
34
|
+
for (let n of e) t = (t * 10 + Number(n)) % 97;
|
|
35
|
+
return t;
|
|
36
|
+
}
|
|
37
|
+
function b(e, t) {
|
|
38
|
+
return (98 - y(`${t}${e}00`.replace(/[A-Z]/g, (e) => String(e.charCodeAt(0) - 55)))).toString().padStart(2, "0");
|
|
39
|
+
}
|
|
40
|
+
function x(e) {
|
|
41
|
+
let t = e.split("").map(Number), n = 0, r = !0;
|
|
42
|
+
for (let e = t.length - 1; e >= 0; e--) {
|
|
43
|
+
let i = t[e];
|
|
44
|
+
r && (i *= 2, i > 9 && (i -= 9)), n += i, r = !r;
|
|
45
|
+
}
|
|
46
|
+
let i = (10 - n % 10) % 10;
|
|
47
|
+
return String(i);
|
|
48
|
+
}
|
|
49
|
+
function S(e, n = {}) {
|
|
50
|
+
let r = n.min ?? 100, i = n.max ?? 1e4, a = n.currency ?? "USD", o = t(r, i, 2, e.source);
|
|
51
|
+
return f(o.toFixed(2), m[a]);
|
|
52
|
+
}
|
|
53
|
+
function C(e, t) {
|
|
54
|
+
let n = t ?? s(g, e.source);
|
|
55
|
+
if (!(n in c.ibanLengths)) throw RangeError(`iban: unsupported country code "${t}". Supported: ${g.join(", ")}`);
|
|
56
|
+
let r = c.ibanLengths[n] - 4, i = o(r, e.source);
|
|
57
|
+
return `${n}${b(n, i)}${i}`;
|
|
58
|
+
}
|
|
59
|
+
function w(e) {
|
|
60
|
+
return `${v(4, e)}${v(2, e)}${r(2, e.source).toUpperCase()}${n(0, 1, e.source) === 1 ? r(3, e.source).toUpperCase() : ""}`;
|
|
61
|
+
}
|
|
62
|
+
function T(e, t) {
|
|
63
|
+
let n = t ?? s(h, e.source), r = s(c.creditCardIins[n], e.source), i = r + o((n === "amex" ? 15 : 16) - r.length - 1, e.source);
|
|
64
|
+
return `${i}${x(i)}`;
|
|
65
|
+
}
|
|
66
|
+
function E(e, t) {
|
|
67
|
+
let n = (t ?? s(h, e.source)) === "amex" ? 4 : 3;
|
|
68
|
+
return o(n, e.source);
|
|
69
|
+
}
|
|
70
|
+
function D(e) {
|
|
71
|
+
let t = s([
|
|
72
|
+
"1",
|
|
73
|
+
"3",
|
|
74
|
+
"bc1"
|
|
75
|
+
], e.source), r = n(25, 34, e.source);
|
|
76
|
+
return `${t}${i(r, e.source)}`;
|
|
77
|
+
}
|
|
78
|
+
function O(e) {
|
|
79
|
+
return `0x${a(40, e.source)}`;
|
|
80
|
+
}
|
|
81
|
+
function k(e) {
|
|
82
|
+
return s(c.transactionTypes, e.source);
|
|
83
|
+
}
|
|
84
|
+
function A(e) {
|
|
85
|
+
return s(c.banks, e.source);
|
|
86
|
+
}
|
|
87
|
+
//#endregion
|
|
88
|
+
export { S as amount, A as bank, w as bic, D as bitcoinAddress, E as creditCardCVV, T as creditCardNumber, O as ethereumAddress, p as finance_exports, C as iban, k as transactionType };
|
|
89
|
+
|
|
90
|
+
//# sourceMappingURL=finance.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"finance.js","names":[],"sources":["../../src/finance/finance.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 { alphanumeric, base58String, hexString, numericString, pick } from '../_helpers/string';\nimport type { IllusionistContext } from '../types';\nimport { FINANCE_DATA } from './data';\n\nconst CURRENCIES: Record<'USD' | 'EUR' | 'GBP', Currency> = { EUR, GBP, USD };\n\nconst CREDIT_CARD_TYPES = ['visa', 'mastercard', 'amex'] as const;\ntype CreditCardType = (typeof CREDIT_CARD_TYPES)[number];\n\nconst IBAN_COUNTRIES = Object.keys(FINANCE_DATA.ibanCountryCodes) as (keyof typeof FINANCE_DATA.ibanCountryCodes)[];\n\nconst LETTERS = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';\n\nfunction letters(count: number, ctx: IllusionistContext): string {\n let result = '';\n\n for (let i = 0; i < count; i++) {\n result += LETTERS[Math.floor(ctx.source.next() * LETTERS.length)];\n }\n\n return result;\n}\n\n/** Computes `n mod 97` for an arbitrarily long numeric string. */\nfunction mod97(numeric: string): number {\n let remainder = 0;\n\n for (const ch of numeric) {\n remainder = (remainder * 10 + Number(ch)) % 97;\n }\n\n return remainder;\n}\n\n/** Computes the two IBAN check digits so the resulting IBAN passes the mod-97 validation. */\nfunction ibanCheckDigits(country: string, bban: string): string {\n const rearranged = `${bban}${country}00`;\n const numeric = rearranged.replace(/[A-Z]/g, (c) => String(c.charCodeAt(0) - 55));\n const check = 98 - mod97(numeric);\n\n return check.toString().padStart(2, '0');\n}\n\n/** Computes the Luhn check digit for a partial card number (the final digit is appended). */\nfunction luhnCheckDigit(partial: string): string {\n const digits = partial.split('').map(Number);\n let sum = 0;\n let double = true;\n\n for (let i = digits.length - 1; i >= 0; i--) {\n let d = digits[i]!;\n\n if (double) {\n d *= 2;\n if (d > 9) d -= 9;\n }\n\n sum += d;\n double = !double;\n }\n\n const check = (10 - (sum % 10)) % 10;\n\n return String(check);\n}\n\nexport type AmountOptions = {\n readonly min?: number;\n readonly max?: number;\n readonly currency?: 'USD' | 'EUR' | 'GBP';\n};\n\nexport function amount(ctx: IllusionistContext, opts: AmountOptions = {}): Money {\n const min = opts.min ?? 100;\n const max = opts.max ?? 10000;\n const code = opts.currency ?? 'USD';\n const value = floatFixed(min, max, 2, ctx.source);\n\n return money(value.toFixed(2), CURRENCIES[code]);\n}\n\nexport function iban(ctx: IllusionistContext, countryCode?: string): string {\n const country = (countryCode ?? pick(IBAN_COUNTRIES, ctx.source)!) as keyof typeof FINANCE_DATA.ibanLengths;\n\n if (!(country in FINANCE_DATA.ibanLengths)) {\n throw new RangeError(`iban: unsupported country code \"${countryCode}\". Supported: ${IBAN_COUNTRIES.join(', ')}`);\n }\n\n const totalLength = FINANCE_DATA.ibanLengths[country];\n const bbanLength = totalLength - 4;\n const bban = numericString(bbanLength, ctx.source);\n const checkDigits = ibanCheckDigits(country, bban);\n\n return `${country}${checkDigits}${bban}`;\n}\n\nexport function bic(ctx: IllusionistContext): string {\n const bankCode = letters(4, ctx);\n const country = letters(2, ctx);\n const location = alphanumeric(2, ctx.source).toUpperCase();\n const useBranch = int(0, 1, ctx.source) === 1;\n const branch = useBranch ? alphanumeric(3, ctx.source).toUpperCase() : '';\n\n return `${bankCode}${country}${location}${branch}`;\n}\n\nexport function creditCardNumber(ctx: IllusionistContext, type?: CreditCardType): string {\n const cardType = type ?? pick(CREDIT_CARD_TYPES, ctx.source)!;\n const iin = pick(FINANCE_DATA.creditCardIins[cardType], ctx.source)!;\n const totalLength = cardType === 'amex' ? 15 : 16;\n const partial = iin + numericString(totalLength - iin.length - 1, ctx.source);\n const checkDigit = luhnCheckDigit(partial);\n\n return `${partial}${checkDigit}`;\n}\n\nexport function creditCardCVV(ctx: IllusionistContext, type?: CreditCardType): string {\n const cardType = type ?? pick(CREDIT_CARD_TYPES, ctx.source)!;\n const length = cardType === 'amex' ? 4 : 3;\n\n return numericString(length, ctx.source);\n}\n\nexport function bitcoinAddress(ctx: IllusionistContext): string {\n const prefix = pick(['1', '3', 'bc1'], ctx.source)!;\n const suffixLength = int(25, 34, ctx.source);\n\n return `${prefix}${base58String(suffixLength, ctx.source)}`;\n}\n\nexport function ethereumAddress(ctx: IllusionistContext): string {\n return `0x${hexString(40, ctx.source)}`;\n}\n\nexport function transactionType(ctx: IllusionistContext): string {\n return pick(FINANCE_DATA.transactionTypes, ctx.source)!;\n}\n\nexport function bank(ctx: IllusionistContext): string {\n return pick(FINANCE_DATA.banks, ctx.source)!;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;IAQM,IAAsD;CAAE;CAAK;CAAK;AAAI,GAEtE,IAAoB;CAAC;CAAQ;CAAc;AAAM,GAGjD,IAAiB,OAAO,KAAK,EAAa,gBAAgB,GAE1D,IAAU;AAEhB,SAAS,EAAQ,GAAe,GAAiC;CAC/D,IAAI,IAAS;CAEb,KAAK,IAAI,IA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Module`});const e=require("./finance.cjs");exports.amount=e.amount,exports.bank=e.bank,exports.bic=e.bic,exports.bitcoinAddress=e.bitcoinAddress,exports.creditCardCVV=e.creditCardCVV,exports.creditCardNumber=e.creditCardNumber,exports.ethereumAddress=e.ethereumAddress,exports.iban=e.iban,exports.transactionType=e.transactionType;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/finance/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAC"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { amount as e, bank as t, bic as n, bitcoinAddress as r, creditCardCVV as i, creditCardNumber as a, ethereumAddress as o, iban as s, transactionType as c } from "./finance.js";
|
|
2
|
+
export { e as amount, t as bank, n as bic, r as bitcoinAddress, i as creditCardCVV, a as creditCardNumber, o as ethereumAddress, s as iban, c as transactionType };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"iife-entry.d.ts","sourceRoot":"","sources":["../src/iife-entry.ts"],"names":[],"mappings":"AAMA,cAAc,SAAS,CAAC;AACxB,OAAO,EAAE,EAAE,EAAE,MAAM,cAAc,CAAC;AAClC,OAAO,EAAE,EAAE,EAAE,MAAM,cAAc,CAAC"}
|