@mionjs/type-formats 0.8.0-alpha.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/.dist/cjs/BigintFormats.cjs +14 -0
- package/.dist/cjs/BigintFormats.cjs.map +1 -0
- package/.dist/cjs/BigintFormats.d.ts +2 -0
- package/.dist/cjs/NumberFormats.cjs +20 -0
- package/.dist/cjs/NumberFormats.cjs.map +1 -0
- package/.dist/cjs/NumberFormats.d.ts +2 -0
- package/.dist/cjs/StringFormats.cjs +120 -0
- package/.dist/cjs/StringFormats.cjs.map +1 -0
- package/.dist/cjs/StringFormats.d.ts +11 -0
- package/.dist/cjs/constants.d.ts +1 -0
- package/.dist/cjs/package.json +1 -0
- package/.dist/cjs/src/bigint/bigIntFormat.runtype.cjs +152 -0
- package/.dist/cjs/src/bigint/bigIntFormat.runtype.cjs.map +1 -0
- package/.dist/cjs/src/bigint/bigIntFormat.runtype.d.ts +21 -0
- package/.dist/cjs/src/bigint/defaultBigNumberFormats.cjs +16 -0
- package/.dist/cjs/src/bigint/defaultBigNumberFormats.cjs.map +1 -0
- package/.dist/cjs/src/bigint/defaultBigNumberFormats.d.ts +29 -0
- package/.dist/cjs/src/constants.cjs +34 -0
- package/.dist/cjs/src/constants.cjs.map +1 -0
- package/.dist/cjs/src/constants.d.ts +15 -0
- package/.dist/cjs/src/constants.mock.cjs +111 -0
- package/.dist/cjs/src/constants.mock.cjs.map +1 -0
- package/.dist/cjs/src/constants.mock.d.ts +335 -0
- package/.dist/cjs/src/number/defaultNumberFormats.cjs +28 -0
- package/.dist/cjs/src/number/defaultNumberFormats.cjs.map +1 -0
- package/.dist/cjs/src/number/defaultNumberFormats.d.ts +63 -0
- package/.dist/cjs/src/number/numberFormat.runtype.cjs +214 -0
- package/.dist/cjs/src/number/numberFormat.runtype.cjs.map +1 -0
- package/.dist/cjs/src/number/numberFormat.runtype.d.ts +21 -0
- package/.dist/cjs/src/string/date.runtype.cjs +88 -0
- package/.dist/cjs/src/string/date.runtype.cjs.map +1 -0
- package/.dist/cjs/src/string/date.runtype.d.ts +19 -0
- package/.dist/cjs/src/string/dateTime.runtype.cjs +83 -0
- package/.dist/cjs/src/string/dateTime.runtype.cjs.map +1 -0
- package/.dist/cjs/src/string/dateTime.runtype.d.ts +26 -0
- package/.dist/cjs/src/string/defaultStringFormats.runtype.cjs +25 -0
- package/.dist/cjs/src/string/defaultStringFormats.runtype.cjs.map +1 -0
- package/.dist/cjs/src/string/defaultStringFormats.runtype.d.ts +45 -0
- package/.dist/cjs/src/string/domain.runtype.cjs +248 -0
- package/.dist/cjs/src/string/domain.runtype.cjs.map +1 -0
- package/.dist/cjs/src/string/domain.runtype.d.ts +72 -0
- package/.dist/cjs/src/string/email.runtype.cjs +159 -0
- package/.dist/cjs/src/string/email.runtype.cjs.map +1 -0
- package/.dist/cjs/src/string/email.runtype.d.ts +57 -0
- package/.dist/cjs/src/string/ip.runtype.cjs +72 -0
- package/.dist/cjs/src/string/ip.runtype.cjs.map +1 -0
- package/.dist/cjs/src/string/ip.runtype.d.ts +50 -0
- package/.dist/cjs/src/string/stringFormat.runtype.cjs +270 -0
- package/.dist/cjs/src/string/stringFormat.runtype.cjs.map +1 -0
- package/.dist/cjs/src/string/stringFormat.runtype.d.ts +21 -0
- package/.dist/cjs/src/string/time.runtype.cjs +100 -0
- package/.dist/cjs/src/string/time.runtype.cjs.map +1 -0
- package/.dist/cjs/src/string/time.runtype.d.ts +21 -0
- package/.dist/cjs/src/string/url.runtype.cjs +160 -0
- package/.dist/cjs/src/string/url.runtype.cjs.map +1 -0
- package/.dist/cjs/src/string/url.runtype.d.ts +81 -0
- package/.dist/cjs/src/string/uuid.runtype.cjs +44 -0
- package/.dist/cjs/src/string/uuid.runtype.cjs.map +1 -0
- package/.dist/cjs/src/string/uuid.runtype.d.ts +22 -0
- package/.dist/cjs/src/type-formats-pure-fns.cjs +390 -0
- package/.dist/cjs/src/type-formats-pure-fns.cjs.map +1 -0
- package/.dist/cjs/src/type-formats-pure-fns.d.ts +27 -0
- package/.dist/cjs/src/utils.cjs +14 -0
- package/.dist/cjs/src/utils.cjs.map +1 -0
- package/.dist/cjs/src/utils.d.ts +3 -0
- package/.dist/cjs/vitest.config.d.ts +2 -0
- package/.dist/esm/BigintFormats.d.ts +2 -0
- package/.dist/esm/BigintFormats.js +14 -0
- package/.dist/esm/BigintFormats.js.map +1 -0
- package/.dist/esm/NumberFormats.d.ts +2 -0
- package/.dist/esm/NumberFormats.js +20 -0
- package/.dist/esm/NumberFormats.js.map +1 -0
- package/.dist/esm/StringFormats.d.ts +11 -0
- package/.dist/esm/StringFormats.js +120 -0
- package/.dist/esm/StringFormats.js.map +1 -0
- package/.dist/esm/constants.d.ts +1 -0
- package/.dist/esm/src/bigint/bigIntFormat.runtype.d.ts +21 -0
- package/.dist/esm/src/bigint/bigIntFormat.runtype.js +152 -0
- package/.dist/esm/src/bigint/bigIntFormat.runtype.js.map +1 -0
- package/.dist/esm/src/bigint/defaultBigNumberFormats.d.ts +29 -0
- package/.dist/esm/src/bigint/defaultBigNumberFormats.js +16 -0
- package/.dist/esm/src/bigint/defaultBigNumberFormats.js.map +1 -0
- package/.dist/esm/src/constants.d.ts +15 -0
- package/.dist/esm/src/constants.js +34 -0
- package/.dist/esm/src/constants.js.map +1 -0
- package/.dist/esm/src/constants.mock.d.ts +335 -0
- package/.dist/esm/src/constants.mock.js +111 -0
- package/.dist/esm/src/constants.mock.js.map +1 -0
- package/.dist/esm/src/number/defaultNumberFormats.d.ts +63 -0
- package/.dist/esm/src/number/defaultNumberFormats.js +28 -0
- package/.dist/esm/src/number/defaultNumberFormats.js.map +1 -0
- package/.dist/esm/src/number/numberFormat.runtype.d.ts +21 -0
- package/.dist/esm/src/number/numberFormat.runtype.js +214 -0
- package/.dist/esm/src/number/numberFormat.runtype.js.map +1 -0
- package/.dist/esm/src/string/date.runtype.d.ts +19 -0
- package/.dist/esm/src/string/date.runtype.js +88 -0
- package/.dist/esm/src/string/date.runtype.js.map +1 -0
- package/.dist/esm/src/string/dateTime.runtype.d.ts +26 -0
- package/.dist/esm/src/string/dateTime.runtype.js +83 -0
- package/.dist/esm/src/string/dateTime.runtype.js.map +1 -0
- package/.dist/esm/src/string/defaultStringFormats.runtype.d.ts +45 -0
- package/.dist/esm/src/string/defaultStringFormats.runtype.js +25 -0
- package/.dist/esm/src/string/defaultStringFormats.runtype.js.map +1 -0
- package/.dist/esm/src/string/domain.runtype.d.ts +72 -0
- package/.dist/esm/src/string/domain.runtype.js +248 -0
- package/.dist/esm/src/string/domain.runtype.js.map +1 -0
- package/.dist/esm/src/string/email.runtype.d.ts +57 -0
- package/.dist/esm/src/string/email.runtype.js +159 -0
- package/.dist/esm/src/string/email.runtype.js.map +1 -0
- package/.dist/esm/src/string/ip.runtype.d.ts +50 -0
- package/.dist/esm/src/string/ip.runtype.js +72 -0
- package/.dist/esm/src/string/ip.runtype.js.map +1 -0
- package/.dist/esm/src/string/stringFormat.runtype.d.ts +21 -0
- package/.dist/esm/src/string/stringFormat.runtype.js +270 -0
- package/.dist/esm/src/string/stringFormat.runtype.js.map +1 -0
- package/.dist/esm/src/string/time.runtype.d.ts +21 -0
- package/.dist/esm/src/string/time.runtype.js +100 -0
- package/.dist/esm/src/string/time.runtype.js.map +1 -0
- package/.dist/esm/src/string/url.runtype.d.ts +81 -0
- package/.dist/esm/src/string/url.runtype.js +160 -0
- package/.dist/esm/src/string/url.runtype.js.map +1 -0
- package/.dist/esm/src/string/uuid.runtype.d.ts +22 -0
- package/.dist/esm/src/string/uuid.runtype.js +44 -0
- package/.dist/esm/src/string/uuid.runtype.js.map +1 -0
- package/.dist/esm/src/type-formats-pure-fns.d.ts +27 -0
- package/.dist/esm/src/type-formats-pure-fns.js +390 -0
- package/.dist/esm/src/type-formats-pure-fns.js.map +1 -0
- package/.dist/esm/src/utils.d.ts +3 -0
- package/.dist/esm/src/utils.js +14 -0
- package/.dist/esm/src/utils.js.map +1 -0
- package/.dist/esm/vitest.config.d.ts +2 -0
- package/LICENSE +21 -0
- package/README.md +123 -0
- package/package.json +80 -0
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
const __ΩEMAIL_NAME_SAMPLES = ["john.doe", "jane.smith", "admin", "support", "contact", "info", "sales", "marketing", "hello", "feedback", "user123", "test.account", "random.name", "developer", "webmaster", "juan.perez", "maria.garcia", "soporte", "contacto", "ventas", "informacion", "hola", "usuario", "prueba", "desarrollador", "jean.dupont", "marie.curie", "contact", "support", "vente", "bonjour", "utilisateur", "testeur", "developpeur", "hans.schmidt", "anna.müller", "kontakt", "hilfe", "verkauf", "benutzer", "testkonto", "entwickler", "giuseppe.rossi", "maria.bianchi", "contatto", "supporto", "vendite", "utente", "prova", "sviluppatore", "joao.silva", "maria.oliveira", "contato", "suporte", "vendas", "usuario", "teste", "desenvolvedor", "홍길동", "김철수", "고객지원", "연락처", "판매", "사용자", "山田太郎", "鈴木花子", "情報", "サポート", "日本語", "テスト", "携帯", "電子", "李伟", "王芳", "张三", "联系", "测试", "用户", "开发", "arjun.sharma", "priya.kumar", "support", "contact", "vikas", "pariksha", "upayogakarta", "иван.иванов", "анна.петровна", "поддержка", "контакт", "продажи", "пользователь", "разработчик", "alpha.beta", "charlie.delta", "test123", "mock.user", "example.name", "first.last", "nickname", "alias", "temp.account", "demo.user", "EMAIL_NAME_SAMPLES", "P.!.\".#.$.%.&.'.(.).*.+.,.-.../.0.1.2.3.4.5.6.7.8.9.:.;.<.=.>.?.@.A.B.C.D.E.F.G.H.I.J.K.L.M.N.O.P.Q.R.S.T.U.V.W.X.Y.Z.[.\\.].^._.`.a.b.c.d.e.f.g.h.i.j.k.l.m.n.o.p.q.r.s.t.u.v.w.x.y.z.{.|.}.~.......
..Gwy"];
|
|
2
|
+
const __ΩEMAIL_SAMPLES = ["john.doe@mion.io", "jane.smith@rpc.org", "admin@wiki.org", "support@www.mion.org", "contact@www.api.org", "info@arch.org", "sales@ccmns.org", "marketing@eff.org", "hello@fsf.org", "feedback@opensource.org", "user123@node.org", "test.account@typescript.org", "random.name@rpc.org", "developer@fullstack.org", "webmaster@mion.io", "juan.perez@wiki.org", "maria.garcia@arch.org", "soporte@ccmns.org", "contacto@eff.org", "ventas@fsf.org", "informacion@opensource.org", "hola@node.org", "usuario@typescript.org", "prueba@rpc.org", "desarrollador@fullstack.org", "jean.dupont@mion.io", "marie.curie@wiki.org", "vente@arch.org", "bonjour@ccmns.org", "utilisateur@eff.org", "testeur@fsf.org", "developpeur@opensource.org", "anna.müller@node.org", "anna.schmidt@typescript.org", "kontakt@rpc.org", "hilfe@fullstack.org", "verkauf@mion.io", "benutzer@wiki.org", "entwickler@arch.org", "王芳@ccmns.org", "联系@eff.org", "测试@fsf.org", "ceshi@opensource.org", "张三@node.org", "kaifa@typescript.org", "arjun.sharma@rpc.org", "priya.kumar@fullstack.org", "vikas@mion.io", "pariksha@wiki.org", "upayogakarta@arch.org", "иван.иванов@ccmns.org", "анна.петровна@eff.org", "поддержка@fsf.org", "контакт@opensource.org", "продажи@node.org", "пользователь@typescript.org", "разработчик@rpc.org", "alpha.beta@fullstack.org", "charlie.delta@mion.io", "test123@wiki.org", "mock.user@arch.org", "example.name@ccmns.org", "first.last@eff.org", "nickname@fsf.org", "alias@opensource.org", "temp.account@node.org", "demo.user@typescript.org", "email+tag@mion.io", "email-with-hyphen@rpc.org", "email_with_underscore@wiki.org", "very.common@arch.org", "!#$%&'*+-/=?^_`{|}~@ccmns.org", '"quoted"@eff.org', '"very.(),:;<>[]\\"@opensource.org', "user.name+tag+sorting@example.com", "x@example.com", "example-indeed@strange-example.com", "test/test@test.com", 'very."(),:;<>[]..very.unusual@strange.example.com', "user%example.com@mion.io", "user-@example.org", "EMAIL_SAMPLES", "P.!.\".#.$.%.&.'.(.).*.+.,.-.../.0.1.2.3.4.5.6.7.8.9.:.;.<.=.>.?.@.A.B.C.D.E.F.G.H.I.J.K.L.M.N.O.P.Q.R.S.T.U.V.W.X.Y.Z.[.\\.].^._.`.a.b.c.d.e.f.g.h.i.j.k.l.m.n.o.p.qGwry"];
|
|
3
|
+
const __ΩEMAIL_SAMPLES_PUNYCODE = ["john.doe@mion.io", "jane.smith@rpc.org", "admin@xn--e1afmkfd.xn--p1ai", "support@xn--80aaicww6a.xn--p1acf", "juan.perez@wiki.org", "maria.garcia@arch.org", "soporte@xn--mgbh0fb.xn--kgbechtv", "contacto@xn--fiqz9s.xn--fiqs8s", "иван.иванов@ccmns.org", "анна.петровна@xn--80adxhks.xn--p1ai", "поддержка@xn--d1acufc.xn--j1amh", "user.name+tag+sorting@example.com", "user@sub-domain.example-site.com", "user@domain.with-number123.com", "user@xn--80akhbyknj4f.xn--p1ai", "x@xn--mgberp4a5d4ar.xn--mgbaam7a8h", "test@xn--qxam.xn--zckzah", "info@xn--9n2bp8q.xn--9t4b11yi5a", "EMAIL_SAMPLES_PUNYCODE", `P.!.".#.$.%.&.'.(.).*.+.,.-.../.0.1.2Gw3y`];
|
|
4
|
+
const __ΩURL_SAMPLES = ["https://mion.io", "https://rpc.org", "http://wiki.org", "https://www.mion.org", "http://www.api.org", "https://arch.org/path/to/resource", "http://ccmns.org/path/to/resource", "https://eff.org?query=param", "http://fsf.org?query=param#hello-world", "https://opensource.org#fragment", "http://node.org#fragment", "https://subdomain.typescript.org", "http://subdomain.rpc.org", "https://fullstack.org:8080", "http://localhost:8080/path/to/resource", "https://127.0.0.1:8080/path/to/resource", "https://254.60.167.80:80/path/to/resource", "http://:8080/path/to/resource", "http://[::1]:8080/path/to/resource", "http://[::]:8080/path/to/resource?query=param", "http://[::1]:8080/path/to/resource#fragment", "http://[::1]/path/to/resource", "ws://mion.io/socket", "ws://websocket.org/socket", "wss://socket.io/socket", "ws://live.com/socket?query=param", "wss://sock.org/socket?query=param#fragment", "ws://socketcluster.io/socket#fragment", "wss://developer..dev:8080/socket", "ws://fast.com:8080/socket?query=param", "ftp://example.com/file.txt", "ftps://example.com/file.txt", "URL_SAMPLES", `P.!.".#.$.%.&.'.(.).*.+.,.-.../.0.1.2.3.4.5.6.7.8.9.:.;.<.=.>.?.@GwAy`];
|
|
5
|
+
const __ΩFILE_URL_SAMPLES = ["file:///path/to/file.txt", "file:///C:/path/to/file.txt", "file://localhost/path/to/file.txt", "file:///home/user/file.txt", "file://example.com/path/to/file.txt", "file:///C:/Users/User/Documents/file.txt", "file:///tmp/file.txt", "file:///var/log/syslog", "file:///path/to/file.txt?query=param", "file:///C:/path/to/file.txt?query=param", "file:///path/to/file%20with%20spaces.txt", "file:///path/to/file@with@special#characters.txt", "file://localhost/path/to/file.txt", "file://localhost/C:/path/to/file.txt", "file://localhost/home/user/file.txt", "file://127.0.0.1:890/example.com/path/to/file.txt", "file://localhost/path/to/file.txt?query=param", "file:///home/user/file.txt?query=param", "FILE_URL_SAMPLES", `P.!.".#.$.%.&.'.(.).*.+.,.-.../.0.1.2Gw3y`];
|
|
6
|
+
const __ΩHTTP_URL_SAMPLES = ["https://mion.io", "https://rpc.org", "http://wiki.org", "https://www.mion.org", "http://www.api.org", "https://arch.org/path/to/resource", "http://ccmns.org/path/to/resource", "https://eff.org?query=param", "http://fsf.org?query=param#hello-world", "https://opensource.org#fragment", "http://node.org#fragment", "https://subdomain.typescript.org", "http://subdomain.rpc.org", "https://fullstack.org:8080", "http://localhost:8080/path/to/resource", "https://127.0.0.1:8080/path/to/resource", "https://254.60.167.80:80/path/to/resource", "http://:8080/path/to/resource", "http://[::1]:8080/path/to/resource", "http://[::]:8080/path/to/resource?query=param", "http://[::1]:8080/path/to/resource#fragment", "http://[::1]/path/to/resource", "HTTP_URL_SAMPLES", `P.!.".#.$.%.&.'.(.).*.+.,.-.../.0.1.2.3.4.5.6Gw7y`];
|
|
7
|
+
const __ΩSOCIAL_MEDIA_URL_SAMPLES = ["https://www.facebook.com/user", "https://twitter.com/user", "https://www.instagram.com/user/", "https://www.linkedin.com/in/user/", "https://www.tiktok.com/@user", "https://www.youtube.com/c/user", "https://www.snapchat.com/add/user", "https://www.pinterest.com/user?query=param", "https://www.reddit.com/user/user#fragment", "https://www.whatsapp.com/user/", "http://www.facebook.com/user", "http://twitter.com/user", "http://www.instagram.com/user/", "http://www.linkedin.com/in/user/?query=param", "http://www.tiktok.com/@user", "http://www.youtube.com/c/user", "http://www.snapchat.com/add/user?query=param#fragment", "http://www.pinterest.com/user/", "http://www.reddit.com/user/user/#fragment", "http://www.whatsapp.com/user/", "SOCIAL_MEDIA_URL_SAMPLES", `P.!.".#.$.%.&.'.(.).*.+.,.-.../.0.1.2.3.4Gw5y`];
|
|
8
|
+
const __ΩSOCIAL_MEDIA_DOMAINS_SAMPLES = ["facebook", "twitter", "instagram", "linkedin", "tiktok", "youtube", "snapchat", "pinterest", "reddit", "whatsapp", "SOCIAL_MEDIA_DOMAINS_SAMPLES", `P.!.".#.$.%.&.'.(.).*Gw+y`];
|
|
9
|
+
const TLD_SAMPLES = [
|
|
10
|
+
"com",
|
|
11
|
+
"org",
|
|
12
|
+
"net",
|
|
13
|
+
"io",
|
|
14
|
+
"ai",
|
|
15
|
+
"app",
|
|
16
|
+
"co",
|
|
17
|
+
"dev",
|
|
18
|
+
"tech",
|
|
19
|
+
"co.uk",
|
|
20
|
+
"com.au",
|
|
21
|
+
"com.br",
|
|
22
|
+
"com.mx",
|
|
23
|
+
"com.ar"
|
|
24
|
+
];
|
|
25
|
+
const NAME_SAMPLES = [
|
|
26
|
+
"mion",
|
|
27
|
+
"mionkit",
|
|
28
|
+
"example",
|
|
29
|
+
"gogle",
|
|
30
|
+
"fcbook",
|
|
31
|
+
"amzn",
|
|
32
|
+
"twitt",
|
|
33
|
+
"insta",
|
|
34
|
+
"linked",
|
|
35
|
+
"yoube",
|
|
36
|
+
"pinturist",
|
|
37
|
+
"mion",
|
|
38
|
+
"mionkit",
|
|
39
|
+
"wiki",
|
|
40
|
+
"red",
|
|
41
|
+
"line",
|
|
42
|
+
"hello",
|
|
43
|
+
"world",
|
|
44
|
+
"test",
|
|
45
|
+
"random",
|
|
46
|
+
"user",
|
|
47
|
+
"developer",
|
|
48
|
+
"webmaster",
|
|
49
|
+
"admin",
|
|
50
|
+
"support",
|
|
51
|
+
"contact",
|
|
52
|
+
"info",
|
|
53
|
+
"mion",
|
|
54
|
+
"mionkit"
|
|
55
|
+
];
|
|
56
|
+
const TLD_CHARS = "abcdefghijklmnopqrstuvwxyz";
|
|
57
|
+
const NAME_CHARS = "abcdefghijklmnopqrstuvwxyz0123456789";
|
|
58
|
+
const NAME_CHARS_UNICODE = "abcdefghijklmnopqrstuvwxyz0123456789абвгдеёжзийклмнопрстуфхцчшщъыьэюяあいうえおかきくけこさしすせそたちつてとなにぬねのアイウエオカキクケコサシスセソタチツテト中国网址域名汉字电脑互联网技术计算机软件编程한국어도메인이름인터넷기술컴퓨터소프트웨어프로그래밍ابتثجحخدذرزسشصضطظعغفقكلمنهوي";
|
|
59
|
+
const INTERNET_PROTOCOLS = ["http", "https", "ftp", "ftps", "ws", "wss", "file"];
|
|
60
|
+
const EMAIL_NAME_SAMPLES_ARRAY = [
|
|
61
|
+
"john.doe",
|
|
62
|
+
"jane.smith",
|
|
63
|
+
"admin",
|
|
64
|
+
"support",
|
|
65
|
+
"contact",
|
|
66
|
+
"info",
|
|
67
|
+
"sales",
|
|
68
|
+
"marketing",
|
|
69
|
+
"hello",
|
|
70
|
+
"feedback",
|
|
71
|
+
"user123",
|
|
72
|
+
"test.account",
|
|
73
|
+
"random.name",
|
|
74
|
+
"developer",
|
|
75
|
+
"webmaster",
|
|
76
|
+
"juan.perez",
|
|
77
|
+
"maria.garcia",
|
|
78
|
+
"soporte",
|
|
79
|
+
"contacto",
|
|
80
|
+
"ventas",
|
|
81
|
+
"informacion",
|
|
82
|
+
"hola",
|
|
83
|
+
"usuario",
|
|
84
|
+
"prueba",
|
|
85
|
+
"desarrollador",
|
|
86
|
+
"jean.dupont",
|
|
87
|
+
"marie.curie",
|
|
88
|
+
"vente",
|
|
89
|
+
"bonjour",
|
|
90
|
+
"utilisateur",
|
|
91
|
+
"testeur",
|
|
92
|
+
"developpeur"
|
|
93
|
+
];
|
|
94
|
+
export {
|
|
95
|
+
EMAIL_NAME_SAMPLES_ARRAY,
|
|
96
|
+
INTERNET_PROTOCOLS,
|
|
97
|
+
NAME_CHARS,
|
|
98
|
+
NAME_CHARS_UNICODE,
|
|
99
|
+
NAME_SAMPLES,
|
|
100
|
+
TLD_CHARS,
|
|
101
|
+
TLD_SAMPLES,
|
|
102
|
+
__ΩEMAIL_NAME_SAMPLES,
|
|
103
|
+
__ΩEMAIL_SAMPLES,
|
|
104
|
+
__ΩEMAIL_SAMPLES_PUNYCODE,
|
|
105
|
+
__ΩFILE_URL_SAMPLES,
|
|
106
|
+
__ΩHTTP_URL_SAMPLES,
|
|
107
|
+
__ΩSOCIAL_MEDIA_DOMAINS_SAMPLES,
|
|
108
|
+
__ΩSOCIAL_MEDIA_URL_SAMPLES,
|
|
109
|
+
__ΩURL_SAMPLES
|
|
110
|
+
};
|
|
111
|
+
//# sourceMappingURL=constants.mock.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.mock.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { FormatNumber } from './numberFormat.runtype.ts';
|
|
2
|
+
export type FormatInteger = FormatNumber<{
|
|
3
|
+
integer: true;
|
|
4
|
+
}, 'integer'>;
|
|
5
|
+
export type FormatFloat = FormatNumber<{
|
|
6
|
+
float: true;
|
|
7
|
+
}, 'float'>;
|
|
8
|
+
export type FormatPositive = FormatNumber<{
|
|
9
|
+
min: 0;
|
|
10
|
+
}, 'positive'>;
|
|
11
|
+
export type FormatNegative = FormatNumber<{
|
|
12
|
+
max: 0;
|
|
13
|
+
}, 'negative'>;
|
|
14
|
+
export type FormatPositiveInt = FormatNumber<{
|
|
15
|
+
min: 0;
|
|
16
|
+
integer: true;
|
|
17
|
+
}, 'positiveInt'>;
|
|
18
|
+
export type FormatNegativeInt = FormatNumber<{
|
|
19
|
+
max: 0;
|
|
20
|
+
integer: true;
|
|
21
|
+
}, 'negativeInt'>;
|
|
22
|
+
export type FormatInt8 = FormatNumber<{
|
|
23
|
+
integer: true;
|
|
24
|
+
min: -128;
|
|
25
|
+
max: 127;
|
|
26
|
+
}, 'int8'>;
|
|
27
|
+
export type FormatInt16 = FormatNumber<{
|
|
28
|
+
integer: true;
|
|
29
|
+
min: -32768;
|
|
30
|
+
max: 32767;
|
|
31
|
+
}, 'int16'>;
|
|
32
|
+
export type FormatInt32 = FormatNumber<{
|
|
33
|
+
integer: true;
|
|
34
|
+
min: -2147483648;
|
|
35
|
+
max: 2147483647;
|
|
36
|
+
}, 'int32'>;
|
|
37
|
+
export type FormatUInt8 = FormatNumber<{
|
|
38
|
+
integer: true;
|
|
39
|
+
min: 0;
|
|
40
|
+
max: 255;
|
|
41
|
+
}, 'uint8'>;
|
|
42
|
+
export type FormatUInt16 = FormatNumber<{
|
|
43
|
+
integer: true;
|
|
44
|
+
min: 0;
|
|
45
|
+
max: 65535;
|
|
46
|
+
}, 'uint16'>;
|
|
47
|
+
export type FormatUInt32 = FormatNumber<{
|
|
48
|
+
integer: true;
|
|
49
|
+
min: 0;
|
|
50
|
+
max: 4294967295;
|
|
51
|
+
}, 'uint32'>;
|
|
52
|
+
export declare type __ΩFormatInteger = any[];
|
|
53
|
+
export declare type __ΩFormatFloat = any[];
|
|
54
|
+
export declare type __ΩFormatPositive = any[];
|
|
55
|
+
export declare type __ΩFormatNegative = any[];
|
|
56
|
+
export declare type __ΩFormatPositiveInt = any[];
|
|
57
|
+
export declare type __ΩFormatNegativeInt = any[];
|
|
58
|
+
export declare type __ΩFormatInt8 = any[];
|
|
59
|
+
export declare type __ΩFormatInt16 = any[];
|
|
60
|
+
export declare type __ΩFormatInt32 = any[];
|
|
61
|
+
export declare type __ΩFormatUInt8 = any[];
|
|
62
|
+
export declare type __ΩFormatUInt16 = any[];
|
|
63
|
+
export declare type __ΩFormatUInt32 = any[];
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { __ΩFormatNumber as ___FormatNumber } from "./numberFormat.runtype.js";
|
|
2
|
+
const __ΩFormatInteger = [() => ___FormatNumber, true, "integer", "integer", "FormatInteger", 'P."4#M.$o!#w%y'];
|
|
3
|
+
const __ΩFormatFloat = [() => ___FormatNumber, true, "float", "float", "FormatFloat", 'P."4#M.$o!#w%y'];
|
|
4
|
+
const __ΩFormatPositive = [() => ___FormatNumber, 0, "min", "positive", "FormatPositive", 'P."4#M.$o!#w%y'];
|
|
5
|
+
const __ΩFormatNegative = [() => ___FormatNumber, 0, "max", "negative", "FormatNegative", 'P."4#M.$o!#w%y'];
|
|
6
|
+
const __ΩFormatPositiveInt = [() => ___FormatNumber, 0, "min", true, "integer", "positiveInt", "FormatPositiveInt", `P."4#.$4%M.&o!#w'y`];
|
|
7
|
+
const __ΩFormatNegativeInt = [() => ___FormatNumber, 0, "max", true, "integer", "negativeInt", "FormatNegativeInt", `P."4#.$4%M.&o!#w'y`];
|
|
8
|
+
const __ΩFormatInt8 = [() => ___FormatNumber, true, "integer", -128, "min", 127, "max", "int8", "FormatInt8", `P."4#.$4%.&4'M.(o!#w)y`];
|
|
9
|
+
const __ΩFormatInt16 = [() => ___FormatNumber, true, "integer", -32768, "min", 32767, "max", "int16", "FormatInt16", `P."4#.$4%.&4'M.(o!#w)y`];
|
|
10
|
+
const __ΩFormatInt32 = [() => ___FormatNumber, true, "integer", -2147483648, "min", 2147483647, "max", "int32", "FormatInt32", `P."4#.$4%.&4'M.(o!#w)y`];
|
|
11
|
+
const __ΩFormatUInt8 = [() => ___FormatNumber, true, "integer", 0, "min", 255, "max", "uint8", "FormatUInt8", `P."4#.$4%.&4'M.(o!#w)y`];
|
|
12
|
+
const __ΩFormatUInt16 = [() => ___FormatNumber, true, "integer", 0, "min", 65535, "max", "uint16", "FormatUInt16", `P."4#.$4%.&4'M.(o!#w)y`];
|
|
13
|
+
const __ΩFormatUInt32 = [() => ___FormatNumber, true, "integer", 0, "min", 4294967295, "max", "uint32", "FormatUInt32", `P."4#.$4%.&4'M.(o!#w)y`];
|
|
14
|
+
export {
|
|
15
|
+
__ΩFormatFloat,
|
|
16
|
+
__ΩFormatInt16,
|
|
17
|
+
__ΩFormatInt32,
|
|
18
|
+
__ΩFormatInt8,
|
|
19
|
+
__ΩFormatInteger,
|
|
20
|
+
__ΩFormatNegative,
|
|
21
|
+
__ΩFormatNegativeInt,
|
|
22
|
+
__ΩFormatPositive,
|
|
23
|
+
__ΩFormatPositiveInt,
|
|
24
|
+
__ΩFormatUInt16,
|
|
25
|
+
__ΩFormatUInt32,
|
|
26
|
+
__ΩFormatUInt8
|
|
27
|
+
};
|
|
28
|
+
//# sourceMappingURL=defaultNumberFormats.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"defaultNumberFormats.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { BaseRunType, JitFnCompiler, JitErrorsFnCompiler, JitCode, jitBinarySerializerArgs, JitFunctions, BaseFnCompiler, jitBinaryDeserializerArgs, TypeFormat, BaseRunTypeFormat, RunTypeOptions } from '@mionjs/run-types';
|
|
2
|
+
import { ReflectionKind } from '@deepkit/type';
|
|
3
|
+
import { FormatParams_Number } from '@mionjs/core';
|
|
4
|
+
type BinarySerializer = BaseFnCompiler<typeof jitBinarySerializerArgs, typeof JitFunctions.toBinary.id>;
|
|
5
|
+
type BinaryDeserializer = BaseFnCompiler<typeof jitBinaryDeserializerArgs, typeof JitFunctions.fromBinary.id>;
|
|
6
|
+
export declare class NumberRunTypeFormat extends BaseRunTypeFormat<FormatParams_Number> {
|
|
7
|
+
static readonly id: "numberFormat";
|
|
8
|
+
readonly kind = ReflectionKind.number;
|
|
9
|
+
readonly name: "numberFormat";
|
|
10
|
+
emitIsType(comp: JitFnCompiler, rt: BaseRunType): JitCode;
|
|
11
|
+
emitIsTypeErrors(comp: JitErrorsFnCompiler, rt: BaseRunType): JitCode;
|
|
12
|
+
emitFormat(): JitCode;
|
|
13
|
+
emitToBinary(comp: BinarySerializer, rt: BaseRunType): JitCode;
|
|
14
|
+
emitFromBinary(comp: BinaryDeserializer, rt: BaseRunType): JitCode;
|
|
15
|
+
_mock(opts: RunTypeOptions, rt: BaseRunType): number;
|
|
16
|
+
validateParams(rt: BaseRunType, params: FormatParams_Number): void;
|
|
17
|
+
}
|
|
18
|
+
export declare const NUMBER_RUN_TYPE_FORMATTER: NumberRunTypeFormat;
|
|
19
|
+
export type FormatNumber<P extends Partial<FormatParams_Number>, BrandName extends string = never> = TypeFormat<number, typeof NumberRunTypeFormat.id, P, BrandName>;
|
|
20
|
+
export {};
|
|
21
|
+
export declare type __ΩFormatNumber = any[];
|
|
@@ -0,0 +1,214 @@
|
|
|
1
|
+
import { registerFormatter, BaseRunTypeFormat, random, __ΩTypeFormat as ___TypeFormat } from "@mionjs/run-types";
|
|
2
|
+
import { ReflectionKind } from "@deepkit/type";
|
|
3
|
+
import { paramVal } from "../utils.js";
|
|
4
|
+
class NumberRunTypeFormat extends BaseRunTypeFormat {
|
|
5
|
+
static id = "numberFormat";
|
|
6
|
+
kind = ReflectionKind.number;
|
|
7
|
+
name = NumberRunTypeFormat.id;
|
|
8
|
+
emitIsType(comp, rt) {
|
|
9
|
+
const params = this.getParams(rt);
|
|
10
|
+
const v = comp.vλl;
|
|
11
|
+
const conditions = [];
|
|
12
|
+
if (params.integer) {
|
|
13
|
+
conditions.push(`Number.isInteger(${v})`);
|
|
14
|
+
} else if (params.float) {
|
|
15
|
+
conditions.push(`!Number.isInteger(${v})`);
|
|
16
|
+
}
|
|
17
|
+
if (params.max !== void 0) {
|
|
18
|
+
const maxVal = paramVal(params.max);
|
|
19
|
+
conditions.push(`${v} <= ${maxVal}`);
|
|
20
|
+
}
|
|
21
|
+
if (params.min !== void 0) {
|
|
22
|
+
const minVal = paramVal(params.min);
|
|
23
|
+
conditions.push(`${v} >= ${minVal}`);
|
|
24
|
+
}
|
|
25
|
+
if (params.lt !== void 0) {
|
|
26
|
+
const ltVal = paramVal(params.lt);
|
|
27
|
+
conditions.push(`${v} < ${ltVal}`);
|
|
28
|
+
}
|
|
29
|
+
if (params.gt !== void 0) {
|
|
30
|
+
const gtVal = paramVal(params.gt);
|
|
31
|
+
conditions.push(`${v} > ${gtVal}`);
|
|
32
|
+
}
|
|
33
|
+
if (params.multipleOf !== void 0) {
|
|
34
|
+
const multipleOfVal = paramVal(params.multipleOf);
|
|
35
|
+
conditions.push(`(${v} % ${multipleOfVal} === 0)`);
|
|
36
|
+
}
|
|
37
|
+
return { code: conditions.join(" && "), type: "E" };
|
|
38
|
+
}
|
|
39
|
+
emitIsTypeErrors(comp, rt) {
|
|
40
|
+
const params = this.getParams(rt);
|
|
41
|
+
const v = comp.vλl;
|
|
42
|
+
const errFn = this.getCallJitFormatErr(comp, rt, this, false);
|
|
43
|
+
const conditions = [];
|
|
44
|
+
if (params.integer) {
|
|
45
|
+
conditions.push(`if (!Number.isInteger(${v})) ${errFn("integer", true)}`);
|
|
46
|
+
} else if (params.float) {
|
|
47
|
+
conditions.push(`if (Number.isInteger(${v})) ${errFn("float", true)}`);
|
|
48
|
+
}
|
|
49
|
+
if (params.max !== void 0) {
|
|
50
|
+
const maxVal = paramVal(params.max);
|
|
51
|
+
conditions.push(`if (${v} > ${maxVal}) ${errFn("max", maxVal)}`);
|
|
52
|
+
}
|
|
53
|
+
if (params.min !== void 0) {
|
|
54
|
+
const minVal = paramVal(params.min);
|
|
55
|
+
conditions.push(`if (${v} < ${minVal}) ${errFn("min", minVal)}`);
|
|
56
|
+
}
|
|
57
|
+
if (params.lt !== void 0) {
|
|
58
|
+
const ltVal = paramVal(params.lt);
|
|
59
|
+
conditions.push(`if (${v} >= ${ltVal}) ${errFn("lt", ltVal)}`);
|
|
60
|
+
}
|
|
61
|
+
if (params.gt !== void 0) {
|
|
62
|
+
const gtVal = paramVal(params.gt);
|
|
63
|
+
conditions.push(`if (${v} <= ${gtVal}) ${errFn("gt", gtVal)}`);
|
|
64
|
+
}
|
|
65
|
+
if (params.multipleOf !== void 0) {
|
|
66
|
+
const multipleOfVal = paramVal(params.multipleOf);
|
|
67
|
+
conditions.push(`if ((${v} % ${multipleOfVal} !== 0)) ${errFn("multipleOf", multipleOfVal)}`);
|
|
68
|
+
}
|
|
69
|
+
return { code: conditions.join(";"), type: "S" };
|
|
70
|
+
}
|
|
71
|
+
// No format transformation needed for numbers
|
|
72
|
+
emitFormat() {
|
|
73
|
+
return { code: void 0, type: "S" };
|
|
74
|
+
}
|
|
75
|
+
emitToBinary(comp, rt) {
|
|
76
|
+
const type = "S";
|
|
77
|
+
const sεr = comp.args.sεr;
|
|
78
|
+
const params = this.getParams(rt);
|
|
79
|
+
const isFloat = params.float !== void 0 ? paramVal(params.float) : false;
|
|
80
|
+
const floatCode = `${sεr}.view.setFloat64(${sεr}.index,${comp.vλl}, 1, (${sεr}.index += 8))`;
|
|
81
|
+
if (isFloat)
|
|
82
|
+
return { code: floatCode, type };
|
|
83
|
+
const isInt = params.integer !== void 0 ? paramVal(params.integer) : false;
|
|
84
|
+
if (isInt) {
|
|
85
|
+
const { isUint8, isUint16, isUint32, isInt8, isInt16, isInt32 } = getIntegerType(params);
|
|
86
|
+
switch (true) {
|
|
87
|
+
case isUint8:
|
|
88
|
+
return { code: `${sεr}.view.setUint8(${sεr}.index++, ${comp.vλl})`, type };
|
|
89
|
+
case isUint16:
|
|
90
|
+
return { code: `${sεr}.view.setUint16(${sεr}.index, ${comp.vλl}, 1, ${sεr}.index += 2)`, type };
|
|
91
|
+
case isUint32:
|
|
92
|
+
return { code: `${sεr}.view.setUint32(${sεr}.index, ${comp.vλl}, 1, ${sεr}.index += 4)`, type };
|
|
93
|
+
case isInt8:
|
|
94
|
+
return { code: `${sεr}.view.setInt8(${sεr}.index++, ${comp.vλl})`, type };
|
|
95
|
+
case isInt16:
|
|
96
|
+
return { code: `${sεr}.view.setInt16(${sεr}.index, ${comp.vλl}, 1, ${sεr}.index += 2)`, type };
|
|
97
|
+
case isInt32:
|
|
98
|
+
return { code: `${sεr}.view.setInt32(${sεr}.index, ${comp.vλl}, 1, ${sεr}.index += 4)`, type };
|
|
99
|
+
default:
|
|
100
|
+
return { code: floatCode, type };
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
return { code: floatCode, type: "S" };
|
|
104
|
+
}
|
|
105
|
+
emitFromBinary(comp, rt) {
|
|
106
|
+
const type = "E";
|
|
107
|
+
const dεs = comp.args.dεs;
|
|
108
|
+
const params = this.getParams(rt);
|
|
109
|
+
const isFloat = params.float !== void 0 ? paramVal(params.float) : false;
|
|
110
|
+
const floatCode = `${dεs}.view.getFloat64(${dεs}.index, 1, (${dεs}.index += 8))`;
|
|
111
|
+
if (isFloat)
|
|
112
|
+
return { code: floatCode, type };
|
|
113
|
+
const isInt = params.integer !== void 0 ? paramVal(params.integer) : false;
|
|
114
|
+
if (isInt) {
|
|
115
|
+
const { isUint8, isUint16, isUint32, isInt8, isInt16, isInt32 } = getIntegerType(params);
|
|
116
|
+
switch (true) {
|
|
117
|
+
case isUint8:
|
|
118
|
+
return { code: `${dεs}.view.getUint8(${dεs}.index++)`, type };
|
|
119
|
+
case isUint16:
|
|
120
|
+
return { code: `${dεs}.view.getUint16(${dεs}.index, 1, ${dεs}.index += 2)`, type };
|
|
121
|
+
case isUint32:
|
|
122
|
+
return { code: `${dεs}.view.getUint32(${dεs}.index, 1, ${dεs}.index += 4)`, type };
|
|
123
|
+
case isInt8:
|
|
124
|
+
return { code: `${dεs}.view.getInt8(${dεs}.index++)`, type };
|
|
125
|
+
case isInt16:
|
|
126
|
+
return { code: `${dεs}.view.getInt16(${dεs}.index, 1, ${dεs}.index += 2)`, type };
|
|
127
|
+
case isInt32:
|
|
128
|
+
return { code: `${dεs}.view.getInt32(${dεs}.index, 1, ${dεs}.index += 4)`, type };
|
|
129
|
+
default:
|
|
130
|
+
return { code: floatCode, type };
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
return { code: floatCode, type };
|
|
134
|
+
}
|
|
135
|
+
_mock(opts, rt) {
|
|
136
|
+
const params = this.getParams(rt);
|
|
137
|
+
let min = params.min !== void 0 ? paramVal(params.min) : -99999;
|
|
138
|
+
let max = params.max !== void 0 ? paramVal(params.max) : 99999;
|
|
139
|
+
if (params.gt !== void 0) {
|
|
140
|
+
const epsilon = params.float ? 0.01 : 1;
|
|
141
|
+
const gtVal = paramVal(params.gt);
|
|
142
|
+
min = Math.max(min, gtVal + epsilon);
|
|
143
|
+
}
|
|
144
|
+
if (params.lt !== void 0) {
|
|
145
|
+
const epsilon = params.float ? 0.01 : 1;
|
|
146
|
+
const ltVal = paramVal(params.lt);
|
|
147
|
+
max = Math.min(max, ltVal - epsilon);
|
|
148
|
+
}
|
|
149
|
+
let result;
|
|
150
|
+
if (params.integer) {
|
|
151
|
+
min = Math.ceil(min);
|
|
152
|
+
max = Math.floor(max);
|
|
153
|
+
result = random(min, max);
|
|
154
|
+
} else {
|
|
155
|
+
result = min + Math.random() * (max - min);
|
|
156
|
+
}
|
|
157
|
+
if (params.multipleOf !== void 0) {
|
|
158
|
+
const multipleOfVal = paramVal(params.multipleOf);
|
|
159
|
+
const factor = Math.floor(result / multipleOfVal);
|
|
160
|
+
result = factor * multipleOfVal;
|
|
161
|
+
}
|
|
162
|
+
return result;
|
|
163
|
+
}
|
|
164
|
+
validateParams(rt, params) {
|
|
165
|
+
if (params.integer && params.float) {
|
|
166
|
+
throw new Error(`Cannot specify both integer and float in ${this.printPath(rt)}`);
|
|
167
|
+
}
|
|
168
|
+
const lowerBoundCount = [params.min, params.gt].filter(Boolean).length;
|
|
169
|
+
if (lowerBoundCount > 1) {
|
|
170
|
+
throw new Error(`Cannot specify more than one of min or gt in ${this.printPath(rt)}`);
|
|
171
|
+
}
|
|
172
|
+
const upperBoundCount = [params.max, params.lt].filter(Boolean).length;
|
|
173
|
+
if (upperBoundCount > 1) {
|
|
174
|
+
throw new Error(`Cannot specify more than one of max or lt in ${this.printPath(rt)}`);
|
|
175
|
+
}
|
|
176
|
+
if (params.min && params.max && paramVal(params.min) > paramVal(params.max)) {
|
|
177
|
+
throw new Error(`min cannot be greater than max in ${this.printPath(rt)}`);
|
|
178
|
+
}
|
|
179
|
+
if (params.gt && params.lt && paramVal(params.gt) >= paramVal(params.lt)) {
|
|
180
|
+
throw new Error(`gt cannot be greater than or equal to lt in ${this.printPath(rt)}`);
|
|
181
|
+
}
|
|
182
|
+
if (params.multipleOf !== void 0) {
|
|
183
|
+
const multipleOfVal = paramVal(params.multipleOf);
|
|
184
|
+
if (multipleOfVal <= 0) {
|
|
185
|
+
throw new Error(`multipleOf must be greater than 0 in ${this.printPath(rt)}`);
|
|
186
|
+
}
|
|
187
|
+
if (!Number.isInteger(multipleOfVal)) {
|
|
188
|
+
throw new Error(`multipleOf must be an integer to avoid floating-point precision issues in ${this.printPath(rt)}`);
|
|
189
|
+
}
|
|
190
|
+
if (params.float) {
|
|
191
|
+
throw new Error(`multipleOf cannot be used with float constraint as multipleOf must be an integer in ${this.printPath(rt)}`);
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
function getIntegerType(params) {
|
|
197
|
+
const min = params.min !== void 0 ? paramVal(params.min) : Number.MIN_SAFE_INTEGER;
|
|
198
|
+
const max = params.max !== void 0 ? paramVal(params.max) : Number.MAX_SAFE_INTEGER;
|
|
199
|
+
const isUint8 = min >= 0 && max !== void 0 && max <= 255;
|
|
200
|
+
const isUint16 = min >= 0 && max !== void 0 && max <= 65535;
|
|
201
|
+
const isUint32 = min >= 0 && max !== void 0 && max <= 4294967295;
|
|
202
|
+
const isInt8 = min >= -128 && max !== void 0 && max <= 127;
|
|
203
|
+
const isInt16 = min >= -32768 && max !== void 0 && max <= 32767;
|
|
204
|
+
const isInt32 = min >= -2147483648 && max !== void 0 && max <= 2147483647;
|
|
205
|
+
return { isUint8, isUint16, isUint32, isInt8, isInt16, isInt32 };
|
|
206
|
+
}
|
|
207
|
+
const NUMBER_RUN_TYPE_FORMATTER = registerFormatter(new NumberRunTypeFormat());
|
|
208
|
+
const __ΩFormatNumber = ["P", "BrandName", () => ___TypeFormat, () => NumberRunTypeFormat.id, "FormatNumber", `b!!c"'i$e!!e!"o#%w%y`];
|
|
209
|
+
export {
|
|
210
|
+
NUMBER_RUN_TYPE_FORMATTER,
|
|
211
|
+
NumberRunTypeFormat,
|
|
212
|
+
__ΩFormatNumber
|
|
213
|
+
};
|
|
214
|
+
//# sourceMappingURL=numberFormat.runtype.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"numberFormat.runtype.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { ReflectionKind } from '@deepkit/type';
|
|
2
|
+
import { JitFnCompiler, JitErrorsFnCompiler, BaseRunType, RunTypeOptions, JitCode, BaseRunTypeFormat, TypeFormat } from '@mionjs/run-types';
|
|
3
|
+
import { DateFmt, FormatParams_Date } from '@mionjs/core';
|
|
4
|
+
export declare class DateStringRunTypeFormat extends BaseRunTypeFormat<FormatParams_Date> {
|
|
5
|
+
static id: "date";
|
|
6
|
+
kind: ReflectionKind;
|
|
7
|
+
name: "date";
|
|
8
|
+
emitIsType(comp: JitFnCompiler, rt: BaseRunType): JitCode;
|
|
9
|
+
emitIsTypeErrors(comp: JitErrorsFnCompiler, rt: BaseRunType): JitCode;
|
|
10
|
+
_mock(opts: RunTypeOptions, rt: BaseRunType): string;
|
|
11
|
+
getFormatPureFn(format: DateFmt): import('@mionjs/core').CompiledPureFunction;
|
|
12
|
+
}
|
|
13
|
+
export declare const DATE_RUN_TYPE_FORMATTER: DateStringRunTypeFormat;
|
|
14
|
+
export type DEFAULT_DATE_PARAMS = {
|
|
15
|
+
format: 'ISO';
|
|
16
|
+
};
|
|
17
|
+
export type FormatStringDate<P extends Partial<FormatParams_Date> = DEFAULT_DATE_PARAMS> = TypeFormat<string, typeof DateStringRunTypeFormat.id, P, 'date'>;
|
|
18
|
+
export declare type __ΩDEFAULT_DATE_PARAMS = any[];
|
|
19
|
+
export declare type __ΩFormatStringDate = any[];
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import { ReflectionKind } from "@deepkit/type";
|
|
2
|
+
import { registerFormatter, BaseRunTypeFormat, __ΩTypeFormat as ___TypeFormat } from "@mionjs/run-types";
|
|
3
|
+
import { paramVal } from "../utils.js";
|
|
4
|
+
import { cpf_isDateString_DM, cpf_isDateString_MD, cpf_isDateString_YM, cpf_isDateString_MDY, cpf_isDateString_DMY, cpf_isDateString_YMD } from "../type-formats-pure-fns.js";
|
|
5
|
+
class DateStringRunTypeFormat extends BaseRunTypeFormat {
|
|
6
|
+
static id = "date";
|
|
7
|
+
kind = ReflectionKind.string;
|
|
8
|
+
name = DateStringRunTypeFormat.id;
|
|
9
|
+
emitIsType(comp, rt) {
|
|
10
|
+
const params = this.getParams(rt);
|
|
11
|
+
const formatFn = this.getFormatPureFn(paramVal(params.format));
|
|
12
|
+
return { code: this.compilePureFunctionCall(comp, rt, formatFn).callCode, type: "E" };
|
|
13
|
+
}
|
|
14
|
+
emitIsTypeErrors(comp, rt) {
|
|
15
|
+
const isTypeCodeObj = this.emitIsType(comp, rt);
|
|
16
|
+
const isTypeCode = isTypeCodeObj.code;
|
|
17
|
+
if (!isTypeCode)
|
|
18
|
+
return { code: "", type: "S" };
|
|
19
|
+
const params = this.getParams(rt);
|
|
20
|
+
const errFn = this.getCallJitFormatErr(comp, rt, this);
|
|
21
|
+
return { code: `if (!(${isTypeCode})) ${errFn("format", paramVal(params.format))}`, type: "S" };
|
|
22
|
+
}
|
|
23
|
+
_mock(opts, rt) {
|
|
24
|
+
const params = this.getParams(rt);
|
|
25
|
+
const yy = Math.floor(Math.random() * 1e4);
|
|
26
|
+
const mm = Math.floor(Math.random() * 12) + 1;
|
|
27
|
+
const dd = Math.floor(Math.random() * getMaxDaysInMonth(yy, mm)) + 1;
|
|
28
|
+
const year = String(yy).padStart(4, "0");
|
|
29
|
+
const month = String(mm).padStart(2, "0");
|
|
30
|
+
const day = String(dd).padStart(2, "0");
|
|
31
|
+
switch (paramVal(params.format)) {
|
|
32
|
+
case "ISO":
|
|
33
|
+
case "YYYY-MM-DD":
|
|
34
|
+
return `${year}-${month}-${day}`;
|
|
35
|
+
case "DD-MM-YYYY":
|
|
36
|
+
return `${day}-${month}-${year}`;
|
|
37
|
+
case "MM-DD-YYYY":
|
|
38
|
+
return `${month}-${day}-${year}`;
|
|
39
|
+
case "YYYY-MM":
|
|
40
|
+
return `${year}-${month}`;
|
|
41
|
+
case "MM-DD":
|
|
42
|
+
return `${month}-${day}`;
|
|
43
|
+
case "DD-MM":
|
|
44
|
+
return `${day}-${month}`;
|
|
45
|
+
default:
|
|
46
|
+
throw new Error(`Invalid date format: ${paramVal(params.format)}`);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
getFormatPureFn(format) {
|
|
50
|
+
switch (format) {
|
|
51
|
+
case "ISO":
|
|
52
|
+
case "YYYY-MM-DD":
|
|
53
|
+
return cpf_isDateString_YMD;
|
|
54
|
+
case "DD-MM-YYYY":
|
|
55
|
+
return cpf_isDateString_DMY;
|
|
56
|
+
case "MM-DD-YYYY":
|
|
57
|
+
return cpf_isDateString_MDY;
|
|
58
|
+
case "YYYY-MM":
|
|
59
|
+
return cpf_isDateString_YM;
|
|
60
|
+
case "MM-DD":
|
|
61
|
+
return cpf_isDateString_MD;
|
|
62
|
+
case "DD-MM":
|
|
63
|
+
return cpf_isDateString_DM;
|
|
64
|
+
default:
|
|
65
|
+
throw new Error(`Invalid date format: ${format}`);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
function getMaxDaysInMonth(year, month) {
|
|
70
|
+
if (month === 2) {
|
|
71
|
+
if (year % 4 === 0 && (year % 100 !== 0 || year % 400 === 0))
|
|
72
|
+
return 29;
|
|
73
|
+
return 28;
|
|
74
|
+
}
|
|
75
|
+
if (month === 4 || month === 6 || month === 9 || month === 11)
|
|
76
|
+
return 30;
|
|
77
|
+
return 31;
|
|
78
|
+
}
|
|
79
|
+
const DATE_RUN_TYPE_FORMATTER = registerFormatter(new DateStringRunTypeFormat());
|
|
80
|
+
const __ΩDEFAULT_DATE_PARAMS = ["ISO", "format", "DEFAULT_DATE_PARAMS", 'P.!4"Mw#y'];
|
|
81
|
+
const __ΩFormatStringDate = [() => __ΩDEFAULT_DATE_PARAMS, "P", () => ___TypeFormat, () => DateStringRunTypeFormat.id, "date", "FormatStringDate", 'n!c"&i$e!!.%o#%w&y'];
|
|
82
|
+
export {
|
|
83
|
+
DATE_RUN_TYPE_FORMATTER,
|
|
84
|
+
DateStringRunTypeFormat,
|
|
85
|
+
__ΩDEFAULT_DATE_PARAMS,
|
|
86
|
+
__ΩFormatStringDate
|
|
87
|
+
};
|
|
88
|
+
//# sourceMappingURL=date.runtype.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"date.runtype.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { BaseRunType, JitFnCompiler, JitErrorsFnCompiler, JitCode, TypeFormat, RunTypeOptions, BaseRunTypeFormat } from '@mionjs/run-types';
|
|
2
|
+
import { ReflectionKind } from '@deepkit/type';
|
|
3
|
+
import { DEFAULT_DATE_PARAMS, DateStringRunTypeFormat } from './date.runtype.ts';
|
|
4
|
+
import { FormatParams_DateTime } from '@mionjs/core';
|
|
5
|
+
import { DEFAULT_TIME_FORMAT_PARAMS, TimeStringRunTypeFormat } from './time.runtype.ts';
|
|
6
|
+
export declare class DateTimeRunTypeFormat extends BaseRunTypeFormat<FormatParams_DateTime> {
|
|
7
|
+
static id: "dateTime";
|
|
8
|
+
kind: ReflectionKind;
|
|
9
|
+
name: "dateTime";
|
|
10
|
+
dateFormatter: DateStringRunTypeFormat;
|
|
11
|
+
timeFormatter: TimeStringRunTypeFormat;
|
|
12
|
+
constructor(parentPath?: string[]);
|
|
13
|
+
getIgnoredProps(): string[] | undefined;
|
|
14
|
+
emitIsType(comp: JitFnCompiler, rt: BaseRunType): JitCode;
|
|
15
|
+
emitIsTypeErrors(comp: JitErrorsFnCompiler, rt: BaseRunType): JitCode;
|
|
16
|
+
_mock(opts: RunTypeOptions, rt: BaseRunType): string;
|
|
17
|
+
}
|
|
18
|
+
export declare const DATE_TIME_RUN_TYPE_FORMATTER: DateTimeRunTypeFormat;
|
|
19
|
+
export type DEFAULT_DATE_TIME_PARAMS = {
|
|
20
|
+
date: DEFAULT_DATE_PARAMS;
|
|
21
|
+
time: DEFAULT_TIME_FORMAT_PARAMS;
|
|
22
|
+
splitChar: 'T';
|
|
23
|
+
};
|
|
24
|
+
export type FormatStringDateTime<P extends Partial<FormatParams_DateTime> = {}> = TypeFormat<string, typeof DateTimeRunTypeFormat.id, DEFAULT_DATE_TIME_PARAMS & P, 'dateTime'>;
|
|
25
|
+
export declare type __ΩDEFAULT_DATE_TIME_PARAMS = any[];
|
|
26
|
+
export declare type __ΩFormatStringDateTime = any[];
|