colombian-holidays 4.1.1 → 4.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +23 -2
- package/dist/utils/isHoliday.js +24 -0
- package/dist/utils/isHoliday.js.map +1 -0
- package/package.json +9 -4
- package/lib/utils/isHoliday.js +0 -16
- package/lib/utils/isHoliday.js.map +0 -1
- /package/{lib → dist}/helpers.d.ts +0 -0
- /package/{lib → dist}/helpers.js +0 -0
- /package/{lib → dist}/helpers.js.map +0 -0
- /package/{lib → dist}/holidays.d.ts +0 -0
- /package/{lib → dist}/holidays.js +0 -0
- /package/{lib → dist}/holidays.js.map +0 -0
- /package/{lib → dist}/index.d.ts +0 -0
- /package/{lib → dist}/index.js +0 -0
- /package/{lib → dist}/index.js.map +0 -0
- /package/{lib → dist}/types.d.ts +0 -0
- /package/{lib → dist}/types.js +0 -0
- /package/{lib → dist}/types.js.map +0 -0
- /package/{lib → dist}/utils/getHoliday.d.ts +0 -0
- /package/{lib → dist}/utils/getHoliday.js +0 -0
- /package/{lib → dist}/utils/getHoliday.js.map +0 -0
- /package/{lib → dist}/utils/helpers.d.ts +0 -0
- /package/{lib → dist}/utils/helpers.js +0 -0
- /package/{lib → dist}/utils/helpers.js.map +0 -0
- /package/{lib → dist}/utils/holidaysWithinInterval.d.ts +0 -0
- /package/{lib → dist}/utils/holidaysWithinInterval.js +0 -0
- /package/{lib → dist}/utils/holidaysWithinInterval.js.map +0 -0
- /package/{lib → dist}/utils/isHoliday.d.ts +0 -0
package/README.md
CHANGED
@@ -1,9 +1,10 @@
|
|
1
1
|
# Colombian Holidays 🎆
|
2
2
|
|
3
3
|
[](https://badge.fury.io/js/colombian-holidays)
|
4
|
-
[](https://github.com/MauricioRobayo/colombian-holidays/actions/workflows/build-and-release.yml)
|
5
5
|
[](https://codecov.io/gh/MauricioRobayo/colombian-holidays)
|
6
6
|
[](https://www.codefactor.io/repository/github/mauriciorobayo/colombian-holidays)
|
7
|
+
[](git@github.com:MauricioRobayo/colombian-holidays.git)
|
7
8
|
|
8
9
|
TypeScript module to calculate colombian holidays for any given year.
|
9
10
|
|
@@ -11,7 +12,7 @@ TypeScript module to calculate colombian holidays for any given year.
|
|
11
12
|
|
12
13
|
To install as a dependency of your project:
|
13
14
|
|
14
|
-
```
|
15
|
+
```sh
|
15
16
|
npm install colombian-holidays
|
16
17
|
```
|
17
18
|
|
@@ -39,6 +40,20 @@ You get a function that you can use to get the complete list of holidays for a g
|
|
39
40
|
const colombianHolidays2015 = colombianHolidays({ year: 2015 });
|
40
41
|
```
|
41
42
|
|
43
|
+
# Examples
|
44
|
+
|
45
|
+
Get current year holidays
|
46
|
+
|
47
|
+
```sh
|
48
|
+
npm run ts-node examples/currentDate
|
49
|
+
```
|
50
|
+
|
51
|
+
Get next year holidays
|
52
|
+
|
53
|
+
```sh
|
54
|
+
npm run ts-node examples/nextYear
|
55
|
+
```
|
56
|
+
|
42
57
|
The content of the `colombianHolidays2015` variable will be the following array:
|
43
58
|
|
44
59
|
```js
|
@@ -218,6 +233,12 @@ Returns:
|
|
218
233
|
];
|
219
234
|
```
|
220
235
|
|
236
|
+
Run the previous example
|
237
|
+
|
238
|
+
```sh
|
239
|
+
npm run ts-node examples/monthHolidays
|
240
|
+
```
|
241
|
+
|
221
242
|
You can opt-in to have the function return native JavaScript dates instead of strings for the `date` and `celebrationDate` properties by using the `valueAsDate` option:
|
222
243
|
|
223
244
|
```js
|
@@ -0,0 +1,24 @@
|
|
1
|
+
"use strict";
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
4
|
+
};
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
6
|
+
exports.isHoliday = void 0;
|
7
|
+
const __1 = __importDefault(require(".."));
|
8
|
+
const helpers_1 = require("./helpers");
|
9
|
+
const holidaysCache = new Map();
|
10
|
+
function isHoliday(date) {
|
11
|
+
const year = date.getUTCFullYear();
|
12
|
+
const cachedHolidays = holidaysCache.get(year);
|
13
|
+
if (cachedHolidays) {
|
14
|
+
return cachedHolidays.some(({ celebrationDate }) => (0, helpers_1.isSameDate)(celebrationDate, date));
|
15
|
+
}
|
16
|
+
const holidays = (0, __1.default)({
|
17
|
+
year,
|
18
|
+
valueAsDate: true,
|
19
|
+
});
|
20
|
+
holidaysCache.set(year, holidays);
|
21
|
+
return holidays.some(({ celebrationDate }) => (0, helpers_1.isSameDate)(celebrationDate, date));
|
22
|
+
}
|
23
|
+
exports.isHoliday = isHoliday;
|
24
|
+
//# sourceMappingURL=isHoliday.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"isHoliday.js","sourceRoot":"","sources":["../../src/utils/isHoliday.ts"],"names":[],"mappings":";;;;;;AAAA,2CAAmC;AAEnC,uCAAuC;AAEvC,MAAM,aAAa,GAAG,IAAI,GAAG,EAA4C,CAAC;AAE1E,SAAgB,SAAS,CAAC,IAAU;IAClC,MAAM,IAAI,GAAG,IAAI,CAAC,cAAc,EAAE,CAAC;IACnC,MAAM,cAAc,GAAG,aAAa,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;IAC/C,IAAI,cAAc,EAAE;QAClB,OAAO,cAAc,CAAC,IAAI,CAAC,CAAC,EAAE,eAAe,EAAE,EAAE,EAAE,CACjD,IAAA,oBAAU,EAAC,eAAe,EAAE,IAAI,CAAC,CAClC,CAAC;KACH;IACD,MAAM,QAAQ,GAAG,IAAA,WAAiB,EAAC;QACjC,IAAI;QACJ,WAAW,EAAE,IAAI;KAClB,CAAC,CAAC;IACH,aAAa,CAAC,GAAG,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;IAClC,OAAO,QAAQ,CAAC,IAAI,CAAC,CAAC,EAAE,eAAe,EAAE,EAAE,EAAE,CAC3C,IAAA,oBAAU,EAAC,eAAe,EAAE,IAAI,CAAC,CAClC,CAAC;AACJ,CAAC;AAhBD,8BAgBC"}
|
package/package.json
CHANGED
@@ -1,14 +1,15 @@
|
|
1
1
|
{
|
2
2
|
"name": "colombian-holidays",
|
3
|
-
"version": "4.
|
3
|
+
"version": "4.2.0",
|
4
4
|
"description": "Colombian holidays",
|
5
|
-
"main": "
|
5
|
+
"main": "dist/index.js",
|
6
6
|
"scripts": {
|
7
7
|
"format": "prettier --write .",
|
8
8
|
"lint": "eslint . --ext .ts --fix",
|
9
9
|
"test": "jest --coverage",
|
10
10
|
"build": "tsc",
|
11
|
-
"prepublishOnly": "tsc"
|
11
|
+
"prepublishOnly": "tsc",
|
12
|
+
"ts-node": "ts-node"
|
12
13
|
},
|
13
14
|
"license": "MIT",
|
14
15
|
"bugs": {
|
@@ -32,16 +33,20 @@
|
|
32
33
|
"prettier": "^2.6.2",
|
33
34
|
"timezone-mock": "^1.3.1",
|
34
35
|
"ts-jest": "^27.1.4",
|
36
|
+
"ts-node": "^10.9.1",
|
35
37
|
"typescript": "^4.6.4"
|
36
38
|
},
|
37
39
|
"dependencies": {
|
38
40
|
"pascua": "^2.1.5"
|
39
41
|
},
|
40
42
|
"files": [
|
41
|
-
"
|
43
|
+
"dist"
|
42
44
|
],
|
43
45
|
"repository": {
|
44
46
|
"type": "git",
|
45
47
|
"url": "https://github.com/MauricioRobayo/colombian-holidays.git"
|
48
|
+
},
|
49
|
+
"release": {
|
50
|
+
"branches": "main"
|
46
51
|
}
|
47
52
|
}
|
package/lib/utils/isHoliday.js
DELETED
@@ -1,16 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
4
|
-
};
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
6
|
-
exports.isHoliday = void 0;
|
7
|
-
const __1 = __importDefault(require(".."));
|
8
|
-
const helpers_1 = require("./helpers");
|
9
|
-
function isHoliday(date) {
|
10
|
-
return (0, __1.default)({
|
11
|
-
year: date.getUTCFullYear(),
|
12
|
-
valueAsDate: true,
|
13
|
-
}).some(({ celebrationDate }) => (0, helpers_1.isSameDate)(celebrationDate, date));
|
14
|
-
}
|
15
|
-
exports.isHoliday = isHoliday;
|
16
|
-
//# sourceMappingURL=isHoliday.js.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"isHoliday.js","sourceRoot":"","sources":["../../src/utils/isHoliday.ts"],"names":[],"mappings":";;;;;;AAAA,2CAAmC;AACnC,uCAAuC;AAEvC,SAAgB,SAAS,CAAC,IAAU;IAClC,OAAO,IAAA,WAAiB,EAAC;QACvB,IAAI,EAAE,IAAI,CAAC,cAAc,EAAE;QAC3B,WAAW,EAAE,IAAI;KAClB,CAAC,CAAC,IAAI,CAAC,CAAC,EAAE,eAAe,EAAE,EAAE,EAAE,CAAC,IAAA,oBAAU,EAAC,eAAe,EAAE,IAAI,CAAC,CAAC,CAAC;AACtE,CAAC;AALD,8BAKC"}
|
File without changes
|
/package/{lib → dist}/helpers.js
RENAMED
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
/package/{lib → dist}/index.d.ts
RENAMED
File without changes
|
/package/{lib → dist}/index.js
RENAMED
File without changes
|
File without changes
|
/package/{lib → dist}/types.d.ts
RENAMED
File without changes
|
/package/{lib → dist}/types.js
RENAMED
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|