pakdatakit 1.0.2 → 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.
- package/LICENSE +21 -21
- package/README.md +907 -597
- package/dist/address.cjs +17 -0
- package/dist/address.d.cts +36 -0
- package/dist/address.d.ts +36 -0
- package/dist/address.js +4 -0
- package/dist/chunk-3COX5FSL.cjs +1650 -0
- package/dist/chunk-422X6FEZ.cjs +220 -0
- package/dist/chunk-432ZYMYV.js +31 -0
- package/dist/chunk-4VVFS6FN.cjs +715 -0
- package/dist/chunk-6TSKA2PH.js +38 -0
- package/dist/chunk-APXP7OK7.cjs +226 -0
- package/dist/chunk-AUATLZA5.cjs +168 -0
- package/dist/chunk-BSS4Z7NI.cjs +422 -0
- package/dist/chunk-CEPNSHIC.js +33 -0
- package/dist/chunk-CQKK3S7A.js +217 -0
- package/dist/chunk-CYJJ7KGC.cjs +108 -0
- package/dist/chunk-EEVNLTB4.js +32 -0
- package/dist/chunk-ENQ7O7VW.js +32 -0
- package/dist/chunk-H4DVWUYH.js +231 -0
- package/dist/chunk-H6M6L26S.cjs +37 -0
- package/dist/chunk-HBOZIITD.js +351 -0
- package/dist/chunk-HTCSHHOR.cjs +35 -0
- package/dist/chunk-JKE4AMSZ.js +47 -0
- package/dist/chunk-K6CZFCX6.js +1642 -0
- package/dist/chunk-KEHCTYLO.cjs +52 -0
- package/dist/chunk-KQKW2ZEK.cjs +18 -0
- package/dist/chunk-L2BDDM2W.js +165 -0
- package/dist/chunk-L45UXUWX.js +21 -0
- package/dist/chunk-LIYNKIKS.js +709 -0
- package/dist/chunk-LVHTH4P7.cjs +41 -0
- package/dist/chunk-OVUR47QH.cjs +22 -0
- package/dist/chunk-P4CGOJEM.js +16 -0
- package/dist/chunk-PHHKIMO2.cjs +35 -0
- package/dist/chunk-QQQKISXT.js +223 -0
- package/dist/chunk-T3E4B5MJ.js +417 -0
- package/dist/chunk-VPBMIYO2.cjs +38 -0
- package/dist/chunk-WPKV5JT3.cjs +235 -0
- package/dist/chunk-XCXFGTHW.cjs +355 -0
- package/dist/chunk-XT4ZNXRC.js +20 -0
- package/dist/chunk-Y6BUGLXU.js +95 -0
- package/dist/chunk-YLWZGSFY.cjs +99 -0
- package/dist/chunk-YS7MOLK2.cjs +23 -0
- package/dist/chunk-Z5JEIQVW.js +102 -0
- package/dist/cli.js +129 -0
- package/dist/cnic.cjs +15 -0
- package/dist/cnic.d.cts +35 -0
- package/dist/cnic.d.ts +35 -0
- package/dist/cnic.js +2 -0
- package/dist/format.cjs +14 -0
- package/dist/format.d.cts +27 -0
- package/dist/format.d.ts +27 -0
- package/dist/format.js +1 -0
- package/dist/geo.cjs +27 -0
- package/dist/geo.d.cts +43 -0
- package/dist/geo.d.ts +43 -0
- package/dist/geo.js +2 -0
- package/dist/hijri.cjs +26 -0
- package/dist/hijri.d.cts +62 -0
- package/dist/hijri.d.ts +62 -0
- package/dist/hijri.js +1 -0
- package/dist/holidays.cjs +19 -0
- package/dist/holidays.d.cts +72 -0
- package/dist/holidays.d.ts +72 -0
- package/dist/holidays.js +2 -0
- package/dist/iban.cjs +15 -0
- package/dist/iban.d.cts +21 -0
- package/dist/iban.d.ts +21 -0
- package/dist/iban.js +2 -0
- package/dist/index.cjs +211 -0
- package/dist/index.d.cts +16 -0
- package/dist/index.d.ts +16 -190
- package/dist/index.js +18 -2465
- package/dist/networks.cjs +12 -0
- package/dist/networks.d.cts +20 -0
- package/dist/networks.d.ts +20 -0
- package/dist/networks.js +3 -0
- package/dist/numbers.cjs +24 -0
- package/dist/numbers.d.cts +53 -0
- package/dist/numbers.d.ts +53 -0
- package/dist/numbers.js +3 -0
- package/dist/phone.cjs +29 -0
- package/dist/phone.d.cts +56 -0
- package/dist/phone.d.ts +56 -0
- package/dist/phone.js +4 -0
- package/dist/postal.cjs +27 -0
- package/dist/postal.d.cts +40 -0
- package/dist/postal.d.ts +40 -0
- package/dist/postal.js +2 -0
- package/dist/raast.cjs +20 -0
- package/dist/raast.d.cts +119 -0
- package/dist/raast.d.ts +119 -0
- package/dist/raast.js +3 -0
- package/dist/rules-GxgPiVws.d.cts +7 -0
- package/dist/rules-GxgPiVws.d.ts +7 -0
- package/dist/tax.cjs +20 -0
- package/dist/tax.d.cts +47 -0
- package/dist/tax.d.ts +47 -0
- package/dist/tax.js +3 -0
- package/dist/text.cjs +23 -0
- package/dist/text.d.cts +34 -0
- package/dist/text.d.ts +34 -0
- package/dist/text.js +2 -0
- package/dist/valibot.cjs +47 -0
- package/dist/valibot.d.cts +22 -0
- package/dist/valibot.d.ts +22 -0
- package/dist/valibot.js +25 -0
- package/dist/whatsapp.cjs +12 -0
- package/dist/whatsapp.d.cts +12 -0
- package/dist/whatsapp.d.ts +12 -0
- package/dist/whatsapp.js +3 -0
- package/dist/words.cjs +14 -0
- package/dist/words.d.cts +49 -0
- package/dist/words.d.ts +49 -0
- package/dist/words.js +1 -0
- package/dist/yup.cjs +32 -0
- package/dist/yup.d.cts +22 -0
- package/dist/yup.d.ts +22 -0
- package/dist/yup.js +30 -0
- package/dist/zod.cjs +27 -0
- package/dist/zod.d.cts +22 -0
- package/dist/zod.d.ts +22 -0
- package/dist/zod.js +25 -0
- package/package.json +309 -69
- package/dist/index.js.map +0 -1
package/dist/cli.js
ADDED
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { normalizeRomanUrdu, formatHijri, toHijri, formatPKR, formatLakh, parseAddress, getCityByPostalCode, getPostalCode, getProvince, getBankFromIBAN, validateIBAN, analyzePhone, validatePhone, validateCNIC } from 'pakdatakit';
|
|
3
|
+
|
|
4
|
+
// package.json
|
|
5
|
+
var version = "2.1.0";
|
|
6
|
+
var EXIT_OK = 0;
|
|
7
|
+
var EXIT_NEGATIVE = 1;
|
|
8
|
+
var EXIT_USAGE = 2;
|
|
9
|
+
var [, , command, ...args] = process.argv;
|
|
10
|
+
var input = args.join(" ").trim();
|
|
11
|
+
function printUsage() {
|
|
12
|
+
console.log(`pakdatakit ${version} \u2014 Pakistani developer utilities
|
|
13
|
+
|
|
14
|
+
Usage:
|
|
15
|
+
pakdatakit <command> [input]
|
|
16
|
+
|
|
17
|
+
Commands:
|
|
18
|
+
validate-cnic <cnic> Validate a CNIC number
|
|
19
|
+
validate-phone <phone> Validate a mobile number
|
|
20
|
+
analyze-phone <phone> Analyze phone (format + network)
|
|
21
|
+
validate-iban <iban> Validate a Pakistani IBAN
|
|
22
|
+
bank-from-iban <iban> Get bank name from IBAN
|
|
23
|
+
province <city> Get province for a city
|
|
24
|
+
postal-code <city> Get postal code for a city
|
|
25
|
+
city-from-postal <code> Get city from postal code
|
|
26
|
+
parse-address <address> Parse a Pakistani address
|
|
27
|
+
format-pkr <amount> Format PKR amount
|
|
28
|
+
format-lakh <amount> Format in Lakh/Crore
|
|
29
|
+
hijri [yyyy-mm-dd] Convert date to Hijri (default: today)
|
|
30
|
+
normalize-urdu <text> Normalize Roman Urdu text
|
|
31
|
+
help, --help Show this help message
|
|
32
|
+
--version Show the version
|
|
33
|
+
|
|
34
|
+
Exit status is 0 when the input is valid or found, 1 when it is invalid or
|
|
35
|
+
not found, and 2 for usage errors.
|
|
36
|
+
`);
|
|
37
|
+
}
|
|
38
|
+
function usageError(message) {
|
|
39
|
+
console.error(`Error: ${message}`);
|
|
40
|
+
return EXIT_USAGE;
|
|
41
|
+
}
|
|
42
|
+
function printBoolean(result) {
|
|
43
|
+
console.log(result);
|
|
44
|
+
return result ? EXIT_OK : EXIT_NEGATIVE;
|
|
45
|
+
}
|
|
46
|
+
function printLookup(result) {
|
|
47
|
+
console.log(result ?? "Not found");
|
|
48
|
+
return result === null ? EXIT_NEGATIVE : EXIT_OK;
|
|
49
|
+
}
|
|
50
|
+
function parseAmount(value) {
|
|
51
|
+
const amount = Number(value.replace(/,/g, ""));
|
|
52
|
+
return value.length > 0 && Number.isFinite(amount) ? amount : null;
|
|
53
|
+
}
|
|
54
|
+
function parseLocalDate(value) {
|
|
55
|
+
const match = /^(\d{4})-(\d{2})-(\d{2})$/.exec(value);
|
|
56
|
+
if (!match) {
|
|
57
|
+
return null;
|
|
58
|
+
}
|
|
59
|
+
const [year, month, day] = match.slice(1).map(Number);
|
|
60
|
+
const date = new Date(year, month - 1, day);
|
|
61
|
+
return date.getMonth() === month - 1 ? date : null;
|
|
62
|
+
}
|
|
63
|
+
function run() {
|
|
64
|
+
if (!command || command === "help" || command === "--help" || command === "-h") {
|
|
65
|
+
printUsage();
|
|
66
|
+
return EXIT_OK;
|
|
67
|
+
}
|
|
68
|
+
if (command === "--version" || command === "-v") {
|
|
69
|
+
console.log(version);
|
|
70
|
+
return EXIT_OK;
|
|
71
|
+
}
|
|
72
|
+
if (input.length === 0 && command !== "hijri") {
|
|
73
|
+
return usageError(`missing input for "${command}"`);
|
|
74
|
+
}
|
|
75
|
+
switch (command) {
|
|
76
|
+
case "validate-cnic":
|
|
77
|
+
return printBoolean(validateCNIC(input));
|
|
78
|
+
case "validate-phone":
|
|
79
|
+
return printBoolean(validatePhone(input));
|
|
80
|
+
case "analyze-phone": {
|
|
81
|
+
const analysis = analyzePhone(input);
|
|
82
|
+
console.log(JSON.stringify(analysis, null, 2));
|
|
83
|
+
return analysis.valid ? EXIT_OK : EXIT_NEGATIVE;
|
|
84
|
+
}
|
|
85
|
+
case "validate-iban":
|
|
86
|
+
return printBoolean(validateIBAN(input));
|
|
87
|
+
case "bank-from-iban":
|
|
88
|
+
return printLookup(getBankFromIBAN(input));
|
|
89
|
+
case "province":
|
|
90
|
+
return printLookup(getProvince(input));
|
|
91
|
+
case "postal-code":
|
|
92
|
+
return printLookup(getPostalCode(input));
|
|
93
|
+
case "city-from-postal":
|
|
94
|
+
return printLookup(getCityByPostalCode(input));
|
|
95
|
+
case "parse-address":
|
|
96
|
+
console.log(JSON.stringify(parseAddress(input), null, 2));
|
|
97
|
+
return EXIT_OK;
|
|
98
|
+
case "format-pkr":
|
|
99
|
+
case "format-lakh": {
|
|
100
|
+
const amount = parseAmount(input);
|
|
101
|
+
if (amount === null) {
|
|
102
|
+
return usageError(`"${input}" is not a number`);
|
|
103
|
+
}
|
|
104
|
+
console.log(
|
|
105
|
+
command === "format-pkr" ? formatPKR(amount) : formatLakh(amount)
|
|
106
|
+
);
|
|
107
|
+
return EXIT_OK;
|
|
108
|
+
}
|
|
109
|
+
case "hijri": {
|
|
110
|
+
const date = input.length > 0 ? parseLocalDate(input) : /* @__PURE__ */ new Date();
|
|
111
|
+
if (date === null) {
|
|
112
|
+
return usageError(
|
|
113
|
+
`"${input}" is not a valid date (expected yyyy-mm-dd)`
|
|
114
|
+
);
|
|
115
|
+
}
|
|
116
|
+
console.log(formatHijri(date));
|
|
117
|
+
console.log(JSON.stringify(toHijri(date), null, 2));
|
|
118
|
+
return EXIT_OK;
|
|
119
|
+
}
|
|
120
|
+
case "normalize-urdu":
|
|
121
|
+
console.log(normalizeRomanUrdu(input));
|
|
122
|
+
return EXIT_OK;
|
|
123
|
+
default:
|
|
124
|
+
console.error(`Unknown command: ${command}`);
|
|
125
|
+
printUsage();
|
|
126
|
+
return EXIT_USAGE;
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
process.exitCode = run();
|
package/dist/cnic.cjs
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var chunkHTCSHHOR_cjs = require('./chunk-HTCSHHOR.cjs');
|
|
4
|
+
require('./chunk-VPBMIYO2.cjs');
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
Object.defineProperty(exports, "getCNICInfo", {
|
|
9
|
+
enumerable: true,
|
|
10
|
+
get: function () { return chunkHTCSHHOR_cjs.getCNICInfo; }
|
|
11
|
+
});
|
|
12
|
+
Object.defineProperty(exports, "validateCNIC", {
|
|
13
|
+
enumerable: true,
|
|
14
|
+
get: function () { return chunkHTCSHHOR_cjs.validateCNIC; }
|
|
15
|
+
});
|
package/dist/cnic.d.cts
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Validates a Pakistani CNIC number.
|
|
3
|
+
*
|
|
4
|
+
* Accepts `3520212345671`, `35202-1234567-1`, `35202 1234567 1` and Urdu digits.
|
|
5
|
+
* Separators must sit between the 5-7-1 digit groups and be used consistently.
|
|
6
|
+
*
|
|
7
|
+
* NADRA does not publish a check-digit algorithm, so this validates structure only.
|
|
8
|
+
*
|
|
9
|
+
* @param cnic - The CNIC string to validate
|
|
10
|
+
* @returns `true` if the CNIC is valid, otherwise `false`
|
|
11
|
+
*/
|
|
12
|
+
declare function validateCNIC(cnic: string): boolean;
|
|
13
|
+
/** Information encoded in a CNIC number. */
|
|
14
|
+
interface CNICInfo {
|
|
15
|
+
/** The CNIC as 13 digits without separators. */
|
|
16
|
+
digits: string;
|
|
17
|
+
/** The CNIC in `#####-#######-#` form. */
|
|
18
|
+
formatted: string;
|
|
19
|
+
/**
|
|
20
|
+
* Province where the CNIC was first registered (from the first digit).
|
|
21
|
+
* This is not necessarily where the holder lives now.
|
|
22
|
+
*/
|
|
23
|
+
province: string;
|
|
24
|
+
/** Gender encoded in the last digit: odd for male, even for female. */
|
|
25
|
+
gender: 'male' | 'female';
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Reads the province of registration and gender encoded in a CNIC.
|
|
29
|
+
*
|
|
30
|
+
* @param cnic - CNIC in any format accepted by {@link validateCNIC}
|
|
31
|
+
* @returns Decoded information, or `null` if the CNIC is invalid
|
|
32
|
+
*/
|
|
33
|
+
declare function getCNICInfo(cnic: string): CNICInfo | null;
|
|
34
|
+
|
|
35
|
+
export { type CNICInfo, getCNICInfo, validateCNIC };
|
package/dist/cnic.d.ts
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Validates a Pakistani CNIC number.
|
|
3
|
+
*
|
|
4
|
+
* Accepts `3520212345671`, `35202-1234567-1`, `35202 1234567 1` and Urdu digits.
|
|
5
|
+
* Separators must sit between the 5-7-1 digit groups and be used consistently.
|
|
6
|
+
*
|
|
7
|
+
* NADRA does not publish a check-digit algorithm, so this validates structure only.
|
|
8
|
+
*
|
|
9
|
+
* @param cnic - The CNIC string to validate
|
|
10
|
+
* @returns `true` if the CNIC is valid, otherwise `false`
|
|
11
|
+
*/
|
|
12
|
+
declare function validateCNIC(cnic: string): boolean;
|
|
13
|
+
/** Information encoded in a CNIC number. */
|
|
14
|
+
interface CNICInfo {
|
|
15
|
+
/** The CNIC as 13 digits without separators. */
|
|
16
|
+
digits: string;
|
|
17
|
+
/** The CNIC in `#####-#######-#` form. */
|
|
18
|
+
formatted: string;
|
|
19
|
+
/**
|
|
20
|
+
* Province where the CNIC was first registered (from the first digit).
|
|
21
|
+
* This is not necessarily where the holder lives now.
|
|
22
|
+
*/
|
|
23
|
+
province: string;
|
|
24
|
+
/** Gender encoded in the last digit: odd for male, even for female. */
|
|
25
|
+
gender: 'male' | 'female';
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Reads the province of registration and gender encoded in a CNIC.
|
|
29
|
+
*
|
|
30
|
+
* @param cnic - CNIC in any format accepted by {@link validateCNIC}
|
|
31
|
+
* @returns Decoded information, or `null` if the CNIC is invalid
|
|
32
|
+
*/
|
|
33
|
+
declare function getCNICInfo(cnic: string): CNICInfo | null;
|
|
34
|
+
|
|
35
|
+
export { type CNICInfo, getCNICInfo, validateCNIC };
|
package/dist/cnic.js
ADDED
package/dist/format.cjs
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var chunkLVHTH4P7_cjs = require('./chunk-LVHTH4P7.cjs');
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
Object.defineProperty(exports, "formatLakh", {
|
|
8
|
+
enumerable: true,
|
|
9
|
+
get: function () { return chunkLVHTH4P7_cjs.formatLakh; }
|
|
10
|
+
});
|
|
11
|
+
Object.defineProperty(exports, "formatPKR", {
|
|
12
|
+
enumerable: true,
|
|
13
|
+
get: function () { return chunkLVHTH4P7_cjs.formatPKR; }
|
|
14
|
+
});
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Formats a numeric amount as Pakistani Rupees with comma separators,
|
|
3
|
+
* rounded to whole rupees. Negative amounts are prefixed with `-`.
|
|
4
|
+
*
|
|
5
|
+
* @param amount - The amount in PKR
|
|
6
|
+
* @returns Formatted string (e.g. `"Rs. 150,000"`, `"-Rs. 500"`)
|
|
7
|
+
* @throws {RangeError} If `amount` is `NaN` or infinite
|
|
8
|
+
*/
|
|
9
|
+
declare function formatPKR(amount: number): string;
|
|
10
|
+
/**
|
|
11
|
+
* Formats a numeric amount using Pakistani lakh/crore conventions.
|
|
12
|
+
*
|
|
13
|
+
* - Amounts of 1 crore or more render as `"N Crore"` (e.g. `10000000` → `"1 Crore"`)
|
|
14
|
+
* - Amounts of 1 lakh or more render as `"N Lakh"` (e.g. `2500000` → `"25 Lakh"`)
|
|
15
|
+
* - Smaller amounts fall back to {@link formatPKR}
|
|
16
|
+
*
|
|
17
|
+
* Values are rounded to two decimals before the unit is chosen, so
|
|
18
|
+
* `9999999` renders as `"1 Crore"` rather than `"100 Lakh"`.
|
|
19
|
+
* Negative amounts are prefixed with `-`.
|
|
20
|
+
*
|
|
21
|
+
* @param amount - The amount in PKR
|
|
22
|
+
* @returns Human-readable lakh/crore string
|
|
23
|
+
* @throws {RangeError} If `amount` is `NaN` or infinite
|
|
24
|
+
*/
|
|
25
|
+
declare function formatLakh(amount: number): string;
|
|
26
|
+
|
|
27
|
+
export { formatLakh, formatPKR };
|
package/dist/format.d.ts
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Formats a numeric amount as Pakistani Rupees with comma separators,
|
|
3
|
+
* rounded to whole rupees. Negative amounts are prefixed with `-`.
|
|
4
|
+
*
|
|
5
|
+
* @param amount - The amount in PKR
|
|
6
|
+
* @returns Formatted string (e.g. `"Rs. 150,000"`, `"-Rs. 500"`)
|
|
7
|
+
* @throws {RangeError} If `amount` is `NaN` or infinite
|
|
8
|
+
*/
|
|
9
|
+
declare function formatPKR(amount: number): string;
|
|
10
|
+
/**
|
|
11
|
+
* Formats a numeric amount using Pakistani lakh/crore conventions.
|
|
12
|
+
*
|
|
13
|
+
* - Amounts of 1 crore or more render as `"N Crore"` (e.g. `10000000` → `"1 Crore"`)
|
|
14
|
+
* - Amounts of 1 lakh or more render as `"N Lakh"` (e.g. `2500000` → `"25 Lakh"`)
|
|
15
|
+
* - Smaller amounts fall back to {@link formatPKR}
|
|
16
|
+
*
|
|
17
|
+
* Values are rounded to two decimals before the unit is chosen, so
|
|
18
|
+
* `9999999` renders as `"1 Crore"` rather than `"100 Lakh"`.
|
|
19
|
+
* Negative amounts are prefixed with `-`.
|
|
20
|
+
*
|
|
21
|
+
* @param amount - The amount in PKR
|
|
22
|
+
* @returns Human-readable lakh/crore string
|
|
23
|
+
* @throws {RangeError} If `amount` is `NaN` or infinite
|
|
24
|
+
*/
|
|
25
|
+
declare function formatLakh(amount: number): string;
|
|
26
|
+
|
|
27
|
+
export { formatLakh, formatPKR };
|
package/dist/format.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { formatLakh, formatPKR } from './chunk-6TSKA2PH.js';
|
package/dist/geo.cjs
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var chunk3COX5FSL_cjs = require('./chunk-3COX5FSL.cjs');
|
|
4
|
+
require('./chunk-VPBMIYO2.cjs');
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
Object.defineProperty(exports, "getDistrictProvince", {
|
|
9
|
+
enumerable: true,
|
|
10
|
+
get: function () { return chunk3COX5FSL_cjs.getDistrictProvince; }
|
|
11
|
+
});
|
|
12
|
+
Object.defineProperty(exports, "getDistrictsByProvince", {
|
|
13
|
+
enumerable: true,
|
|
14
|
+
get: function () { return chunk3COX5FSL_cjs.getDistrictsByProvince; }
|
|
15
|
+
});
|
|
16
|
+
Object.defineProperty(exports, "getProvince", {
|
|
17
|
+
enumerable: true,
|
|
18
|
+
get: function () { return chunk3COX5FSL_cjs.getProvince; }
|
|
19
|
+
});
|
|
20
|
+
Object.defineProperty(exports, "searchCities", {
|
|
21
|
+
enumerable: true,
|
|
22
|
+
get: function () { return chunk3COX5FSL_cjs.searchCities; }
|
|
23
|
+
});
|
|
24
|
+
Object.defineProperty(exports, "searchDistricts", {
|
|
25
|
+
enumerable: true,
|
|
26
|
+
get: function () { return chunk3COX5FSL_cjs.searchDistricts; }
|
|
27
|
+
});
|
package/dist/geo.d.cts
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Returns the province for a given Pakistani city name.
|
|
3
|
+
*
|
|
4
|
+
* Matching is case-insensitive and ignores inconsistent spacing.
|
|
5
|
+
* Returns `null` when no exact city match is found.
|
|
6
|
+
*
|
|
7
|
+
* @param city - The city name to look up
|
|
8
|
+
* @returns Province name or `null` if not found
|
|
9
|
+
*/
|
|
10
|
+
declare function getProvince(city: string): string | null;
|
|
11
|
+
/**
|
|
12
|
+
* Searches cities by partial, case-insensitive name match.
|
|
13
|
+
*
|
|
14
|
+
* @param query - Partial city name to search for
|
|
15
|
+
* @returns Alphabetically sorted list of matching city names
|
|
16
|
+
*/
|
|
17
|
+
declare function searchCities(query: string): string[];
|
|
18
|
+
/**
|
|
19
|
+
* Returns the province for a given Pakistani district name.
|
|
20
|
+
*
|
|
21
|
+
* Matching is case-insensitive and ignores inconsistent spacing.
|
|
22
|
+
* Returns `null` when no exact district match is found.
|
|
23
|
+
*
|
|
24
|
+
* @param district - The district name to look up
|
|
25
|
+
* @returns Province name or `null` if not found
|
|
26
|
+
*/
|
|
27
|
+
declare function getDistrictProvince(district: string): string | null;
|
|
28
|
+
/**
|
|
29
|
+
* Searches districts by partial, case-insensitive name match.
|
|
30
|
+
*
|
|
31
|
+
* @param query - Partial district name to search for
|
|
32
|
+
* @returns Alphabetically sorted list of matching district names
|
|
33
|
+
*/
|
|
34
|
+
declare function searchDistricts(query: string): string[];
|
|
35
|
+
/**
|
|
36
|
+
* Returns all districts for a given province (case-insensitive).
|
|
37
|
+
*
|
|
38
|
+
* @param province - Province name to filter by
|
|
39
|
+
* @returns Alphabetically sorted district names
|
|
40
|
+
*/
|
|
41
|
+
declare function getDistrictsByProvince(province: string): string[];
|
|
42
|
+
|
|
43
|
+
export { getDistrictProvince, getDistrictsByProvince, getProvince, searchCities, searchDistricts };
|
package/dist/geo.d.ts
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Returns the province for a given Pakistani city name.
|
|
3
|
+
*
|
|
4
|
+
* Matching is case-insensitive and ignores inconsistent spacing.
|
|
5
|
+
* Returns `null` when no exact city match is found.
|
|
6
|
+
*
|
|
7
|
+
* @param city - The city name to look up
|
|
8
|
+
* @returns Province name or `null` if not found
|
|
9
|
+
*/
|
|
10
|
+
declare function getProvince(city: string): string | null;
|
|
11
|
+
/**
|
|
12
|
+
* Searches cities by partial, case-insensitive name match.
|
|
13
|
+
*
|
|
14
|
+
* @param query - Partial city name to search for
|
|
15
|
+
* @returns Alphabetically sorted list of matching city names
|
|
16
|
+
*/
|
|
17
|
+
declare function searchCities(query: string): string[];
|
|
18
|
+
/**
|
|
19
|
+
* Returns the province for a given Pakistani district name.
|
|
20
|
+
*
|
|
21
|
+
* Matching is case-insensitive and ignores inconsistent spacing.
|
|
22
|
+
* Returns `null` when no exact district match is found.
|
|
23
|
+
*
|
|
24
|
+
* @param district - The district name to look up
|
|
25
|
+
* @returns Province name or `null` if not found
|
|
26
|
+
*/
|
|
27
|
+
declare function getDistrictProvince(district: string): string | null;
|
|
28
|
+
/**
|
|
29
|
+
* Searches districts by partial, case-insensitive name match.
|
|
30
|
+
*
|
|
31
|
+
* @param query - Partial district name to search for
|
|
32
|
+
* @returns Alphabetically sorted list of matching district names
|
|
33
|
+
*/
|
|
34
|
+
declare function searchDistricts(query: string): string[];
|
|
35
|
+
/**
|
|
36
|
+
* Returns all districts for a given province (case-insensitive).
|
|
37
|
+
*
|
|
38
|
+
* @param province - Province name to filter by
|
|
39
|
+
* @returns Alphabetically sorted district names
|
|
40
|
+
*/
|
|
41
|
+
declare function getDistrictsByProvince(province: string): string[];
|
|
42
|
+
|
|
43
|
+
export { getDistrictProvince, getDistrictsByProvince, getProvince, searchCities, searchDistricts };
|
package/dist/geo.js
ADDED
package/dist/hijri.cjs
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var chunkCYJJ7KGC_cjs = require('./chunk-CYJJ7KGC.cjs');
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
Object.defineProperty(exports, "formatHijri", {
|
|
8
|
+
enumerable: true,
|
|
9
|
+
get: function () { return chunkCYJJ7KGC_cjs.formatHijri; }
|
|
10
|
+
});
|
|
11
|
+
Object.defineProperty(exports, "fromHijri", {
|
|
12
|
+
enumerable: true,
|
|
13
|
+
get: function () { return chunkCYJJ7KGC_cjs.fromHijri; }
|
|
14
|
+
});
|
|
15
|
+
Object.defineProperty(exports, "getHijriMonthName", {
|
|
16
|
+
enumerable: true,
|
|
17
|
+
get: function () { return chunkCYJJ7KGC_cjs.getHijriMonthName; }
|
|
18
|
+
});
|
|
19
|
+
Object.defineProperty(exports, "isRamadan", {
|
|
20
|
+
enumerable: true,
|
|
21
|
+
get: function () { return chunkCYJJ7KGC_cjs.isRamadan; }
|
|
22
|
+
});
|
|
23
|
+
Object.defineProperty(exports, "toHijri", {
|
|
24
|
+
enumerable: true,
|
|
25
|
+
get: function () { return chunkCYJJ7KGC_cjs.toHijri; }
|
|
26
|
+
});
|
package/dist/hijri.d.cts
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
/** Islamic (Hijri) date components. */
|
|
2
|
+
interface HijriDate {
|
|
3
|
+
year: number;
|
|
4
|
+
month: number;
|
|
5
|
+
day: number;
|
|
6
|
+
}
|
|
7
|
+
/** Options for Hijri conversions. */
|
|
8
|
+
interface HijriOptions {
|
|
9
|
+
/**
|
|
10
|
+
* Whole days to shift the tabular calendar by, to match local moon sighting.
|
|
11
|
+
* For example, `-1` when Pakistan's Ruet-e-Hilal calendar runs a day behind
|
|
12
|
+
* the tabular date. Defaults to `0`.
|
|
13
|
+
*/
|
|
14
|
+
offset?: number;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Converts a Gregorian `Date` to a Hijri (Islamic) date.
|
|
18
|
+
*
|
|
19
|
+
* Uses the tabular (arithmetic, "islamic-civil") calendar. Actual dates in
|
|
20
|
+
* Pakistan follow moon sighting and can differ by a day or two; pass
|
|
21
|
+
* `options.offset` to adjust.
|
|
22
|
+
*
|
|
23
|
+
* @param date - Gregorian date (local date components are used)
|
|
24
|
+
* @param options - Optional day offset for moon-sighting adjustment
|
|
25
|
+
* @returns Hijri date components
|
|
26
|
+
* @throws {RangeError} If `date` is invalid or `offset` is not an integer
|
|
27
|
+
*/
|
|
28
|
+
declare function toHijri(date: Date, options?: HijriOptions): HijriDate;
|
|
29
|
+
/**
|
|
30
|
+
* Converts a Hijri date to a Gregorian `Date` (local midnight).
|
|
31
|
+
*
|
|
32
|
+
* @param hijri - Hijri date components
|
|
33
|
+
* @param options - Optional day offset, matching the one used with {@link toHijri}
|
|
34
|
+
* @returns Gregorian date
|
|
35
|
+
* @throws {RangeError} If the Hijri components are out of range
|
|
36
|
+
*/
|
|
37
|
+
declare function fromHijri(hijri: HijriDate, options?: HijriOptions): Date;
|
|
38
|
+
/**
|
|
39
|
+
* Formats a Gregorian date as a Hijri date string.
|
|
40
|
+
*
|
|
41
|
+
* @param date - Gregorian date
|
|
42
|
+
* @param options - Optional day offset for moon-sighting adjustment
|
|
43
|
+
* @returns Formatted Hijri string (e.g. `"14 Ramadan 1447"`)
|
|
44
|
+
*/
|
|
45
|
+
declare function formatHijri(date: Date, options?: HijriOptions): string;
|
|
46
|
+
/**
|
|
47
|
+
* Returns the English name of a Hijri month (1–12).
|
|
48
|
+
*
|
|
49
|
+
* @param month - Hijri month number
|
|
50
|
+
* @returns Month name, or `null` if `month` is not an integer from 1 to 12
|
|
51
|
+
*/
|
|
52
|
+
declare function getHijriMonthName(month: number): string | null;
|
|
53
|
+
/**
|
|
54
|
+
* Returns whether a Gregorian date falls in the month of Ramadan.
|
|
55
|
+
*
|
|
56
|
+
* @param date - Gregorian date
|
|
57
|
+
* @param options - Optional day offset for moon-sighting adjustment
|
|
58
|
+
* @returns `true` during Ramadan
|
|
59
|
+
*/
|
|
60
|
+
declare function isRamadan(date: Date, options?: HijriOptions): boolean;
|
|
61
|
+
|
|
62
|
+
export { type HijriDate, type HijriOptions, formatHijri, fromHijri, getHijriMonthName, isRamadan, toHijri };
|
package/dist/hijri.d.ts
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
/** Islamic (Hijri) date components. */
|
|
2
|
+
interface HijriDate {
|
|
3
|
+
year: number;
|
|
4
|
+
month: number;
|
|
5
|
+
day: number;
|
|
6
|
+
}
|
|
7
|
+
/** Options for Hijri conversions. */
|
|
8
|
+
interface HijriOptions {
|
|
9
|
+
/**
|
|
10
|
+
* Whole days to shift the tabular calendar by, to match local moon sighting.
|
|
11
|
+
* For example, `-1` when Pakistan's Ruet-e-Hilal calendar runs a day behind
|
|
12
|
+
* the tabular date. Defaults to `0`.
|
|
13
|
+
*/
|
|
14
|
+
offset?: number;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Converts a Gregorian `Date` to a Hijri (Islamic) date.
|
|
18
|
+
*
|
|
19
|
+
* Uses the tabular (arithmetic, "islamic-civil") calendar. Actual dates in
|
|
20
|
+
* Pakistan follow moon sighting and can differ by a day or two; pass
|
|
21
|
+
* `options.offset` to adjust.
|
|
22
|
+
*
|
|
23
|
+
* @param date - Gregorian date (local date components are used)
|
|
24
|
+
* @param options - Optional day offset for moon-sighting adjustment
|
|
25
|
+
* @returns Hijri date components
|
|
26
|
+
* @throws {RangeError} If `date` is invalid or `offset` is not an integer
|
|
27
|
+
*/
|
|
28
|
+
declare function toHijri(date: Date, options?: HijriOptions): HijriDate;
|
|
29
|
+
/**
|
|
30
|
+
* Converts a Hijri date to a Gregorian `Date` (local midnight).
|
|
31
|
+
*
|
|
32
|
+
* @param hijri - Hijri date components
|
|
33
|
+
* @param options - Optional day offset, matching the one used with {@link toHijri}
|
|
34
|
+
* @returns Gregorian date
|
|
35
|
+
* @throws {RangeError} If the Hijri components are out of range
|
|
36
|
+
*/
|
|
37
|
+
declare function fromHijri(hijri: HijriDate, options?: HijriOptions): Date;
|
|
38
|
+
/**
|
|
39
|
+
* Formats a Gregorian date as a Hijri date string.
|
|
40
|
+
*
|
|
41
|
+
* @param date - Gregorian date
|
|
42
|
+
* @param options - Optional day offset for moon-sighting adjustment
|
|
43
|
+
* @returns Formatted Hijri string (e.g. `"14 Ramadan 1447"`)
|
|
44
|
+
*/
|
|
45
|
+
declare function formatHijri(date: Date, options?: HijriOptions): string;
|
|
46
|
+
/**
|
|
47
|
+
* Returns the English name of a Hijri month (1–12).
|
|
48
|
+
*
|
|
49
|
+
* @param month - Hijri month number
|
|
50
|
+
* @returns Month name, or `null` if `month` is not an integer from 1 to 12
|
|
51
|
+
*/
|
|
52
|
+
declare function getHijriMonthName(month: number): string | null;
|
|
53
|
+
/**
|
|
54
|
+
* Returns whether a Gregorian date falls in the month of Ramadan.
|
|
55
|
+
*
|
|
56
|
+
* @param date - Gregorian date
|
|
57
|
+
* @param options - Optional day offset for moon-sighting adjustment
|
|
58
|
+
* @returns `true` during Ramadan
|
|
59
|
+
*/
|
|
60
|
+
declare function isRamadan(date: Date, options?: HijriOptions): boolean;
|
|
61
|
+
|
|
62
|
+
export { type HijriDate, type HijriOptions, formatHijri, fromHijri, getHijriMonthName, isRamadan, toHijri };
|
package/dist/hijri.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { formatHijri, fromHijri, getHijriMonthName, isRamadan, toHijri } from './chunk-Z5JEIQVW.js';
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var chunkXCXFGTHW_cjs = require('./chunk-XCXFGTHW.cjs');
|
|
4
|
+
require('./chunk-CYJJ7KGC.cjs');
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
Object.defineProperty(exports, "getHolidaysOn", {
|
|
9
|
+
enumerable: true,
|
|
10
|
+
get: function () { return chunkXCXFGTHW_cjs.getHolidaysOn; }
|
|
11
|
+
});
|
|
12
|
+
Object.defineProperty(exports, "getPakistanHolidays", {
|
|
13
|
+
enumerable: true,
|
|
14
|
+
get: function () { return chunkXCXFGTHW_cjs.getPakistanHolidays; }
|
|
15
|
+
});
|
|
16
|
+
Object.defineProperty(exports, "isPakistanHoliday", {
|
|
17
|
+
enumerable: true,
|
|
18
|
+
get: function () { return chunkXCXFGTHW_cjs.isPakistanHoliday; }
|
|
19
|
+
});
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
/** Islamic public holidays, whose dates depend on moon sighting. */
|
|
2
|
+
type IslamicHolidayId = 'eid-ul-fitr' | 'eid-ul-adha' | 'ashura' | 'eid-milad-un-nabi';
|
|
3
|
+
/** Identifier of a Pakistani federal public holiday. */
|
|
4
|
+
type HolidayId = IslamicHolidayId | 'kashmir-day' | 'pakistan-day' | 'labour-day' | 'youm-e-takbeer' | 'independence-day' | 'iqbal-day' | 'quaid-e-azam-day' | 'day-after-christmas';
|
|
5
|
+
/** A public holiday on a specific date. */
|
|
6
|
+
interface Holiday {
|
|
7
|
+
id: HolidayId;
|
|
8
|
+
name: string;
|
|
9
|
+
/** Date as `YYYY-MM-DD`. */
|
|
10
|
+
date: string;
|
|
11
|
+
type: 'national' | 'religious';
|
|
12
|
+
/**
|
|
13
|
+
* `true` when an Islamic holiday's date is calculated from the tabular Hijri
|
|
14
|
+
* calendar because the observed dates are not in the dataset yet. The real
|
|
15
|
+
* date depends on the moon-sighting announcement.
|
|
16
|
+
*/
|
|
17
|
+
estimated: boolean;
|
|
18
|
+
/** `true` for holidays that apply to Christian employees only. */
|
|
19
|
+
christiansOnly?: boolean;
|
|
20
|
+
/** Source of an observed Islamic holiday date. */
|
|
21
|
+
source?: string;
|
|
22
|
+
}
|
|
23
|
+
/** Options for {@link getPakistanHolidays}. */
|
|
24
|
+
interface HolidayOptions {
|
|
25
|
+
/** Include 26 December, a holiday for Christian employees only. Defaults to `false`. */
|
|
26
|
+
includeChristianHolidays?: boolean;
|
|
27
|
+
/**
|
|
28
|
+
* Observed or announced dates (`YYYY-MM-DD`) for Islamic holidays, used
|
|
29
|
+
* instead of the dataset or estimate. Use this to apply a new moon-sighting
|
|
30
|
+
* announcement before the library is updated.
|
|
31
|
+
*/
|
|
32
|
+
announced?: Partial<Record<IslamicHolidayId, string[]>>;
|
|
33
|
+
/** Day offset applied to estimated Islamic dates. Defaults to `0`. */
|
|
34
|
+
hijriOffset?: number;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Lists Pakistan's federal public holidays for a year, sorted by date.
|
|
38
|
+
*
|
|
39
|
+
* Islamic holidays use the dates actually observed after moon sighting
|
|
40
|
+
* (2020 onwards, from Cabinet Division and SBP notifications). For years not
|
|
41
|
+
* yet in the dataset they are estimated from the tabular Hijri calendar and
|
|
42
|
+
* marked `estimated: true`; pass `announced` to use official dates instead.
|
|
43
|
+
*
|
|
44
|
+
* Optional holidays (e.g. Shab-e-Barat, Easter, Youm-e-Ali) are not included.
|
|
45
|
+
*
|
|
46
|
+
* @example
|
|
47
|
+
* getPakistanHolidays(2025).find((h) => h.id === 'eid-ul-fitr');
|
|
48
|
+
* // { id: 'eid-ul-fitr', name: 'Eid ul Fitr', date: '2025-03-31', type: 'religious', estimated: false, ... }
|
|
49
|
+
*
|
|
50
|
+
* @param year - Gregorian year
|
|
51
|
+
* @param options - Christian holidays, announced dates and estimate offset
|
|
52
|
+
* @returns Holidays in date order
|
|
53
|
+
*/
|
|
54
|
+
declare function getPakistanHolidays(year: number, options?: HolidayOptions): Holiday[];
|
|
55
|
+
/**
|
|
56
|
+
* Returns the public holidays that fall on a date.
|
|
57
|
+
*
|
|
58
|
+
* @param date - A `Date` (local calendar date) or `YYYY-MM-DD` string
|
|
59
|
+
* @param options - Same options as {@link getPakistanHolidays}
|
|
60
|
+
* @returns Holidays on that date; empty if it is not a public holiday
|
|
61
|
+
*/
|
|
62
|
+
declare function getHolidaysOn(date: Date | string, options?: HolidayOptions): Holiday[];
|
|
63
|
+
/**
|
|
64
|
+
* Returns whether a date is a Pakistani federal public holiday.
|
|
65
|
+
*
|
|
66
|
+
* @param date - A `Date` (local calendar date) or `YYYY-MM-DD` string
|
|
67
|
+
* @param options - Same options as {@link getPakistanHolidays}
|
|
68
|
+
* @returns `true` on a public holiday
|
|
69
|
+
*/
|
|
70
|
+
declare function isPakistanHoliday(date: Date | string, options?: HolidayOptions): boolean;
|
|
71
|
+
|
|
72
|
+
export { type Holiday, type HolidayId, type HolidayOptions, type IslamicHolidayId, getHolidaysOn, getPakistanHolidays, isPakistanHoliday };
|