Skip to content

Commit 1459da5

Browse files
authored
Merge pull request #13 from gammaaex/feature/create_declaration_file_for_typescript
Create declaration file for typescript
2 parents 5f22cb6 + 54bff3e commit 1459da5

3 files changed

Lines changed: 58 additions & 3 deletions

File tree

README.md

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,22 @@ In HTML
1616
<script src="./your/own/path/holiday_jp.js"></script>
1717
<script>
1818
var holidays = holiday_jp.between(new Date('2010-09-14'), new Date('2010-09-21'));
19-
console.log(holidays[0]['name']) // // 敬老の日
19+
console.log(holidays[0]['name']); // 敬老の日
2020
</script>
2121
```
2222

2323
In Node
2424

2525
```javascript
26-
var holiday_jp = require('holiday_jp');
26+
var holiday_jp = require('@holiday-jp/holiday_jp');
2727
var holidays = holiday_jp.between(new Date('2010-09-14'), new Date('2010-09-21'));
28-
console.log(holidays[0]['name']) // // 敬老の日
28+
console.log(holidays[0]['name']); // 敬老の日
29+
```
30+
31+
In TypeScript
32+
33+
```typescript
34+
import * as holiday_jp from '@holiday-jp/holiday_jp';
35+
const holidays = holiday_jp.between(new Date('2010-09-14'), new Date('2010-09-21'));
36+
console.log(holidays[0]['name']); // 敬老の日
2937
```

lib/holiday_jp.d.ts

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
/**
2+
* The type definition of a holiday
3+
* @see https://github.com/holiday-jp/holiday_jp-js/blob/master/lib/holidays.js
4+
*/
5+
export interface Holiday {
6+
/**
7+
* Expression of Date object
8+
*/
9+
date: Date;
10+
/**
11+
* Day of the week in Japanese
12+
*/
13+
week: string;
14+
/**
15+
* Day of the week in English
16+
*/
17+
week_en: string;
18+
/**
19+
* Holiday name in Japanese
20+
*/
21+
name: string;
22+
/**
23+
* Holiday name in English
24+
*/
25+
name_en: string;
26+
}
27+
28+
/**
29+
* The version of this package
30+
*/
31+
export const VERSION: string
32+
33+
/**
34+
* Find holidays between parameters
35+
* @param start Start date to find holiday
36+
* @param end End date to find holiday
37+
* @returns The holiday list between start and end, or empty if none
38+
*/
39+
export function between(start: Date, end: Date): Holiday[];
40+
41+
/**
42+
* Check if parameter is holiday
43+
* @param date A reference to be checked against holiday
44+
* @returns True if the provided reference is holiday otherwise false
45+
*/
46+
export function isHoliday(date: Date): boolean;

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
"version": "2.2.2",
44
"description": "Japanese holidays",
55
"main": "release/holiday_jp.js",
6+
"types": "lib/holiday_jp.d.ts",
67
"scripts": {
78
"test": "mocha --require should test/*.js",
89
"generate": "git submodule update; cd holiday_jp/; git fetch origin master; git reset --hard origin/master; cd ../; node scripts/generate.js",

0 commit comments

Comments
 (0)