nepali-date-library 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/ReadMe.md +128 -0
- package/dist/Helper/Constants.d.ts +16 -0
- package/dist/Helper/DateConverter.d.ts +12 -0
- package/dist/Helper/DateFormatter.d.ts +2 -0
- package/dist/NepaliDate.d.ts +272 -0
- package/dist/index.cjs +1 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.mjs +1 -0
- package/package.json +25 -0
- package/src/Helper/Constants.ts +132 -0
- package/src/Helper/DateConverter.ts +47 -0
- package/src/Helper/DateFormatter.ts +170 -0
- package/src/NepaliDate.ts +680 -0
- package/src/index.ts +5 -0
- package/tsconfig.json +20 -0
package/ReadMe.md
ADDED
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
# NepaliDate Library
|
|
2
|
+
|
|
3
|
+
## Overview
|
|
4
|
+
The `NepaliDate` library provides a way to work with Nepali (Bikram Sambat) dates in TypeScript/JavaScript. It allows you to create, manipulate, format, and convert between Nepali and Gregorian dates.
|
|
5
|
+
|
|
6
|
+
## Installation
|
|
7
|
+
```sh
|
|
8
|
+
npm install nepali-date-library
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Importing the Library
|
|
12
|
+
```ts
|
|
13
|
+
import { NepaliDate } from 'nepali-date-library';
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
## Class: `NepaliDate`
|
|
17
|
+
### Constructors
|
|
18
|
+
```ts
|
|
19
|
+
new NepaliDate();
|
|
20
|
+
new NepaliDate(date: Date | NepaliDate | number | string);
|
|
21
|
+
new NepaliDate(year: number, month: number, day: number);
|
|
22
|
+
```
|
|
23
|
+
- Creates a `NepaliDate` instance.
|
|
24
|
+
- Accepts either no arguments (current date), a JavaScript `Date`, another `NepaliDate`, a timestamp, or a formatted date string.
|
|
25
|
+
- Can also accept year, month (0-11), and day (1-32) as separate arguments.
|
|
26
|
+
|
|
27
|
+
### Methods
|
|
28
|
+
#### Date Conversion
|
|
29
|
+
|
|
30
|
+
```ts
|
|
31
|
+
//PreBuild Functions
|
|
32
|
+
|
|
33
|
+
import { ADtoBS, BStoAD } from 'nepali-date-library';
|
|
34
|
+
|
|
35
|
+
// Convert AD to BS
|
|
36
|
+
const bsDate = ADtoBS('2025-02-22'); // Returns: '2081-10-10'
|
|
37
|
+
|
|
38
|
+
// Convert BS to AD
|
|
39
|
+
const adDate = BStoAD('2081-10-14'); // Returns: '2025-02-26'
|
|
40
|
+
|
|
41
|
+
//Class Functions
|
|
42
|
+
const adDate = new NepaliDate().getEnglishDate();
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
#### Getters
|
|
46
|
+
```ts
|
|
47
|
+
getYear(): number;
|
|
48
|
+
getMonth(): number;
|
|
49
|
+
getDate(): number;
|
|
50
|
+
getDay(): number;
|
|
51
|
+
getHours(): number;
|
|
52
|
+
getMinutes(): number;
|
|
53
|
+
getSeconds(): number;
|
|
54
|
+
getMilliseconds(): number;
|
|
55
|
+
getTime(): number;
|
|
56
|
+
```
|
|
57
|
+
- Returns individual date components like year, month (0-11), day (1-32), and other time properties.
|
|
58
|
+
|
|
59
|
+
#### Setters
|
|
60
|
+
```ts
|
|
61
|
+
setYear(year: number): void;
|
|
62
|
+
setMonth(month: number): void;
|
|
63
|
+
setDate(day: number): void;
|
|
64
|
+
set(year: number, month: number, day: number): void;
|
|
65
|
+
```
|
|
66
|
+
- Updates the Nepali date components and synchronizes the internal timestamp.
|
|
67
|
+
|
|
68
|
+
#### Formatting
|
|
69
|
+
```ts
|
|
70
|
+
format(formatStr: string): string;
|
|
71
|
+
```
|
|
72
|
+
- Formats the date based on the provided format string.
|
|
73
|
+
|
|
74
|
+
- Available Formats:
|
|
75
|
+
- English
|
|
76
|
+
- YYYY - Full Year (e.g., 2080)
|
|
77
|
+
- MM - Month with leading zero (01-12)
|
|
78
|
+
- M - Month without leading zero (1-12)
|
|
79
|
+
- MMM - Short month name (Bai, Cha)
|
|
80
|
+
- MMMM - Long month name (Baisakh, Chaitra)
|
|
81
|
+
- DD - Day with leading zero (01-32)
|
|
82
|
+
- D - Day without leading zero (1-32)
|
|
83
|
+
- DDD - Short day name (Sun, Sat)
|
|
84
|
+
- DDDD - Full day name (Sunday)
|
|
85
|
+
|
|
86
|
+
- Nepali
|
|
87
|
+
- yyyy - Full Year (e.g., २०८१)
|
|
88
|
+
- mm - Month with leading zero (०१-१२)
|
|
89
|
+
- m - Month without leading zero (१-१२)
|
|
90
|
+
- mmm - Short month name (बै, चै)
|
|
91
|
+
- mmmm - Long month name (बैशाख, चैत्र)
|
|
92
|
+
- dd - Day with leading zero (०१-३२)
|
|
93
|
+
- d - Day without leading zero (१-३२)
|
|
94
|
+
- ddd - Short day name (आइत, शनि)
|
|
95
|
+
- dddd - Full day name (आइतबार)
|
|
96
|
+
|
|
97
|
+
|
|
98
|
+
#### Date Manipulation
|
|
99
|
+
```ts
|
|
100
|
+
addDays(days: number): NepaliDate;
|
|
101
|
+
addMonths(months: number): NepaliDate;
|
|
102
|
+
addYears(years: number): NepaliDate;
|
|
103
|
+
```
|
|
104
|
+
- Adds a specified number of days, months, or years to the date and returns a new `NepaliDate` instance.
|
|
105
|
+
|
|
106
|
+
|
|
107
|
+
## Example Usage
|
|
108
|
+
```ts
|
|
109
|
+
const today = new NepaliDate();
|
|
110
|
+
console.log(today);
|
|
111
|
+
|
|
112
|
+
const formatted = today.format('YYYY-MM-DD');
|
|
113
|
+
console.log(formatted);
|
|
114
|
+
|
|
115
|
+
const futureDate = today.addDays(10);
|
|
116
|
+
console.log(futureDate);
|
|
117
|
+
|
|
118
|
+
const pastDate = today.addDays(-10);
|
|
119
|
+
console.log(pastDate);
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
## Error Handling
|
|
123
|
+
- Throws an error if an invalid date format is used.
|
|
124
|
+
- Throws an error if the Nepali date is out of range.
|
|
125
|
+
|
|
126
|
+
## License
|
|
127
|
+
MIT License
|
|
128
|
+
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export declare const NEPALI_DATE_MAP: {
|
|
2
|
+
year: number;
|
|
3
|
+
days: Array<number>;
|
|
4
|
+
totalDays: number;
|
|
5
|
+
daysTillNow: number;
|
|
6
|
+
}[];
|
|
7
|
+
export declare const EPOCH: number;
|
|
8
|
+
export declare const WEEK_EN: string[];
|
|
9
|
+
export declare const WEEK_SHORT_EN: string[];
|
|
10
|
+
export declare const WEEK_NP: string[];
|
|
11
|
+
export declare const WEEK_SHORT_NP: string[];
|
|
12
|
+
export declare const MONTH_EN: string[];
|
|
13
|
+
export declare const MONTH_SHORT_EN: string[];
|
|
14
|
+
export declare const MONTH_NP: string[];
|
|
15
|
+
export declare const MONTH_SHORT_NP: string[];
|
|
16
|
+
export declare const NUMBER_NP: string[];
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Converts a Anno Domini (AD) date to an Bikram Sambat(BS) Date.
|
|
3
|
+
* @param {string} adDate - The Anno Domini (AD) date in "YYYY-MM-DD" format.
|
|
4
|
+
* @returns {string} - The corresponding Bikram Sambat(BS) date in "YYYY-MM-DD" format.
|
|
5
|
+
*/
|
|
6
|
+
export declare const ADtoBS: (adDate: string) => string;
|
|
7
|
+
/**
|
|
8
|
+
* Converts a Bikram Sambat(BS) to an Anno Domini (AD) Date.
|
|
9
|
+
* @param bsDate - The Bikram Sambat(BS) date in "YYYY-MM-DD" format.
|
|
10
|
+
* @returns {string} - The corresponding Anno Domini (AD) date in "YYYY-MM-DD" format.
|
|
11
|
+
*/
|
|
12
|
+
export declare function BStoAD(bsDate: string): string;
|
|
@@ -0,0 +1,272 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Class representing a Nepali date (Bikram Sambat)
|
|
3
|
+
* Provides methods to create, manipulate and format Nepali dates
|
|
4
|
+
*/
|
|
5
|
+
export declare class NepaliDate {
|
|
6
|
+
/** JavaScript Date object representing the equivalent Gregorian date */
|
|
7
|
+
timestamp: Date;
|
|
8
|
+
/** Nepali year (BS) */
|
|
9
|
+
year: number;
|
|
10
|
+
/** Nepali month (0-11) */
|
|
11
|
+
month: number;
|
|
12
|
+
/** Nepali day of month (1-32) */
|
|
13
|
+
day: number;
|
|
14
|
+
/**
|
|
15
|
+
* Creates a NepaliDate instance for the current date
|
|
16
|
+
*/
|
|
17
|
+
constructor();
|
|
18
|
+
/**
|
|
19
|
+
* Creates a NepaliDate instance from various input types
|
|
20
|
+
* @param date Source date as Date, NepaliDate, timestamp number, or date string
|
|
21
|
+
*/
|
|
22
|
+
constructor(date: Date | NepaliDate | number | string);
|
|
23
|
+
/**
|
|
24
|
+
* Creates a NepaliDate instance with the specified year, month, and day
|
|
25
|
+
* @param year Nepali year
|
|
26
|
+
* @param month Nepali month (0-11)
|
|
27
|
+
* @param day Nepali day (1-32)
|
|
28
|
+
*/
|
|
29
|
+
constructor(year: number, month: number, day: number);
|
|
30
|
+
/**
|
|
31
|
+
* Sets the internal properties based on the provided English (Gregorian) date
|
|
32
|
+
* @param date JavaScript Date object
|
|
33
|
+
* @private
|
|
34
|
+
*/
|
|
35
|
+
private setEnglishDate;
|
|
36
|
+
/**
|
|
37
|
+
* Returns the equivalent English (Gregorian) date
|
|
38
|
+
* @returns JavaScript Date object representing the equivalent Gregorian date
|
|
39
|
+
*/
|
|
40
|
+
getEnglishDate(): Date;
|
|
41
|
+
/**
|
|
42
|
+
* Parses a date string and updates the current instance
|
|
43
|
+
* @param dateString Date string in format YYYY-MM-DD, YYYY/MM/DD, or YYYY.MM.DD
|
|
44
|
+
* @throws Error if the date format is invalid or date is out of range
|
|
45
|
+
*/
|
|
46
|
+
parse(dateString: string): void;
|
|
47
|
+
/**
|
|
48
|
+
* Returns the Nepali year
|
|
49
|
+
* @returns Nepali year
|
|
50
|
+
*/
|
|
51
|
+
getYear(): number;
|
|
52
|
+
/**
|
|
53
|
+
* Returns the Nepali month (0-11)
|
|
54
|
+
* @returns Nepali month (0-11)
|
|
55
|
+
*/
|
|
56
|
+
getMonth(): number;
|
|
57
|
+
/**
|
|
58
|
+
* Returns the Nepali day of month
|
|
59
|
+
* @returns Nepali day of month (1-32)
|
|
60
|
+
*/
|
|
61
|
+
getDate(): number;
|
|
62
|
+
/**
|
|
63
|
+
* Returns the day of week (0-6, 0 = Sunday)
|
|
64
|
+
* @returns Day of week (0-6, 0 = Sunday)
|
|
65
|
+
*/
|
|
66
|
+
getDay(): number;
|
|
67
|
+
/**
|
|
68
|
+
* Returns the hour (0-23)
|
|
69
|
+
* @returns Hour (0-23)
|
|
70
|
+
*/
|
|
71
|
+
getHours(): number;
|
|
72
|
+
/**
|
|
73
|
+
* Returns the minutes (0-59)
|
|
74
|
+
* @returns Minutes (0-59)
|
|
75
|
+
*/
|
|
76
|
+
getMinutes(): number;
|
|
77
|
+
/**
|
|
78
|
+
* Returns the seconds (0-59)
|
|
79
|
+
* @returns Seconds (0-59)
|
|
80
|
+
*/
|
|
81
|
+
getSeconds(): number;
|
|
82
|
+
/**
|
|
83
|
+
* Returns the milliseconds (0-999)
|
|
84
|
+
* @returns Milliseconds (0-999)
|
|
85
|
+
*/
|
|
86
|
+
getMilliseconds(): number;
|
|
87
|
+
/**
|
|
88
|
+
* Returns the timestamp (milliseconds since Unix Epoch)
|
|
89
|
+
* @returns Timestamp in milliseconds
|
|
90
|
+
*/
|
|
91
|
+
getTime(): number;
|
|
92
|
+
/**
|
|
93
|
+
* Sets the Nepali year
|
|
94
|
+
* @param year Nepali year
|
|
95
|
+
*/
|
|
96
|
+
setYear(year: number): void;
|
|
97
|
+
/**
|
|
98
|
+
* Sets the Nepali month
|
|
99
|
+
* @param month Nepali month (0-11)
|
|
100
|
+
*/
|
|
101
|
+
setMonth(month: number): void;
|
|
102
|
+
/**
|
|
103
|
+
* Sets the Nepali day of month
|
|
104
|
+
* @param day Nepali day of month (1-32)
|
|
105
|
+
*/
|
|
106
|
+
setDate(day: number): void;
|
|
107
|
+
/**
|
|
108
|
+
* Sets the Nepali date components and updates the internal timestamp
|
|
109
|
+
* @param year Nepali year
|
|
110
|
+
* @param month Nepali month (0-11)
|
|
111
|
+
* @param date Nepali day (1-32)
|
|
112
|
+
*/
|
|
113
|
+
set(year: number, month: number, date: number): void;
|
|
114
|
+
/**
|
|
115
|
+
* Formats the Nepali date according to the specified format string
|
|
116
|
+
* @param formatStr Format string (see DateFormatter for syntax)
|
|
117
|
+
* @returns Formatted date string
|
|
118
|
+
*/
|
|
119
|
+
format(formatStr: string): string;
|
|
120
|
+
/**
|
|
121
|
+
* Returns the string representation of the Nepali date
|
|
122
|
+
* @returns Date string in format YYYY/MM/DD where MM is 1-indexed
|
|
123
|
+
*/
|
|
124
|
+
toString(): string;
|
|
125
|
+
/**
|
|
126
|
+
* Adds the specified number of days to the current Nepali date
|
|
127
|
+
* @param days Number of days to add (can be negative)
|
|
128
|
+
* @returns A new NepaliDate instance with the added days
|
|
129
|
+
*/
|
|
130
|
+
addDays(days: number): NepaliDate;
|
|
131
|
+
/**
|
|
132
|
+
* Adds the specified number of months to the current Nepali date
|
|
133
|
+
* @param months Number of months to add (can be negative)
|
|
134
|
+
* @returns A new NepaliDate instance with the added months
|
|
135
|
+
*/
|
|
136
|
+
addMonths(months: number): NepaliDate;
|
|
137
|
+
/**
|
|
138
|
+
* Adds the specified number of years to the current Nepali date
|
|
139
|
+
* @param years Number of years to add (can be negative)
|
|
140
|
+
* @returns A new NepaliDate instance with the added years
|
|
141
|
+
*/
|
|
142
|
+
addYears(years: number): NepaliDate;
|
|
143
|
+
/**
|
|
144
|
+
* Returns the earliest date supported by the NepaliDate class
|
|
145
|
+
* @returns JavaScript Date object representing the minimum supported date
|
|
146
|
+
*/
|
|
147
|
+
static minimum(): Date;
|
|
148
|
+
/**
|
|
149
|
+
* Returns the latest date supported by the NepaliDate class
|
|
150
|
+
* @returns JavaScript Date object representing the maximum supported date
|
|
151
|
+
*/
|
|
152
|
+
static maximum(): Date;
|
|
153
|
+
/**
|
|
154
|
+
* Returns the number of days in the current month
|
|
155
|
+
* @returns Number of days in the month
|
|
156
|
+
*/
|
|
157
|
+
daysInMonth(): number;
|
|
158
|
+
/**
|
|
159
|
+
* Checks if the current year is a leap year in the Nepali calendar
|
|
160
|
+
* @returns true if the year is a leap year, false otherwise
|
|
161
|
+
*/
|
|
162
|
+
isLeapYear(): boolean;
|
|
163
|
+
/**
|
|
164
|
+
* Calculates the number of weeks in the current month
|
|
165
|
+
* @returns Number of weeks in the month
|
|
166
|
+
*/
|
|
167
|
+
getWeeksInMonth(): number;
|
|
168
|
+
/**
|
|
169
|
+
* Calculates the difference between two dates in the specified unit
|
|
170
|
+
* @param date NepaliDate to compare with
|
|
171
|
+
* @param unit Unit for the difference calculation ('year', 'month', or 'day')
|
|
172
|
+
* @returns Difference value in the specified unit
|
|
173
|
+
*/
|
|
174
|
+
diff(date: NepaliDate, unit: 'year' | 'month' | 'day'): number;
|
|
175
|
+
/**
|
|
176
|
+
* Returns a new NepaliDate representing the start of the current day (00:00:00)
|
|
177
|
+
* @returns A new NepaliDate set to the start of the day
|
|
178
|
+
*/
|
|
179
|
+
startOfDay(): NepaliDate;
|
|
180
|
+
/**
|
|
181
|
+
* Returns a new NepaliDate representing the end of the current day (23:59:59.999)
|
|
182
|
+
* @returns A new NepaliDate set to the end of the day
|
|
183
|
+
*/
|
|
184
|
+
endOfDay(): NepaliDate;
|
|
185
|
+
/**
|
|
186
|
+
* Returns a new NepaliDate representing the start of the current month (1st day)
|
|
187
|
+
* @returns A new NepaliDate set to the first day of the month
|
|
188
|
+
*/
|
|
189
|
+
startOfMonth(): NepaliDate;
|
|
190
|
+
/**
|
|
191
|
+
* Returns a new NepaliDate representing the end of the current month (last day)
|
|
192
|
+
* @returns A new NepaliDate set to the last day of the month
|
|
193
|
+
*/
|
|
194
|
+
endOfMonth(): NepaliDate;
|
|
195
|
+
/**
|
|
196
|
+
* Returns a new NepaliDate representing the start of the current year (1st Baisakh)
|
|
197
|
+
* @returns A new NepaliDate set to the first day of the year
|
|
198
|
+
*/
|
|
199
|
+
startOfYear(): NepaliDate;
|
|
200
|
+
/**
|
|
201
|
+
* Returns a new NepaliDate representing the end of the current year (last day of Chaitra)
|
|
202
|
+
* @returns A new NepaliDate set to the last day of the year
|
|
203
|
+
*/
|
|
204
|
+
endOfYear(): NepaliDate;
|
|
205
|
+
/**
|
|
206
|
+
* Returns the name of the specified Nepali month
|
|
207
|
+
* @param month Month index (0-11)
|
|
208
|
+
* @param short Whether to return the short form of the month name
|
|
209
|
+
* @returns Month name in Nepali or English
|
|
210
|
+
*/
|
|
211
|
+
static getMonthName(month: number, short?: boolean, nepali?: boolean): string;
|
|
212
|
+
/**
|
|
213
|
+
* Returns the name of the specified day of week
|
|
214
|
+
* @param day Day of week (0-6, where 0 is Sunday)
|
|
215
|
+
* @param short Whether to return the short form of the day name
|
|
216
|
+
* @returns Day name in Nepali or English
|
|
217
|
+
*/
|
|
218
|
+
static getDayName(day: number, short?: boolean, nepali?: boolean): string;
|
|
219
|
+
/**
|
|
220
|
+
* Checks if the specified Nepali date is valid
|
|
221
|
+
* @param year Nepali year to validate
|
|
222
|
+
* @param month Nepali month to validate (0-11)
|
|
223
|
+
* @param day Nepali day to validate
|
|
224
|
+
* @returns true if the date is valid, false otherwise
|
|
225
|
+
*/
|
|
226
|
+
static isValid(year: number, month: number, day: number): boolean;
|
|
227
|
+
/**
|
|
228
|
+
* Checks if the current NepaliDate instance contains a valid date
|
|
229
|
+
* @returns true if the date is valid, false otherwise
|
|
230
|
+
*/
|
|
231
|
+
isValid(): boolean;
|
|
232
|
+
/**
|
|
233
|
+
* Generate calendar days for a given month, including trailing/leading days from adjacent months
|
|
234
|
+
* @param year Nepali year
|
|
235
|
+
* @param month Nepali month (0-11)
|
|
236
|
+
* @returns Array of day objects with date and isCurrentMonth flag
|
|
237
|
+
*/
|
|
238
|
+
static getCalendarDays(year: number, month: number): {
|
|
239
|
+
date: number;
|
|
240
|
+
isCurrentMonth: boolean;
|
|
241
|
+
}[];
|
|
242
|
+
/**
|
|
243
|
+
* Creates a copy of the current NepaliDate instance
|
|
244
|
+
* @returns A new NepaliDate instance with the same date and time
|
|
245
|
+
*/
|
|
246
|
+
clone(): NepaliDate;
|
|
247
|
+
/**
|
|
248
|
+
* Checks if this date comes after the specified date
|
|
249
|
+
* @param date Date to compare with
|
|
250
|
+
* @returns true if this date is after the specified date, false otherwise
|
|
251
|
+
*/
|
|
252
|
+
isAfter(date: NepaliDate): boolean;
|
|
253
|
+
/**
|
|
254
|
+
* Checks if this date comes before the specified date
|
|
255
|
+
* @param date Date to compare with
|
|
256
|
+
* @returns true if this date is before the specified date, false otherwise
|
|
257
|
+
*/
|
|
258
|
+
isBefore(date: NepaliDate): boolean;
|
|
259
|
+
/**
|
|
260
|
+
* Checks if this date is equal to the specified date
|
|
261
|
+
* @param date Date to compare with
|
|
262
|
+
* @returns true if dates are exactly equal (year, month, day), false otherwise
|
|
263
|
+
*/
|
|
264
|
+
isEqual(date: NepaliDate): boolean;
|
|
265
|
+
/**
|
|
266
|
+
* Checks if this date is the same as the specified date for the given unit
|
|
267
|
+
* @param date Date to compare with
|
|
268
|
+
* @param unit Unit to use for comparison ('year', 'month', or 'day')
|
|
269
|
+
* @returns true if dates are the same for the specified unit, false otherwise
|
|
270
|
+
*/
|
|
271
|
+
isSame(date: NepaliDate, unit: 'year' | 'month' | 'day'): boolean;
|
|
272
|
+
}
|
package/dist/index.cjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var S=Object.defineProperty;var W=Object.getOwnPropertyDescriptor;var F=Object.getOwnPropertyNames;var K=Object.prototype.hasOwnProperty;var $=(e,t)=>{for(var a in t)S(e,a,{get:t[a],enumerable:!0})},C=(e,t,a,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of F(t))!K.call(e,s)&&s!==a&&S(e,s,{get:()=>t[s],enumerable:!(r=W(t,s))||r.enumerable});return e};var B=e=>C(S({},"__esModule",{value:!0}),e);var G={};$(G,{ADtoBS:()=>Y,BStoAD:()=>A,MONTH_EN:()=>c,MONTH_NP:()=>T,MONTH_SHORT_EN:()=>p,MONTH_SHORT_NP:()=>f,NEPALI_DATE_MAP:()=>o,NUMBER_NP:()=>M,NepaliDate:()=>d,WEEK_EN:()=>h,WEEK_NP:()=>m,WEEK_SHORT_EN:()=>N,WEEK_SHORT_NP:()=>w});module.exports=B(G);var o=[{year:2e3,days:[30,32,31,32,31,30,30,30,29,30,29,31],totalDays:0,daysTillNow:0},{year:2001,days:[31,31,32,31,31,31,30,29,30,29,30,30],totalDays:0,daysTillNow:0},{year:2002,days:[31,31,32,32,31,30,30,29,30,29,30,30],totalDays:0,daysTillNow:0},{year:2003,days:[31,32,31,32,31,30,30,30,29,29,30,31],totalDays:0,daysTillNow:0},{year:2004,days:[30,32,31,32,31,30,30,30,29,30,29,31],totalDays:0,daysTillNow:0},{year:2005,days:[31,31,32,31,31,31,30,29,30,29,30,30],totalDays:0,daysTillNow:0},{year:2006,days:[31,31,32,32,31,30,30,29,30,29,30,30],totalDays:0,daysTillNow:0},{year:2007,days:[31,32,31,32,31,30,30,30,29,29,30,31],totalDays:0,daysTillNow:0},{year:2008,days:[31,31,31,32,31,31,29,30,30,29,29,31],totalDays:0,daysTillNow:0},{year:2009,days:[31,31,32,31,31,31,30,29,30,29,30,30],totalDays:0,daysTillNow:0},{year:2010,days:[31,31,32,32,31,30,30,29,30,29,30,30],totalDays:0,daysTillNow:0},{year:2011,days:[31,32,31,32,31,30,30,30,29,29,30,31],totalDays:0,daysTillNow:0},{year:2012,days:[31,31,31,32,31,31,29,30,30,29,30,30],totalDays:0,daysTillNow:0},{year:2013,days:[31,31,32,31,31,31,30,29,30,29,30,30],totalDays:0,daysTillNow:0},{year:2014,days:[31,31,32,32,31,30,30,29,30,29,30,30],totalDays:0,daysTillNow:0},{year:2015,days:[31,32,31,32,31,30,30,30,29,29,30,31],totalDays:0,daysTillNow:0},{year:2016,days:[31,31,31,32,31,31,29,30,30,29,30,30],totalDays:0,daysTillNow:0},{year:2017,days:[31,31,32,31,31,31,30,29,30,29,30,30],totalDays:0,daysTillNow:0},{year:2018,days:[31,32,31,32,31,30,30,29,30,29,30,30],totalDays:0,daysTillNow:0},{year:2019,days:[31,32,31,32,31,30,30,30,29,30,29,31],totalDays:0,daysTillNow:0},{year:2020,days:[31,31,31,32,31,31,30,29,30,29,30,30],totalDays:0,daysTillNow:0},{year:2021,days:[31,31,32,31,31,31,30,29,30,29,30,30],totalDays:0,daysTillNow:0},{year:2022,days:[31,32,31,32,31,30,30,30,29,29,30,30],totalDays:0,daysTillNow:0},{year:2023,days:[31,32,31,32,31,30,30,30,29,30,29,31],totalDays:0,daysTillNow:0},{year:2024,days:[31,31,31,32,31,31,30,29,30,29,30,30],totalDays:0,daysTillNow:0},{year:2025,days:[31,31,32,31,31,31,30,29,30,29,30,30],totalDays:0,daysTillNow:0},{year:2026,days:[31,32,31,32,31,30,30,30,29,29,30,31],totalDays:0,daysTillNow:0},{year:2027,days:[30,32,31,32,31,30,30,30,29,30,29,31],totalDays:0,daysTillNow:0},{year:2028,days:[31,31,32,31,31,31,30,29,30,29,30,30],totalDays:0,daysTillNow:0},{year:2029,days:[31,31,32,31,32,30,30,29,30,29,30,30],totalDays:0,daysTillNow:0},{year:2030,days:[31,32,31,32,31,30,30,30,29,29,30,31],totalDays:0,daysTillNow:0},{year:2031,days:[30,32,31,32,31,30,30,30,29,30,29,31],totalDays:0,daysTillNow:0},{year:2032,days:[31,31,32,31,31,31,30,29,30,29,30,30],totalDays:0,daysTillNow:0},{year:2033,days:[31,31,32,32,31,30,30,29,30,29,30,30],totalDays:0,daysTillNow:0},{year:2034,days:[31,32,31,32,31,30,30,30,29,29,30,31],totalDays:0,daysTillNow:0},{year:2035,days:[30,32,31,32,31,31,29,30,30,29,29,31],totalDays:0,daysTillNow:0},{year:2036,days:[31,31,32,31,31,31,30,29,30,29,30,30],totalDays:0,daysTillNow:0},{year:2037,days:[31,31,32,32,31,30,30,29,30,29,30,30],totalDays:0,daysTillNow:0},{year:2038,days:[31,32,31,32,31,30,30,30,29,29,30,31],totalDays:0,daysTillNow:0},{year:2039,days:[31,31,31,32,31,31,29,30,30,29,30,30],totalDays:0,daysTillNow:0},{year:2040,days:[31,31,32,31,31,31,30,29,30,29,30,30],totalDays:0,daysTillNow:0},{year:2041,days:[31,31,32,32,31,30,30,29,30,29,30,30],totalDays:0,daysTillNow:0},{year:2042,days:[31,32,31,32,31,30,30,30,29,29,30,31],totalDays:0,daysTillNow:0},{year:2043,days:[31,31,31,32,31,31,29,30,30,29,30,30],totalDays:0,daysTillNow:0},{year:2044,days:[31,31,32,31,31,31,30,29,30,29,30,30],totalDays:0,daysTillNow:0},{year:2045,days:[31,32,31,32,31,30,30,29,30,29,30,30],totalDays:0,daysTillNow:0},{year:2046,days:[31,32,31,32,31,30,30,30,29,29,30,31],totalDays:0,daysTillNow:0},{year:2047,days:[31,31,31,32,31,31,30,29,30,29,30,30],totalDays:0,daysTillNow:0},{year:2048,days:[31,31,32,31,31,31,30,29,30,29,30,30],totalDays:0,daysTillNow:0},{year:2049,days:[31,32,31,32,31,30,30,30,29,29,30,30],totalDays:0,daysTillNow:0},{year:2050,days:[31,32,31,32,31,30,30,30,29,30,29,31],totalDays:0,daysTillNow:0},{year:2051,days:[31,31,31,32,31,31,30,29,30,29,30,30],totalDays:0,daysTillNow:0},{year:2052,days:[31,31,32,31,31,31,30,29,30,29,30,30],totalDays:0,daysTillNow:0},{year:2053,days:[31,32,31,32,31,30,30,30,29,29,30,30],totalDays:0,daysTillNow:0},{year:2054,days:[31,32,31,32,31,30,30,30,29,30,29,31],totalDays:0,daysTillNow:0},{year:2055,days:[31,31,32,31,31,31,30,29,30,29,30,30],totalDays:0,daysTillNow:0},{year:2056,days:[31,31,32,31,32,30,30,29,30,29,30,30],totalDays:0,daysTillNow:0},{year:2057,days:[31,32,31,32,31,30,30,30,29,29,30,31],totalDays:0,daysTillNow:0},{year:2058,days:[30,32,31,32,31,30,30,30,29,30,29,31],totalDays:0,daysTillNow:0},{year:2059,days:[31,31,32,31,31,31,30,29,30,29,30,30],totalDays:0,daysTillNow:0},{year:2060,days:[31,31,32,32,31,30,30,29,30,29,30,30],totalDays:0,daysTillNow:0},{year:2061,days:[31,32,31,32,31,30,30,30,29,29,30,31],totalDays:0,daysTillNow:0},{year:2062,days:[30,32,31,32,31,31,29,30,29,30,29,31],totalDays:0,daysTillNow:0},{year:2063,days:[31,31,32,31,31,31,30,29,30,29,30,30],totalDays:0,daysTillNow:0},{year:2064,days:[31,31,32,32,31,30,30,29,30,29,30,30],totalDays:0,daysTillNow:0},{year:2065,days:[31,32,31,32,31,30,30,30,29,29,30,31],totalDays:0,daysTillNow:0},{year:2066,days:[31,31,31,32,31,31,29,30,30,29,29,31],totalDays:0,daysTillNow:0},{year:2067,days:[31,31,32,31,31,31,30,29,30,29,30,30],totalDays:0,daysTillNow:0},{year:2068,days:[31,31,32,32,31,30,30,29,30,29,30,30],totalDays:0,daysTillNow:0},{year:2069,days:[31,32,31,32,31,30,30,30,29,29,30,31],totalDays:0,daysTillNow:0},{year:2070,days:[31,31,31,32,31,31,29,30,30,29,30,30],totalDays:0,daysTillNow:0},{year:2071,days:[31,31,32,31,31,31,30,29,30,29,30,30],totalDays:0,daysTillNow:0},{year:2072,days:[31,32,31,32,31,30,30,29,30,29,30,30],totalDays:0,daysTillNow:0},{year:2073,days:[31,32,31,32,31,30,30,30,29,29,30,31],totalDays:0,daysTillNow:0},{year:2074,days:[31,31,31,32,31,31,30,29,30,29,30,30],totalDays:0,daysTillNow:0},{year:2075,days:[31,31,32,31,31,31,30,29,30,29,30,30],totalDays:0,daysTillNow:0},{year:2076,days:[31,32,31,32,31,30,30,30,29,29,30,30],totalDays:0,daysTillNow:0},{year:2077,days:[31,32,31,32,31,30,30,30,29,30,29,31],totalDays:0,daysTillNow:0},{year:2078,days:[31,31,31,32,31,31,30,29,30,29,30,30],totalDays:0,daysTillNow:0},{year:2079,days:[31,31,32,31,31,31,30,29,30,29,30,30],totalDays:0,daysTillNow:0},{year:2080,days:[31,32,31,32,31,30,30,30,29,29,30,30],totalDays:0,daysTillNow:0},{year:2081,days:[31,32,31,32,31,30,30,30,29,30,29,31],totalDays:0,daysTillNow:0},{year:2082,days:[31,31,31,32,31,31,30,29,30,29,30,30],totalDays:0,daysTillNow:0},{year:2083,days:[31,31,32,31,31,31,30,29,30,29,30,30],totalDays:0,daysTillNow:0},{year:2084,days:[31,32,31,32,31,30,30,30,29,29,30,31],totalDays:0,daysTillNow:0},{year:2085,days:[30,32,31,32,31,30,30,30,29,30,29,31],totalDays:0,daysTillNow:0},{year:2086,days:[31,31,32,31,31,31,30,29,30,29,30,30],totalDays:0,daysTillNow:0},{year:2087,days:[31,31,32,32,31,30,30,29,30,29,30,30],totalDays:0,daysTillNow:0},{year:2088,days:[31,32,31,32,31,30,30,30,29,29,30,31],totalDays:0,daysTillNow:0},{year:2089,days:[30,32,31,32,31,30,30,30,29,30,29,31],totalDays:0,daysTillNow:0},{year:2090,days:[31,31,32,31,31,31,30,29,30,29,30,30],totalDays:0,daysTillNow:0},{year:2091,days:[31,31,32,32,31,30,30,29,30,29,30,30],totalDays:0,daysTillNow:0},{year:2092,days:[31,32,31,32,31,30,30,30,29,29,30,31],totalDays:0,daysTillNow:0},{year:2093,days:[31,31,31,32,31,31,29,30,30,29,29,31],totalDays:0,daysTillNow:0},{year:2094,days:[31,31,32,31,31,31,30,29,30,29,30,30],totalDays:0,daysTillNow:0},{year:2095,days:[31,31,32,32,31,30,30,29,30,29,30,30],totalDays:0,daysTillNow:0},{year:2096,days:[31,32,31,32,31,30,30,30,29,29,30,31],totalDays:0,daysTillNow:0},{year:2097,days:[31,31,31,32,31,31,29,30,30,29,30,30],totalDays:0,daysTillNow:0},{year:2098,days:[31,31,32,31,31,31,30,29,30,29,30,30],totalDays:0,daysTillNow:0},{year:2099,days:[31,31,32,32,31,30,30,29,30,29,30,30],totalDays:0,daysTillNow:0},{year:2100,days:[31,32,31,32,31,30,30,30,29,29,30,31],totalDays:0,daysTillNow:0}],H=0;o.forEach(e=>{e.totalDays=e.days.reduce((t,a)=>t+a,0),H+=e.totalDays,e.daysTillNow=H});var b=new Date(1943,3,14).getTime(),h=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],N=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],m=["\u0906\u0907\u0924\u092C\u093E\u0930","\u0938\u094B\u092E\u092C\u093E\u0930","\u092E\u0902\u0917\u0932\u092C\u093E\u0930","\u092C\u0941\u0927\u092C\u093E\u0930","\u092C\u093F\u0939\u093F\u092C\u093E\u0930","\u0936\u0941\u0915\u094D\u0930\u092C\u093E\u0930","\u0936\u0928\u093F\u092C\u093E\u0930"],w=["\u0906\u0907\u0924","\u0938\u094B\u092E","\u092E\u0902\u0917\u0932","\u092C\u0941\u0927","\u092C\u093F\u0939\u093F","\u0936\u0941\u0915\u094D\u0930","\u0936\u0928\u093F"],c=["Baisakh","Jestha","Asar","Shrawan","Bhadra","Aswin","Kartik","Mangsir","Poush","Magh","Falgun","Chaitra"],p=["Bai","Jes","Asa","Shr","Bhd","Asw","Kar","Man","Pou","Mag","Fal","Cha"],T=["\u092C\u0948\u0936\u093E\u0916","\u091C\u0947\u0920","\u0905\u0938\u093E\u0930","\u0936\u094D\u0930\u093E\u0935\u0923","\u092D\u093E\u0926\u094D\u0930","\u0906\u0936\u094D\u0935\u093F\u0928","\u0915\u093E\u0930\u094D\u0924\u093F\u0915","\u092E\u0902\u0938\u093F\u0930","\u092A\u094C\u0937","\u092E\u093E\u0918","\u092B\u093E\u0932\u094D\u0917\u0941\u0923","\u091A\u0948\u0924\u094D\u0930"],f=["\u092C\u0948","\u091C\u0947","\u0905","\u0936\u094D\u0930\u093E","\u092D\u093E","\u0906","\u0915\u093E","\u092E\u0902","\u092A\u094C","\u092E\u093E","\u092B\u093E","\u091A\u0948"],M=["\u0966","\u0967","\u0968","\u0969","\u096A","\u096B","\u096C","\u096D","\u096E","\u096F"];function O(e){return e<10?`0${e}`:`${e}`}function u(e){let t="";for(let a=0;a<e.length;a+=1)t+=M[e.charCodeAt(a)-48];return t}function k(e){return t=>e<=2?String(t.getYear()).substring(2):e===3?String(t.getYear()).substring(1):String(t.getYear())}function L(e){return t=>e<=2?u(String(t.getYear()).substring(2)):u(e===3?String(t.getYear()).substring(1):String(t.getYear()))}function V(e){return t=>e===1?String(t.getMonth()+1):e===2?O(t.getMonth()+1):e===3?p[t.getMonth()]:c[t.getMonth()]}function q(e){return t=>e===1?u(String(t.getMonth()+1)):e===2?u(O(t.getMonth()+1)):e===3?f[t.getMonth()]:T[t.getMonth()]}function U(e){return t=>e===1?String(t.getDate()):e===2?O(t.getDate()):e===3?N[t.getDay()]:h[t.getDay()]}function j(e){return t=>e===1?u(String(t.getDate())):e===2?u(O(t.getDate())):e===3?w[t.getDay()]:m[t.getDay()]}function P(e){return()=>e}var I={Y:k,y:L,M:V,m:q,D:U,d:j};function J(e){return e in I}function Q(e){let t=!1,a="",r="",s=0,y=[];for(let i=0;i<e.length;i+=1){let l=e[i];if(l===r){s+=1;continue}if(r!==""&&(y.push(I[r](s)),r="",s=0),l==='"'){t=!t;continue}!J(l)||t?a+=l:(a&&(y.push(P(a)),a=""),r=l,s=1)}return a?y.push(P(a)):r&&y.push(I[r](s)),y}function x(e,t){return Q(t).map(a=>a(e)).join("")}function v(e){let t=e.split(/[-./]/,3),[a,r=0,s=1]=t.map(i=>{let l=parseInt(i,10);if(Number.isNaN(l))throw new Error("Invalid date");return l});if(a<o[0].year||a>=o[0].year+o.length)throw new Error("Nepal year out of range");if(r<0||r>11)throw new Error("Invalid nepali month must be between 0 - 11");let y=o[a-o[0].year].days[r-1];if(s<1||s>y)throw new Error(`Invalid nepali date must be between 1 - ${y} in ${a} ${r}`);return[a,r-1,s]}var d=class e{timestamp;year;month;day;constructor(...t){if(t.length===0)this.setEnglishDate(new Date);else if(t.length===1){let a=t[0];if(typeof a=="object")if(a instanceof Date)this.setEnglishDate(a);else if(a instanceof e)this.timestamp=a.timestamp,this.year=a.year,this.month=a.month,this.day=a.day;else throw new Error("Invalid date argument");else if(typeof a=="string")this.set(...v(a));else if(typeof a=="number")this.setEnglishDate(new Date(a));else throw new Error("Invalid date argument")}else if(t.length===3)this.set(t[0],t[1],t[2]);else throw new Error("Invalid argument syntax")}setEnglishDate(t){this.timestamp=t;let a=Math.floor((this.timestamp.getTime()-b)/864e5),r=Math.floor(a/366);for(;a>=o[r].daysTillNow;)r+=1;let s=o[r-1]?o[r-1].daysTillNow:0;a-=s;let y=o[r];for(this.year=y.year,this.month=0;a>=y.days[this.month];)this.month+=1,a-=y.days[this.month-1];this.day=a+1}getEnglishDate(){return this.timestamp}parse(t){this.set(...v(t))}getYear(){return this.year}getMonth(){return this.month}getDate(){return this.day}getDay(){return this.timestamp.getDay()}getHours(){return this.timestamp.getHours()}getMinutes(){return this.timestamp.getMinutes()}getSeconds(){return this.timestamp.getSeconds()}getMilliseconds(){return this.timestamp.getMilliseconds()}getTime(){return this.timestamp.getTime()}setYear(t){this.set(t,this.month,this.day)}setMonth(t){this.set(this.year,t,this.day)}setDate(t){this.set(this.year,this.month,t)}set(t,a,r){let s=t+Math.floor(a/12)-o[0].year,y=o[s],i=y.daysTillNow-y.totalDays,l=a%12,E=l<0?12+l:l;for(let n=0;n<E;n+=1)i+=y.days[n];i+=r-1,this.setEnglishDate(new Date(b+i*864e5))}format(t){return x(this,t)}toString(){return`${this.year}/${this.month+1}/${this.day}`}addDays(t){let a=new Date(this.timestamp.getTime()+t*864e5);return new e(a)}addMonths(t){let a=this.year,r=this.month+t;a+=Math.floor(r/12),r=r%12,r<0&&(r+=12,a-=1);let s=a-o[0].year;if(s<0||s>=o.length)throw new Error("Resulting date is out of supported range");let y=o[s].days[r],i=Math.min(this.day,y);return new e(a,r,i)}addYears(t){let a=this.year+t;if(a<o[0].year||a>=o[0].year+o.length)throw new Error("Resulting date is out of supported range");let r=a-o[0].year;if(this.month===11&&this.day===29){let s=o[r].days[11];if(s<29)return new e(a,11,s)}return new e(a,this.month,this.day)}static minimum(){return new Date(b)}static maximum(){return new Date(b+o[o.length-1].daysTillNow*864e5)}daysInMonth(){let t=this.year-o[0].year;return o[t].days[this.month]}isLeapYear(){let t=this.year-o[0].year;return o[t].totalDays===366}getWeeksInMonth(){let a=new e(this.year,this.month,1).getDay(),r=this.daysInMonth();return Math.ceil((a+r)/7)}diff(t,a){switch(a){case"day":return Math.floor((this.timestamp.getTime()-t.timestamp.getTime())/864e5);case"month":let r=this.year-t.year,s=this.month-t.month;return r*12+s;case"year":return this.year-t.year;default:throw new Error("Invalid unit for diff calculation")}}startOfDay(){let t=new Date(this.timestamp);return t.setHours(0,0,0,0),new e(t)}endOfDay(){let t=new Date(this.timestamp);return t.setHours(23,59,59,999),new e(t)}startOfMonth(){return new e(this.year,this.month,1)}endOfMonth(){let t=this.daysInMonth();return new e(this.year,this.month,t).endOfDay()}startOfYear(){return new e(this.year,0,1)}endOfYear(){let t=this.year-o[0].year,a=o[t].days[11];return new e(this.year,11,a).endOfDay()}static getMonthName(t,a=!1,r=!1){if(t<0||t>11)throw new Error("Invalid month index, must be between 0-11");let s="";return r?s=a?f[t]:T[t]:s=a?p[t]:c[t],s}static getDayName(t,a=!1,r=!1){if(t<0||t>6)throw new Error("Invalid day index, must be between 0-6");let s="";return r?s=a?w[t]:m[t]:s=a?N[t]:h[t],s}static isValid(t,a,r){try{if(t<o[0].year||t>=o[0].year+o.length||a<0||a>11)return!1;let s=t-o[0].year,y=o[s].days[a];return!(r<1||r>y)}catch{return!1}}isValid(){return e.isValid(this.year,this.month,this.day)}static getCalendarDays(t,a){if(!e.isValid(t,a,1))throw new Error("Invalid year or month");let r=[],s=t-o[0].year,i=new e(t,a,1).getDay(),l=o[s].days[a];if(i>0){let n=a-1,D=t;if(n<0&&(n=11,D--),D>=o[0].year){let g=D-o[0].year,R=o[g].days[n];for(let _=0;_<i;_++)r.push({date:R-i+_+1,isCurrentMonth:!1})}}for(let n=1;n<=l;n++)r.push({date:n,isCurrentMonth:!0});let E=42-r.length;if(E>0){let n=a+1,D=t;if(n>11&&(n=0,D++),D<o[0].year+o.length)for(let g=1;g<=E;g++)r.push({date:g,isCurrentMonth:!1})}return r}clone(){return new e(this)}isAfter(t){return this.timestamp.getTime()>t.timestamp.getTime()}isBefore(t){return this.timestamp.getTime()<t.timestamp.getTime()}isEqual(t){return this.year===t.year&&this.month===t.month&&this.day===t.day}isSame(t,a){switch(a){case"year":return this.year===t.year;case"month":return this.year===t.year&&this.month===t.month;case"day":return this.isEqual(t);default:throw new Error("Invalid unit for comparison")}}};var Y=e=>{if(!/^\d{4}-\d{2}-\d{2}$/.test(e))throw new Error("Invalid date format. Expected format: YYYY-MM-DD");let t=new Date(e);if(Number.isNaN(t.getTime()))throw new Error(`Invalid date input '${e}'`);try{return new d(t).format("YYYY-MM-DD")}catch(a){throw console.error("Error During Date Conversion : ",a),new Error("Failed to convert AD to BS")}};function A(e){try{if(!/^\d{4}-\d{2}-\d{2}$/.test(e))throw new Error("Invalid date format. Expected format: YYYY-MM-DD");let t=e?new d(e):new d,a=s=>s<10?`0${s}`:`${s}`,r=t.getEnglishDate();return`${r.getFullYear()}-${a(r.getMonth()+1)}-${a(r.getDate())}`}catch(t){throw console.error("Error During Date Conversion : ",t),new Error("Failed to convert BS to AD")}}0&&(module.exports={ADtoBS,BStoAD,MONTH_EN,MONTH_NP,MONTH_SHORT_EN,MONTH_SHORT_NP,NEPALI_DATE_MAP,NUMBER_NP,NepaliDate,WEEK_EN,WEEK_NP,WEEK_SHORT_EN,WEEK_SHORT_NP});
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { NEPALI_DATE_MAP, NUMBER_NP } from "./Helper/Constants";
|
|
2
|
+
export { WEEK_EN, WEEK_NP, WEEK_SHORT_EN, WEEK_SHORT_NP } from "./Helper/Constants";
|
|
3
|
+
export { MONTH_EN, MONTH_NP, MONTH_SHORT_EN, MONTH_SHORT_NP } from "./Helper/Constants";
|
|
4
|
+
export { ADtoBS, BStoAD } from "./Helper/DateConverter";
|
|
5
|
+
export { NepaliDate } from "./NepaliDate";
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var s=[{year:2e3,days:[30,32,31,32,31,30,30,30,29,30,29,31],totalDays:0,daysTillNow:0},{year:2001,days:[31,31,32,31,31,31,30,29,30,29,30,30],totalDays:0,daysTillNow:0},{year:2002,days:[31,31,32,32,31,30,30,29,30,29,30,30],totalDays:0,daysTillNow:0},{year:2003,days:[31,32,31,32,31,30,30,30,29,29,30,31],totalDays:0,daysTillNow:0},{year:2004,days:[30,32,31,32,31,30,30,30,29,30,29,31],totalDays:0,daysTillNow:0},{year:2005,days:[31,31,32,31,31,31,30,29,30,29,30,30],totalDays:0,daysTillNow:0},{year:2006,days:[31,31,32,32,31,30,30,29,30,29,30,30],totalDays:0,daysTillNow:0},{year:2007,days:[31,32,31,32,31,30,30,30,29,29,30,31],totalDays:0,daysTillNow:0},{year:2008,days:[31,31,31,32,31,31,29,30,30,29,29,31],totalDays:0,daysTillNow:0},{year:2009,days:[31,31,32,31,31,31,30,29,30,29,30,30],totalDays:0,daysTillNow:0},{year:2010,days:[31,31,32,32,31,30,30,29,30,29,30,30],totalDays:0,daysTillNow:0},{year:2011,days:[31,32,31,32,31,30,30,30,29,29,30,31],totalDays:0,daysTillNow:0},{year:2012,days:[31,31,31,32,31,31,29,30,30,29,30,30],totalDays:0,daysTillNow:0},{year:2013,days:[31,31,32,31,31,31,30,29,30,29,30,30],totalDays:0,daysTillNow:0},{year:2014,days:[31,31,32,32,31,30,30,29,30,29,30,30],totalDays:0,daysTillNow:0},{year:2015,days:[31,32,31,32,31,30,30,30,29,29,30,31],totalDays:0,daysTillNow:0},{year:2016,days:[31,31,31,32,31,31,29,30,30,29,30,30],totalDays:0,daysTillNow:0},{year:2017,days:[31,31,32,31,31,31,30,29,30,29,30,30],totalDays:0,daysTillNow:0},{year:2018,days:[31,32,31,32,31,30,30,29,30,29,30,30],totalDays:0,daysTillNow:0},{year:2019,days:[31,32,31,32,31,30,30,30,29,30,29,31],totalDays:0,daysTillNow:0},{year:2020,days:[31,31,31,32,31,31,30,29,30,29,30,30],totalDays:0,daysTillNow:0},{year:2021,days:[31,31,32,31,31,31,30,29,30,29,30,30],totalDays:0,daysTillNow:0},{year:2022,days:[31,32,31,32,31,30,30,30,29,29,30,30],totalDays:0,daysTillNow:0},{year:2023,days:[31,32,31,32,31,30,30,30,29,30,29,31],totalDays:0,daysTillNow:0},{year:2024,days:[31,31,31,32,31,31,30,29,30,29,30,30],totalDays:0,daysTillNow:0},{year:2025,days:[31,31,32,31,31,31,30,29,30,29,30,30],totalDays:0,daysTillNow:0},{year:2026,days:[31,32,31,32,31,30,30,30,29,29,30,31],totalDays:0,daysTillNow:0},{year:2027,days:[30,32,31,32,31,30,30,30,29,30,29,31],totalDays:0,daysTillNow:0},{year:2028,days:[31,31,32,31,31,31,30,29,30,29,30,30],totalDays:0,daysTillNow:0},{year:2029,days:[31,31,32,31,32,30,30,29,30,29,30,30],totalDays:0,daysTillNow:0},{year:2030,days:[31,32,31,32,31,30,30,30,29,29,30,31],totalDays:0,daysTillNow:0},{year:2031,days:[30,32,31,32,31,30,30,30,29,30,29,31],totalDays:0,daysTillNow:0},{year:2032,days:[31,31,32,31,31,31,30,29,30,29,30,30],totalDays:0,daysTillNow:0},{year:2033,days:[31,31,32,32,31,30,30,29,30,29,30,30],totalDays:0,daysTillNow:0},{year:2034,days:[31,32,31,32,31,30,30,30,29,29,30,31],totalDays:0,daysTillNow:0},{year:2035,days:[30,32,31,32,31,31,29,30,30,29,29,31],totalDays:0,daysTillNow:0},{year:2036,days:[31,31,32,31,31,31,30,29,30,29,30,30],totalDays:0,daysTillNow:0},{year:2037,days:[31,31,32,32,31,30,30,29,30,29,30,30],totalDays:0,daysTillNow:0},{year:2038,days:[31,32,31,32,31,30,30,30,29,29,30,31],totalDays:0,daysTillNow:0},{year:2039,days:[31,31,31,32,31,31,29,30,30,29,30,30],totalDays:0,daysTillNow:0},{year:2040,days:[31,31,32,31,31,31,30,29,30,29,30,30],totalDays:0,daysTillNow:0},{year:2041,days:[31,31,32,32,31,30,30,29,30,29,30,30],totalDays:0,daysTillNow:0},{year:2042,days:[31,32,31,32,31,30,30,30,29,29,30,31],totalDays:0,daysTillNow:0},{year:2043,days:[31,31,31,32,31,31,29,30,30,29,30,30],totalDays:0,daysTillNow:0},{year:2044,days:[31,31,32,31,31,31,30,29,30,29,30,30],totalDays:0,daysTillNow:0},{year:2045,days:[31,32,31,32,31,30,30,29,30,29,30,30],totalDays:0,daysTillNow:0},{year:2046,days:[31,32,31,32,31,30,30,30,29,29,30,31],totalDays:0,daysTillNow:0},{year:2047,days:[31,31,31,32,31,31,30,29,30,29,30,30],totalDays:0,daysTillNow:0},{year:2048,days:[31,31,32,31,31,31,30,29,30,29,30,30],totalDays:0,daysTillNow:0},{year:2049,days:[31,32,31,32,31,30,30,30,29,29,30,30],totalDays:0,daysTillNow:0},{year:2050,days:[31,32,31,32,31,30,30,30,29,30,29,31],totalDays:0,daysTillNow:0},{year:2051,days:[31,31,31,32,31,31,30,29,30,29,30,30],totalDays:0,daysTillNow:0},{year:2052,days:[31,31,32,31,31,31,30,29,30,29,30,30],totalDays:0,daysTillNow:0},{year:2053,days:[31,32,31,32,31,30,30,30,29,29,30,30],totalDays:0,daysTillNow:0},{year:2054,days:[31,32,31,32,31,30,30,30,29,30,29,31],totalDays:0,daysTillNow:0},{year:2055,days:[31,31,32,31,31,31,30,29,30,29,30,30],totalDays:0,daysTillNow:0},{year:2056,days:[31,31,32,31,32,30,30,29,30,29,30,30],totalDays:0,daysTillNow:0},{year:2057,days:[31,32,31,32,31,30,30,30,29,29,30,31],totalDays:0,daysTillNow:0},{year:2058,days:[30,32,31,32,31,30,30,30,29,30,29,31],totalDays:0,daysTillNow:0},{year:2059,days:[31,31,32,31,31,31,30,29,30,29,30,30],totalDays:0,daysTillNow:0},{year:2060,days:[31,31,32,32,31,30,30,29,30,29,30,30],totalDays:0,daysTillNow:0},{year:2061,days:[31,32,31,32,31,30,30,30,29,29,30,31],totalDays:0,daysTillNow:0},{year:2062,days:[30,32,31,32,31,31,29,30,29,30,29,31],totalDays:0,daysTillNow:0},{year:2063,days:[31,31,32,31,31,31,30,29,30,29,30,30],totalDays:0,daysTillNow:0},{year:2064,days:[31,31,32,32,31,30,30,29,30,29,30,30],totalDays:0,daysTillNow:0},{year:2065,days:[31,32,31,32,31,30,30,30,29,29,30,31],totalDays:0,daysTillNow:0},{year:2066,days:[31,31,31,32,31,31,29,30,30,29,29,31],totalDays:0,daysTillNow:0},{year:2067,days:[31,31,32,31,31,31,30,29,30,29,30,30],totalDays:0,daysTillNow:0},{year:2068,days:[31,31,32,32,31,30,30,29,30,29,30,30],totalDays:0,daysTillNow:0},{year:2069,days:[31,32,31,32,31,30,30,30,29,29,30,31],totalDays:0,daysTillNow:0},{year:2070,days:[31,31,31,32,31,31,29,30,30,29,30,30],totalDays:0,daysTillNow:0},{year:2071,days:[31,31,32,31,31,31,30,29,30,29,30,30],totalDays:0,daysTillNow:0},{year:2072,days:[31,32,31,32,31,30,30,29,30,29,30,30],totalDays:0,daysTillNow:0},{year:2073,days:[31,32,31,32,31,30,30,30,29,29,30,31],totalDays:0,daysTillNow:0},{year:2074,days:[31,31,31,32,31,31,30,29,30,29,30,30],totalDays:0,daysTillNow:0},{year:2075,days:[31,31,32,31,31,31,30,29,30,29,30,30],totalDays:0,daysTillNow:0},{year:2076,days:[31,32,31,32,31,30,30,30,29,29,30,30],totalDays:0,daysTillNow:0},{year:2077,days:[31,32,31,32,31,30,30,30,29,30,29,31],totalDays:0,daysTillNow:0},{year:2078,days:[31,31,31,32,31,31,30,29,30,29,30,30],totalDays:0,daysTillNow:0},{year:2079,days:[31,31,32,31,31,31,30,29,30,29,30,30],totalDays:0,daysTillNow:0},{year:2080,days:[31,32,31,32,31,30,30,30,29,29,30,30],totalDays:0,daysTillNow:0},{year:2081,days:[31,32,31,32,31,30,30,30,29,30,29,31],totalDays:0,daysTillNow:0},{year:2082,days:[31,31,31,32,31,31,30,29,30,29,30,30],totalDays:0,daysTillNow:0},{year:2083,days:[31,31,32,31,31,31,30,29,30,29,30,30],totalDays:0,daysTillNow:0},{year:2084,days:[31,32,31,32,31,30,30,30,29,29,30,31],totalDays:0,daysTillNow:0},{year:2085,days:[30,32,31,32,31,30,30,30,29,30,29,31],totalDays:0,daysTillNow:0},{year:2086,days:[31,31,32,31,31,31,30,29,30,29,30,30],totalDays:0,daysTillNow:0},{year:2087,days:[31,31,32,32,31,30,30,29,30,29,30,30],totalDays:0,daysTillNow:0},{year:2088,days:[31,32,31,32,31,30,30,30,29,29,30,31],totalDays:0,daysTillNow:0},{year:2089,days:[30,32,31,32,31,30,30,30,29,30,29,31],totalDays:0,daysTillNow:0},{year:2090,days:[31,31,32,31,31,31,30,29,30,29,30,30],totalDays:0,daysTillNow:0},{year:2091,days:[31,31,32,32,31,30,30,29,30,29,30,30],totalDays:0,daysTillNow:0},{year:2092,days:[31,32,31,32,31,30,30,30,29,29,30,31],totalDays:0,daysTillNow:0},{year:2093,days:[31,31,31,32,31,31,29,30,30,29,29,31],totalDays:0,daysTillNow:0},{year:2094,days:[31,31,32,31,31,31,30,29,30,29,30,30],totalDays:0,daysTillNow:0},{year:2095,days:[31,31,32,32,31,30,30,29,30,29,30,30],totalDays:0,daysTillNow:0},{year:2096,days:[31,32,31,32,31,30,30,30,29,29,30,31],totalDays:0,daysTillNow:0},{year:2097,days:[31,31,31,32,31,31,29,30,30,29,30,30],totalDays:0,daysTillNow:0},{year:2098,days:[31,31,32,31,31,31,30,29,30,29,30,30],totalDays:0,daysTillNow:0},{year:2099,days:[31,31,32,32,31,30,30,29,30,29,30,30],totalDays:0,daysTillNow:0},{year:2100,days:[31,32,31,32,31,30,30,30,29,29,30,31],totalDays:0,daysTillNow:0}],x=0;s.forEach(e=>{e.totalDays=e.days.reduce((t,a)=>t+a,0),x+=e.totalDays,e.daysTillNow=x});var N=new Date(1943,3,14).getTime(),m=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],w=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],c=["\u0906\u0907\u0924\u092C\u093E\u0930","\u0938\u094B\u092E\u092C\u093E\u0930","\u092E\u0902\u0917\u0932\u092C\u093E\u0930","\u092C\u0941\u0927\u092C\u093E\u0930","\u092C\u093F\u0939\u093F\u092C\u093E\u0930","\u0936\u0941\u0915\u094D\u0930\u092C\u093E\u0930","\u0936\u0928\u093F\u092C\u093E\u0930"],p=["\u0906\u0907\u0924","\u0938\u094B\u092E","\u092E\u0902\u0917\u0932","\u092C\u0941\u0927","\u092C\u093F\u0939\u093F","\u0936\u0941\u0915\u094D\u0930","\u0936\u0928\u093F"],T=["Baisakh","Jestha","Asar","Shrawan","Bhadra","Aswin","Kartik","Mangsir","Poush","Magh","Falgun","Chaitra"],f=["Bai","Jes","Asa","Shr","Bhd","Asw","Kar","Man","Pou","Mag","Fal","Cha"],g=["\u092C\u0948\u0936\u093E\u0916","\u091C\u0947\u0920","\u0905\u0938\u093E\u0930","\u0936\u094D\u0930\u093E\u0935\u0923","\u092D\u093E\u0926\u094D\u0930","\u0906\u0936\u094D\u0935\u093F\u0928","\u0915\u093E\u0930\u094D\u0924\u093F\u0915","\u092E\u0902\u0938\u093F\u0930","\u092A\u094C\u0937","\u092E\u093E\u0918","\u092B\u093E\u0932\u094D\u0917\u0941\u0923","\u091A\u0948\u0924\u094D\u0930"],b=["\u092C\u0948","\u091C\u0947","\u0905","\u0936\u094D\u0930\u093E","\u092D\u093E","\u0906","\u0915\u093E","\u092E\u0902","\u092A\u094C","\u092E\u093E","\u092B\u093E","\u091A\u0948"],_=["\u0966","\u0967","\u0968","\u0969","\u096A","\u096B","\u096C","\u096D","\u096E","\u096F"];function M(e){return e<10?`0${e}`:`${e}`}function d(e){let t="";for(let a=0;a<e.length;a+=1)t+=_[e.charCodeAt(a)-48];return t}function Y(e){return t=>e<=2?String(t.getYear()).substring(2):e===3?String(t.getYear()).substring(1):String(t.getYear())}function A(e){return t=>e<=2?d(String(t.getYear()).substring(2)):d(e===3?String(t.getYear()).substring(1):String(t.getYear()))}function R(e){return t=>e===1?String(t.getMonth()+1):e===2?M(t.getMonth()+1):e===3?f[t.getMonth()]:T[t.getMonth()]}function W(e){return t=>e===1?d(String(t.getMonth()+1)):e===2?d(M(t.getMonth()+1)):e===3?b[t.getMonth()]:g[t.getMonth()]}function F(e){return t=>e===1?String(t.getDate()):e===2?M(t.getDate()):e===3?w[t.getDay()]:m[t.getDay()]}function K(e){return t=>e===1?d(String(t.getDate())):e===2?d(M(t.getDate())):e===3?p[t.getDay()]:c[t.getDay()]}function H(e){return()=>e}var S={Y,y:A,M:R,m:W,D:F,d:K};function $(e){return e in S}function C(e){let t=!1,a="",r="",o=0,y=[];for(let i=0;i<e.length;i+=1){let l=e[i];if(l===r){o+=1;continue}if(r!==""&&(y.push(S[r](o)),r="",o=0),l==='"'){t=!t;continue}!$(l)||t?a+=l:(a&&(y.push(H(a)),a=""),r=l,o=1)}return a?y.push(H(a)):r&&y.push(S[r](o)),y}function I(e,t){return C(t).map(a=>a(e)).join("")}function P(e){let t=e.split(/[-./]/,3),[a,r=0,o=1]=t.map(i=>{let l=parseInt(i,10);if(Number.isNaN(l))throw new Error("Invalid date");return l});if(a<s[0].year||a>=s[0].year+s.length)throw new Error("Nepal year out of range");if(r<0||r>11)throw new Error("Invalid nepali month must be between 0 - 11");let y=s[a-s[0].year].days[r-1];if(o<1||o>y)throw new Error(`Invalid nepali date must be between 1 - ${y} in ${a} ${r}`);return[a,r-1,o]}var u=class e{timestamp;year;month;day;constructor(...t){if(t.length===0)this.setEnglishDate(new Date);else if(t.length===1){let a=t[0];if(typeof a=="object")if(a instanceof Date)this.setEnglishDate(a);else if(a instanceof e)this.timestamp=a.timestamp,this.year=a.year,this.month=a.month,this.day=a.day;else throw new Error("Invalid date argument");else if(typeof a=="string")this.set(...P(a));else if(typeof a=="number")this.setEnglishDate(new Date(a));else throw new Error("Invalid date argument")}else if(t.length===3)this.set(t[0],t[1],t[2]);else throw new Error("Invalid argument syntax")}setEnglishDate(t){this.timestamp=t;let a=Math.floor((this.timestamp.getTime()-N)/864e5),r=Math.floor(a/366);for(;a>=s[r].daysTillNow;)r+=1;let o=s[r-1]?s[r-1].daysTillNow:0;a-=o;let y=s[r];for(this.year=y.year,this.month=0;a>=y.days[this.month];)this.month+=1,a-=y.days[this.month-1];this.day=a+1}getEnglishDate(){return this.timestamp}parse(t){this.set(...P(t))}getYear(){return this.year}getMonth(){return this.month}getDate(){return this.day}getDay(){return this.timestamp.getDay()}getHours(){return this.timestamp.getHours()}getMinutes(){return this.timestamp.getMinutes()}getSeconds(){return this.timestamp.getSeconds()}getMilliseconds(){return this.timestamp.getMilliseconds()}getTime(){return this.timestamp.getTime()}setYear(t){this.set(t,this.month,this.day)}setMonth(t){this.set(this.year,t,this.day)}setDate(t){this.set(this.year,this.month,t)}set(t,a,r){let o=t+Math.floor(a/12)-s[0].year,y=s[o],i=y.daysTillNow-y.totalDays,l=a%12,E=l<0?12+l:l;for(let n=0;n<E;n+=1)i+=y.days[n];i+=r-1,this.setEnglishDate(new Date(N+i*864e5))}format(t){return I(this,t)}toString(){return`${this.year}/${this.month+1}/${this.day}`}addDays(t){let a=new Date(this.timestamp.getTime()+t*864e5);return new e(a)}addMonths(t){let a=this.year,r=this.month+t;a+=Math.floor(r/12),r=r%12,r<0&&(r+=12,a-=1);let o=a-s[0].year;if(o<0||o>=s.length)throw new Error("Resulting date is out of supported range");let y=s[o].days[r],i=Math.min(this.day,y);return new e(a,r,i)}addYears(t){let a=this.year+t;if(a<s[0].year||a>=s[0].year+s.length)throw new Error("Resulting date is out of supported range");let r=a-s[0].year;if(this.month===11&&this.day===29){let o=s[r].days[11];if(o<29)return new e(a,11,o)}return new e(a,this.month,this.day)}static minimum(){return new Date(N)}static maximum(){return new Date(N+s[s.length-1].daysTillNow*864e5)}daysInMonth(){let t=this.year-s[0].year;return s[t].days[this.month]}isLeapYear(){let t=this.year-s[0].year;return s[t].totalDays===366}getWeeksInMonth(){let a=new e(this.year,this.month,1).getDay(),r=this.daysInMonth();return Math.ceil((a+r)/7)}diff(t,a){switch(a){case"day":return Math.floor((this.timestamp.getTime()-t.timestamp.getTime())/864e5);case"month":let r=this.year-t.year,o=this.month-t.month;return r*12+o;case"year":return this.year-t.year;default:throw new Error("Invalid unit for diff calculation")}}startOfDay(){let t=new Date(this.timestamp);return t.setHours(0,0,0,0),new e(t)}endOfDay(){let t=new Date(this.timestamp);return t.setHours(23,59,59,999),new e(t)}startOfMonth(){return new e(this.year,this.month,1)}endOfMonth(){let t=this.daysInMonth();return new e(this.year,this.month,t).endOfDay()}startOfYear(){return new e(this.year,0,1)}endOfYear(){let t=this.year-s[0].year,a=s[t].days[11];return new e(this.year,11,a).endOfDay()}static getMonthName(t,a=!1,r=!1){if(t<0||t>11)throw new Error("Invalid month index, must be between 0-11");let o="";return r?o=a?b[t]:g[t]:o=a?f[t]:T[t],o}static getDayName(t,a=!1,r=!1){if(t<0||t>6)throw new Error("Invalid day index, must be between 0-6");let o="";return r?o=a?p[t]:c[t]:o=a?w[t]:m[t],o}static isValid(t,a,r){try{if(t<s[0].year||t>=s[0].year+s.length||a<0||a>11)return!1;let o=t-s[0].year,y=s[o].days[a];return!(r<1||r>y)}catch{return!1}}isValid(){return e.isValid(this.year,this.month,this.day)}static getCalendarDays(t,a){if(!e.isValid(t,a,1))throw new Error("Invalid year or month");let r=[],o=t-s[0].year,i=new e(t,a,1).getDay(),l=s[o].days[a];if(i>0){let n=a-1,D=t;if(n<0&&(n=11,D--),D>=s[0].year){let h=D-s[0].year,v=s[h].days[n];for(let O=0;O<i;O++)r.push({date:v-i+O+1,isCurrentMonth:!1})}}for(let n=1;n<=l;n++)r.push({date:n,isCurrentMonth:!0});let E=42-r.length;if(E>0){let n=a+1,D=t;if(n>11&&(n=0,D++),D<s[0].year+s.length)for(let h=1;h<=E;h++)r.push({date:h,isCurrentMonth:!1})}return r}clone(){return new e(this)}isAfter(t){return this.timestamp.getTime()>t.timestamp.getTime()}isBefore(t){return this.timestamp.getTime()<t.timestamp.getTime()}isEqual(t){return this.year===t.year&&this.month===t.month&&this.day===t.day}isSame(t,a){switch(a){case"year":return this.year===t.year;case"month":return this.year===t.year&&this.month===t.month;case"day":return this.isEqual(t);default:throw new Error("Invalid unit for comparison")}}};var B=e=>{if(!/^\d{4}-\d{2}-\d{2}$/.test(e))throw new Error("Invalid date format. Expected format: YYYY-MM-DD");let t=new Date(e);if(Number.isNaN(t.getTime()))throw new Error(`Invalid date input '${e}'`);try{return new u(t).format("YYYY-MM-DD")}catch(a){throw console.error("Error During Date Conversion : ",a),new Error("Failed to convert AD to BS")}};function k(e){try{if(!/^\d{4}-\d{2}-\d{2}$/.test(e))throw new Error("Invalid date format. Expected format: YYYY-MM-DD");let t=e?new u(e):new u,a=o=>o<10?`0${o}`:`${o}`,r=t.getEnglishDate();return`${r.getFullYear()}-${a(r.getMonth()+1)}-${a(r.getDate())}`}catch(t){throw console.error("Error During Date Conversion : ",t),new Error("Failed to convert BS to AD")}}export{B as ADtoBS,k as BStoAD,T as MONTH_EN,g as MONTH_NP,f as MONTH_SHORT_EN,b as MONTH_SHORT_NP,s as NEPALI_DATE_MAP,_ as NUMBER_NP,u as NepaliDate,m as WEEK_EN,c as WEEK_NP,w as WEEK_SHORT_EN,p as WEEK_SHORT_NP};
|
package/package.json
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "nepali-date-library",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"private": false,
|
|
5
|
+
"main": "dist/index.cjs",
|
|
6
|
+
"module": "dist/index.mjs",
|
|
7
|
+
"types": "dist/index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
"import": "./dist/index.mjs",
|
|
10
|
+
"require": "./dist/index.cjs",
|
|
11
|
+
"types": "./dist/index.d.ts"
|
|
12
|
+
},
|
|
13
|
+
"scripts": {
|
|
14
|
+
"build": "tsc --emitDeclarationOnly && esbuild src/index.ts --bundle --platform=node --format=cjs --minify --outfile=dist/index.cjs && esbuild src/index.ts --bundle --platform=node --format=esm --minify --outfile=dist/index.mjs"
|
|
15
|
+
},
|
|
16
|
+
"keywords": [],
|
|
17
|
+
"author": "",
|
|
18
|
+
"license": "ISC",
|
|
19
|
+
"description": "",
|
|
20
|
+
"devDependencies": {
|
|
21
|
+
"@types/node": "^22.13.5",
|
|
22
|
+
"esbuild": "^0.25.0",
|
|
23
|
+
"typescript": "^5.7.3"
|
|
24
|
+
}
|
|
25
|
+
}
|