pakdatakit 1.1.0 → 2.1.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.
Files changed (127) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +907 -666
  3. package/dist/address.cjs +17 -0
  4. package/dist/address.d.cts +36 -0
  5. package/dist/address.d.ts +36 -0
  6. package/dist/address.js +4 -0
  7. package/dist/chunk-3COX5FSL.cjs +1650 -0
  8. package/dist/chunk-422X6FEZ.cjs +220 -0
  9. package/dist/chunk-432ZYMYV.js +31 -0
  10. package/dist/chunk-4VVFS6FN.cjs +715 -0
  11. package/dist/chunk-6TSKA2PH.js +38 -0
  12. package/dist/chunk-APXP7OK7.cjs +226 -0
  13. package/dist/chunk-AUATLZA5.cjs +168 -0
  14. package/dist/chunk-BSS4Z7NI.cjs +422 -0
  15. package/dist/chunk-CEPNSHIC.js +33 -0
  16. package/dist/chunk-CQKK3S7A.js +217 -0
  17. package/dist/chunk-CYJJ7KGC.cjs +108 -0
  18. package/dist/chunk-EEVNLTB4.js +32 -0
  19. package/dist/chunk-ENQ7O7VW.js +32 -0
  20. package/dist/chunk-H4DVWUYH.js +231 -0
  21. package/dist/chunk-H6M6L26S.cjs +37 -0
  22. package/dist/chunk-HBOZIITD.js +351 -0
  23. package/dist/chunk-HTCSHHOR.cjs +35 -0
  24. package/dist/chunk-JKE4AMSZ.js +47 -0
  25. package/dist/chunk-K6CZFCX6.js +1642 -0
  26. package/dist/chunk-KEHCTYLO.cjs +52 -0
  27. package/dist/chunk-KQKW2ZEK.cjs +18 -0
  28. package/dist/chunk-L2BDDM2W.js +165 -0
  29. package/dist/chunk-L45UXUWX.js +21 -0
  30. package/dist/chunk-LIYNKIKS.js +709 -0
  31. package/dist/chunk-LVHTH4P7.cjs +41 -0
  32. package/dist/chunk-OVUR47QH.cjs +22 -0
  33. package/dist/chunk-P4CGOJEM.js +16 -0
  34. package/dist/chunk-PHHKIMO2.cjs +35 -0
  35. package/dist/chunk-QQQKISXT.js +223 -0
  36. package/dist/chunk-T3E4B5MJ.js +417 -0
  37. package/dist/chunk-VPBMIYO2.cjs +38 -0
  38. package/dist/chunk-WPKV5JT3.cjs +235 -0
  39. package/dist/chunk-XCXFGTHW.cjs +355 -0
  40. package/dist/chunk-XT4ZNXRC.js +20 -0
  41. package/dist/chunk-Y6BUGLXU.js +95 -0
  42. package/dist/chunk-YLWZGSFY.cjs +99 -0
  43. package/dist/chunk-YS7MOLK2.cjs +23 -0
  44. package/dist/chunk-Z5JEIQVW.js +102 -0
  45. package/dist/cli.js +78 -2654
  46. package/dist/cnic.cjs +15 -0
  47. package/dist/cnic.d.cts +35 -0
  48. package/dist/cnic.d.ts +35 -0
  49. package/dist/cnic.js +2 -0
  50. package/dist/format.cjs +14 -0
  51. package/dist/format.d.cts +27 -0
  52. package/dist/format.d.ts +27 -0
  53. package/dist/format.js +1 -0
  54. package/dist/geo.cjs +27 -0
  55. package/dist/geo.d.cts +43 -0
  56. package/dist/geo.d.ts +43 -0
  57. package/dist/geo.js +2 -0
  58. package/dist/hijri.cjs +26 -0
  59. package/dist/hijri.d.cts +62 -0
  60. package/dist/hijri.d.ts +62 -0
  61. package/dist/hijri.js +1 -0
  62. package/dist/holidays.cjs +19 -0
  63. package/dist/holidays.d.cts +72 -0
  64. package/dist/holidays.d.ts +72 -0
  65. package/dist/holidays.js +2 -0
  66. package/dist/iban.cjs +15 -0
  67. package/dist/iban.d.cts +21 -0
  68. package/dist/iban.d.ts +21 -0
  69. package/dist/iban.js +2 -0
  70. package/dist/index.cjs +211 -0
  71. package/dist/index.d.cts +16 -0
  72. package/dist/index.d.ts +16 -300
  73. package/dist/index.js +18 -2764
  74. package/dist/networks.cjs +12 -0
  75. package/dist/networks.d.cts +20 -0
  76. package/dist/networks.d.ts +20 -0
  77. package/dist/networks.js +3 -0
  78. package/dist/numbers.cjs +24 -0
  79. package/dist/numbers.d.cts +53 -0
  80. package/dist/numbers.d.ts +53 -0
  81. package/dist/numbers.js +3 -0
  82. package/dist/phone.cjs +29 -0
  83. package/dist/phone.d.cts +56 -0
  84. package/dist/phone.d.ts +56 -0
  85. package/dist/phone.js +4 -0
  86. package/dist/postal.cjs +27 -0
  87. package/dist/postal.d.cts +40 -0
  88. package/dist/postal.d.ts +40 -0
  89. package/dist/postal.js +2 -0
  90. package/dist/raast.cjs +20 -0
  91. package/dist/raast.d.cts +119 -0
  92. package/dist/raast.d.ts +119 -0
  93. package/dist/raast.js +3 -0
  94. package/dist/rules-GxgPiVws.d.cts +7 -0
  95. package/dist/rules-GxgPiVws.d.ts +7 -0
  96. package/dist/tax.cjs +20 -0
  97. package/dist/tax.d.cts +47 -0
  98. package/dist/tax.d.ts +47 -0
  99. package/dist/tax.js +3 -0
  100. package/dist/text.cjs +23 -0
  101. package/dist/text.d.cts +34 -0
  102. package/dist/text.d.ts +34 -0
  103. package/dist/text.js +2 -0
  104. package/dist/valibot.cjs +47 -0
  105. package/dist/valibot.d.cts +22 -0
  106. package/dist/valibot.d.ts +22 -0
  107. package/dist/valibot.js +25 -0
  108. package/dist/whatsapp.cjs +12 -0
  109. package/dist/whatsapp.d.cts +12 -0
  110. package/dist/whatsapp.d.ts +12 -0
  111. package/dist/whatsapp.js +3 -0
  112. package/dist/words.cjs +14 -0
  113. package/dist/words.d.cts +49 -0
  114. package/dist/words.d.ts +49 -0
  115. package/dist/words.js +1 -0
  116. package/dist/yup.cjs +32 -0
  117. package/dist/yup.d.cts +22 -0
  118. package/dist/yup.d.ts +22 -0
  119. package/dist/yup.js +30 -0
  120. package/dist/zod.cjs +27 -0
  121. package/dist/zod.d.cts +22 -0
  122. package/dist/zod.d.ts +22 -0
  123. package/dist/zod.js +25 -0
  124. package/package.json +309 -77
  125. package/dist/cli.d.ts +0 -1
  126. package/dist/cli.js.map +0 -1
  127. package/dist/index.js.map +0 -1
@@ -0,0 +1,41 @@
1
+ 'use strict';
2
+
3
+ // src/format.ts
4
+ var LAKH = 1e5;
5
+ var CRORE = 1e7;
6
+ var pkrFormatter = new Intl.NumberFormat("en-PK", {
7
+ maximumFractionDigits: 0
8
+ });
9
+ function assertFinite(amount) {
10
+ if (typeof amount !== "number" || !Number.isFinite(amount)) {
11
+ throw new RangeError(
12
+ `Amount must be a finite number, received ${String(amount)}`
13
+ );
14
+ }
15
+ }
16
+ function roundTo2(value) {
17
+ return Math.round(value * 100) / 100;
18
+ }
19
+ function formatPKR(amount) {
20
+ assertFinite(amount);
21
+ const rounded = Math.round(Math.abs(amount));
22
+ const sign = amount < 0 && rounded !== 0 ? "-" : "";
23
+ return `${sign}Rs. ${pkrFormatter.format(rounded)}`;
24
+ }
25
+ function formatLakh(amount) {
26
+ assertFinite(amount);
27
+ const sign = amount < 0 ? "-" : "";
28
+ const absolute = Math.abs(amount);
29
+ const crores = roundTo2(absolute / CRORE);
30
+ if (crores >= 1) {
31
+ return `${sign}${crores} Crore`;
32
+ }
33
+ const lakhs = roundTo2(absolute / LAKH);
34
+ if (lakhs >= 1) {
35
+ return `${sign}${lakhs} Lakh`;
36
+ }
37
+ return formatPKR(amount);
38
+ }
39
+
40
+ exports.formatLakh = formatLakh;
41
+ exports.formatPKR = formatPKR;
@@ -0,0 +1,22 @@
1
+ 'use strict';
2
+
3
+ var chunkBSS4Z7NI_cjs = require('./chunk-BSS4Z7NI.cjs');
4
+ var chunkPHHKIMO2_cjs = require('./chunk-PHHKIMO2.cjs');
5
+ var chunkH6M6L26S_cjs = require('./chunk-H6M6L26S.cjs');
6
+ var chunkHTCSHHOR_cjs = require('./chunk-HTCSHHOR.cjs');
7
+ var chunk422X6FEZ_cjs = require('./chunk-422X6FEZ.cjs');
8
+
9
+ // src/adapters/rules.ts
10
+ var RULES = {
11
+ cnic: { test: chunkHTCSHHOR_cjs.validateCNIC, message: "Invalid CNIC number" },
12
+ phone: { test: chunkPHHKIMO2_cjs.validatePhone, message: "Invalid Pakistani mobile number" },
13
+ iban: { test: chunk422X6FEZ_cjs.validateIBAN, message: "Invalid Pakistani IBAN" },
14
+ ntn: { test: chunkH6M6L26S_cjs.validateNTN, message: "Invalid NTN" },
15
+ strn: { test: chunkH6M6L26S_cjs.validateSTRN, message: "Invalid STRN" },
16
+ landline: {
17
+ test: chunkBSS4Z7NI_cjs.validateLandline,
18
+ message: "Invalid Pakistani landline number"
19
+ }
20
+ };
21
+
22
+ exports.RULES = RULES;
@@ -0,0 +1,16 @@
1
+ import { normalizePhoneDigits } from './chunk-Y6BUGLXU.js';
2
+
3
+ // src/whatsapp.ts
4
+ function createWhatsAppLink(phone, message) {
5
+ const digits = normalizePhoneDigits(phone);
6
+ if (digits === null) {
7
+ return null;
8
+ }
9
+ const baseUrl = `https://wa.me/${digits}`;
10
+ if (message === void 0 || message.length === 0) {
11
+ return baseUrl;
12
+ }
13
+ return `${baseUrl}?text=${encodeURIComponent(message)}`;
14
+ }
15
+
16
+ export { createWhatsAppLink };
@@ -0,0 +1,35 @@
1
+ 'use strict';
2
+
3
+ var chunkYS7MOLK2_cjs = require('./chunk-YS7MOLK2.cjs');
4
+ var chunkYLWZGSFY_cjs = require('./chunk-YLWZGSFY.cjs');
5
+
6
+ // src/phone.ts
7
+ function validatePhone(phone) {
8
+ return chunkYLWZGSFY_cjs.normalizePhoneDigits(phone) !== null;
9
+ }
10
+ function formatPhone(phone) {
11
+ const digits = chunkYLWZGSFY_cjs.normalizePhoneDigits(phone);
12
+ if (digits === null) {
13
+ return null;
14
+ }
15
+ return `+${digits}`;
16
+ }
17
+ function analyzePhone(phone) {
18
+ const formatted = formatPhone(phone);
19
+ if (formatted === null) {
20
+ return {
21
+ valid: false,
22
+ formatted: null,
23
+ network: "Unknown"
24
+ };
25
+ }
26
+ return {
27
+ valid: true,
28
+ formatted,
29
+ network: chunkYS7MOLK2_cjs.getNetwork(phone)
30
+ };
31
+ }
32
+
33
+ exports.analyzePhone = analyzePhone;
34
+ exports.formatPhone = formatPhone;
35
+ exports.validatePhone = validatePhone;
@@ -0,0 +1,223 @@
1
+ // src/words.ts
2
+ var SCALES = [
3
+ { value: 1e11, en: "kharab", ur: "\u06A9\u06BE\u0631\u0628" },
4
+ { value: 1e9, en: "arab", ur: "\u0627\u0631\u0628" },
5
+ { value: 1e7, en: "crore", ur: "\u06A9\u0631\u0648\u0691" },
6
+ { value: 1e5, en: "lakh", ur: "\u0644\u0627\u06A9\u06BE" },
7
+ { value: 1e3, en: "thousand", ur: "\u06C1\u0632\u0627\u0631" },
8
+ { value: 100, en: "hundred", ur: "\u0633\u0648" }
9
+ ];
10
+ var EN_ONES = [
11
+ "zero",
12
+ "one",
13
+ "two",
14
+ "three",
15
+ "four",
16
+ "five",
17
+ "six",
18
+ "seven",
19
+ "eight",
20
+ "nine",
21
+ "ten",
22
+ "eleven",
23
+ "twelve",
24
+ "thirteen",
25
+ "fourteen",
26
+ "fifteen",
27
+ "sixteen",
28
+ "seventeen",
29
+ "eighteen",
30
+ "nineteen"
31
+ ];
32
+ var EN_TENS = [
33
+ "",
34
+ "",
35
+ "twenty",
36
+ "thirty",
37
+ "forty",
38
+ "fifty",
39
+ "sixty",
40
+ "seventy",
41
+ "eighty",
42
+ "ninety"
43
+ ];
44
+ var UR_0_TO_99 = [
45
+ "\u0635\u0641\u0631",
46
+ "\u0627\u06CC\u06A9",
47
+ "\u062F\u0648",
48
+ "\u062A\u06CC\u0646",
49
+ "\u0686\u0627\u0631",
50
+ "\u067E\u0627\u0646\u0686",
51
+ "\u0686\u06BE",
52
+ "\u0633\u0627\u062A",
53
+ "\u0622\u0679\u06BE",
54
+ "\u0646\u0648",
55
+ "\u062F\u0633",
56
+ "\u06AF\u06CC\u0627\u0631\u06C1",
57
+ "\u0628\u0627\u0631\u06C1",
58
+ "\u062A\u06CC\u0631\u06C1",
59
+ "\u0686\u0648\u062F\u06C1",
60
+ "\u067E\u0646\u062F\u0631\u06C1",
61
+ "\u0633\u0648\u0644\u06C1",
62
+ "\u0633\u062A\u0631\u06C1",
63
+ "\u0627\u0679\u06BE\u0627\u0631\u06C1",
64
+ "\u0627\u0646\u06CC\u0633",
65
+ "\u0628\u06CC\u0633",
66
+ "\u0627\u06A9\u06CC\u0633",
67
+ "\u0628\u0627\u0626\u06CC\u0633",
68
+ "\u062A\u0626\u06CC\u0633",
69
+ "\u0686\u0648\u0628\u06CC\u0633",
70
+ "\u067E\u0686\u06CC\u0633",
71
+ "\u0686\u06BE\u0628\u06CC\u0633",
72
+ "\u0633\u062A\u0627\u0626\u06CC\u0633",
73
+ "\u0627\u0679\u06BE\u0627\u0626\u06CC\u0633",
74
+ "\u0627\u0646\u062A\u06CC\u0633",
75
+ "\u062A\u06CC\u0633",
76
+ "\u0627\u06A9\u062A\u06CC\u0633",
77
+ "\u0628\u062A\u06CC\u0633",
78
+ "\u062A\u06CC\u0646\u062A\u06CC\u0633",
79
+ "\u0686\u0648\u0646\u062A\u06CC\u0633",
80
+ "\u067E\u06CC\u0646\u062A\u06CC\u0633",
81
+ "\u0686\u06BE\u062A\u06CC\u0633",
82
+ "\u0633\u06CC\u0646\u062A\u06CC\u0633",
83
+ "\u0627\u0691\u062A\u06CC\u0633",
84
+ "\u0627\u0646\u062A\u0627\u0644\u06CC\u0633",
85
+ "\u0686\u0627\u0644\u06CC\u0633",
86
+ "\u0627\u06A9\u062A\u0627\u0644\u06CC\u0633",
87
+ "\u0628\u06CC\u0627\u0644\u06CC\u0633",
88
+ "\u062A\u06CC\u0646\u062A\u0627\u0644\u06CC\u0633",
89
+ "\u0686\u0648\u0627\u0644\u06CC\u0633",
90
+ "\u067E\u06CC\u0646\u062A\u0627\u0644\u06CC\u0633",
91
+ "\u0686\u06BE\u06CC\u0627\u0644\u06CC\u0633",
92
+ "\u0633\u06CC\u0646\u062A\u0627\u0644\u06CC\u0633",
93
+ "\u0627\u0691\u062A\u0627\u0644\u06CC\u0633",
94
+ "\u0627\u0646\u0686\u0627\u0633",
95
+ "\u067E\u0686\u0627\u0633",
96
+ "\u0627\u06A9\u0627\u0648\u0646",
97
+ "\u0628\u0627\u0648\u0646",
98
+ "\u062A\u0631\u067E\u0646",
99
+ "\u0686\u0648\u0646",
100
+ "\u067E\u0686\u067E\u0646",
101
+ "\u0686\u06BE\u067E\u0646",
102
+ "\u0633\u062A\u0627\u0648\u0646",
103
+ "\u0627\u0679\u06BE\u0627\u0648\u0646",
104
+ "\u0627\u0646\u0633\u0679\u06BE",
105
+ "\u0633\u0627\u0679\u06BE",
106
+ "\u0627\u06A9\u0633\u0679\u06BE",
107
+ "\u0628\u0627\u0633\u0679\u06BE",
108
+ "\u062A\u0631\u0633\u0679\u06BE",
109
+ "\u0686\u0648\u0646\u0633\u0679\u06BE",
110
+ "\u067E\u06CC\u0646\u0633\u0679\u06BE",
111
+ "\u0686\u06BE\u06CC\u0627\u0633\u0679\u06BE",
112
+ "\u0633\u0691\u0633\u0679\u06BE",
113
+ "\u0627\u0691\u0633\u0679\u06BE",
114
+ "\u0627\u0646\u06C1\u062A\u0631",
115
+ "\u0633\u062A\u0631",
116
+ "\u0627\u06A9\u06C1\u062A\u0631",
117
+ "\u0628\u06C1\u062A\u0631",
118
+ "\u062A\u06C1\u062A\u0631",
119
+ "\u0686\u0648\u06C1\u062A\u0631",
120
+ "\u067E\u0686\u06BE\u062A\u0631",
121
+ "\u0686\u06BE\u06C1\u062A\u0631",
122
+ "\u0633\u062A\u062A\u0631",
123
+ "\u0627\u0679\u06BE\u06C1\u062A\u0631",
124
+ "\u0627\u0646\u0627\u0633\u06CC",
125
+ "\u0627\u0633\u06CC",
126
+ "\u0627\u06A9\u06CC\u0627\u0633\u06CC",
127
+ "\u0628\u06CC\u0627\u0633\u06CC",
128
+ "\u062A\u0631\u0627\u0633\u06CC",
129
+ "\u0686\u0648\u0631\u0627\u0633\u06CC",
130
+ "\u067E\u0686\u0627\u0633\u06CC",
131
+ "\u0686\u06BE\u06CC\u0627\u0633\u06CC",
132
+ "\u0633\u062A\u0627\u0633\u06CC",
133
+ "\u0627\u0679\u06BE\u0627\u0633\u06CC",
134
+ "\u0646\u0648\u0627\u0633\u06CC",
135
+ "\u0646\u0648\u06D2",
136
+ "\u0627\u06A9\u0627\u0646\u0648\u06D2",
137
+ "\u0628\u0627\u0646\u0648\u06D2",
138
+ "\u062A\u0631\u0627\u0646\u0648\u06D2",
139
+ "\u0686\u0648\u0631\u0627\u0646\u0648\u06D2",
140
+ "\u067E\u0686\u0627\u0646\u0648\u06D2",
141
+ "\u0686\u06BE\u06CC\u0627\u0646\u0648\u06D2",
142
+ "\u0633\u062A\u0627\u0646\u0648\u06D2",
143
+ "\u0627\u0679\u06BE\u0627\u0646\u0648\u06D2",
144
+ "\u0646\u0646\u0627\u0646\u0648\u06D2"
145
+ ];
146
+ function underHundred(n, language) {
147
+ if (language === "ur") {
148
+ return UR_0_TO_99[n];
149
+ }
150
+ if (n < 20) {
151
+ return EN_ONES[n];
152
+ }
153
+ const tens = EN_TENS[Math.floor(n / 10)];
154
+ return n % 10 === 0 ? tens : `${tens}-${EN_ONES[n % 10]}`;
155
+ }
156
+ function convert(n, language) {
157
+ for (const scale of SCALES) {
158
+ if (n >= scale.value) {
159
+ const count = Math.floor(n / scale.value);
160
+ const rest = n % scale.value;
161
+ return [
162
+ ...convert(count, language),
163
+ scale[language],
164
+ ...rest > 0 ? convert(rest, language) : []
165
+ ];
166
+ }
167
+ }
168
+ return [underHundred(n, language)];
169
+ }
170
+ function numberToWords(n, options = {}) {
171
+ const language = options.language ?? "en";
172
+ if (!Number.isSafeInteger(n)) {
173
+ throw new RangeError(`Expected a safe integer, received ${String(n)}`);
174
+ }
175
+ if (n === 0) {
176
+ return underHundred(0, language);
177
+ }
178
+ const words = convert(Math.abs(n), language).join(" ");
179
+ if (n > 0) {
180
+ return words;
181
+ }
182
+ return language === "ur" ? `\u0645\u0646\u0641\u06CC ${words}` : `minus ${words}`;
183
+ }
184
+ function titleCase(text) {
185
+ return text.replace(
186
+ /(^|[\s-])([a-z])/g,
187
+ (_, sep, ch) => `${sep}${ch.toUpperCase()}`
188
+ );
189
+ }
190
+ function amountInWords(amount, options = {}) {
191
+ const language = options.language ?? "en";
192
+ if (!Number.isFinite(amount) || amount < 0) {
193
+ throw new RangeError(
194
+ `Amount must be a finite number of zero or more, received ${String(amount)}`
195
+ );
196
+ }
197
+ const totalPaisa = Math.round(amount * 100);
198
+ const rupees = Math.floor(totalPaisa / 100);
199
+ const paisa = totalPaisa % 100;
200
+ const rupeeWords = numberToWords(rupees, { language });
201
+ const paisaWords = paisa > 0 ? numberToWords(paisa, { language }) : null;
202
+ if (language === "ur") {
203
+ let text2 = `${rupeeWords} \u0631\u0648\u067E\u06D2`;
204
+ if (paisaWords !== null) {
205
+ text2 += ` \u0627\u0648\u0631 ${paisaWords} \u067E\u06CC\u0633\u06D2`;
206
+ }
207
+ return options.cheque ? `${text2} \u0635\u0631\u0641` : text2;
208
+ }
209
+ if (options.cheque) {
210
+ const paisaPart = paisaWords !== null ? ` and ${paisaWords} paisa` : "";
211
+ return titleCase(`rupees ${rupeeWords}${paisaPart} only`).replace(
212
+ " And ",
213
+ " and "
214
+ );
215
+ }
216
+ let text = `${rupeeWords} ${rupees === 1 ? "rupee" : "rupees"}`;
217
+ if (paisaWords !== null) {
218
+ text += ` and ${paisaWords} paisa`;
219
+ }
220
+ return text;
221
+ }
222
+
223
+ export { amountInWords, numberToWords };