@ultirequiem/leap-year 3.0.1 → 3.1.1

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/lib/index.d.ts CHANGED
@@ -19,4 +19,18 @@ export declare function isLeapYear(year?: Date | string | number, returnValue?:
19
19
  year: number;
20
20
  result: boolean;
21
21
  };
22
+ /**
23
+ * List every leap year in a range, both ends included.
24
+ *
25
+ * @param min - First year to check, defaults to `0`.
26
+ * @param max - Last year to check, defaults to the current year.
27
+ *
28
+ * @example
29
+ * ```javascript
30
+ * import { leapYearsInRange } from "@ultirequiem/leap-year";
31
+ *
32
+ * leapYearsInRange(2000, 2020); //=> [2000, 2004, 2008, 2012, 2016, 2020]
33
+ * ```
34
+ */
35
+ export declare function leapYearsInRange(min?: Date | string | number, max?: Date | string | number): number[];
22
36
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,UAAU,CAAC,IAAI,CAAC,EAAE,IAAI,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC;AACnE,wBAAgB,UAAU,CACxB,IAAI,CAAC,EAAE,IAAI,GAAG,MAAM,GAAG,MAAM,EAC7B,WAAW,CAAC,EAAE,OAAO,GACpB;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,OAAO,CAAA;CAAE,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,UAAU,CAAC,IAAI,CAAC,EAAE,IAAI,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC;AACnE,wBAAgB,UAAU,CACxB,IAAI,CAAC,EAAE,IAAI,GAAG,MAAM,GAAG,MAAM,EAC7B,WAAW,CAAC,EAAE,OAAO,GACpB;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,OAAO,CAAA;CAAE,CAAC;AAYrC;;;;;;;;;;;;GAYG;AACH,wBAAgB,gBAAgB,CAC9B,GAAG,GAAE,IAAI,GAAG,MAAM,GAAG,MAAU,EAC/B,GAAG,GAAE,IAAI,GAAG,MAAM,GAAG,MAAmB,GACvC,MAAM,EAAE,CAWV"}
package/lib/index.js CHANGED
@@ -4,3 +4,26 @@ export function isLeapYear(year = new Date(), returnValue = false) {
4
4
  const result = (year % 4 === 0 && year % 100 !== 0) || year % 400 === 0;
5
5
  return returnValue ? { result, year } : result;
6
6
  }
7
+ /**
8
+ * List every leap year in a range, both ends included.
9
+ *
10
+ * @param min - First year to check, defaults to `0`.
11
+ * @param max - Last year to check, defaults to the current year.
12
+ *
13
+ * @example
14
+ * ```javascript
15
+ * import { leapYearsInRange } from "@ultirequiem/leap-year";
16
+ *
17
+ * leapYearsInRange(2000, 2020); //=> [2000, 2004, 2008, 2012, 2016, 2020]
18
+ * ```
19
+ */
20
+ export function leapYearsInRange(min = 0, max = new Date()) {
21
+ const maxYear = parseDateLike(max);
22
+ const years = [];
23
+ for (let year = parseDateLike(min); year <= maxYear; year++) {
24
+ if (isLeapYear(year)) {
25
+ years.push(year);
26
+ }
27
+ }
28
+ return years;
29
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ultirequiem/leap-year",
3
- "version": "3.0.1",
3
+ "version": "3.1.1",
4
4
  "description": "Check whether a year is a leap year.",
5
5
  "type": "module",
6
6
  "main": "lib/index.js",
@@ -42,7 +42,7 @@
42
42
  "@vitest/coverage-v8": "^5.0.5",
43
43
  "eslint": "^10.13.0",
44
44
  "eslint-plugin-tsdoc": "^0.5.4",
45
- "eslint-plugin-unicorn": "^78.0.0",
45
+ "eslint-plugin-unicorn": "^79.0.0",
46
46
  "prettier": "^3.9.10",
47
47
  "typescript": "^6.0.3",
48
48
  "typescript-eslint": "^8.72.0",
package/readme.md CHANGED
@@ -1,12 +1,13 @@
1
1
  # leap-year
2
2
 
3
- Check if a year is a [leap year](https://en.wikipedia.org/wiki/Leap_year),
3
+ Check whether a year is a leap year.
4
4
 
5
5
  [![npm](https://img.shields.io/npm/v/@ultirequiem/leap-year?logo=npm&color=cb3837)](https://www.npmjs.com/package/@ultirequiem/leap-year)
6
6
  [![npm downloads](https://img.shields.io/npm/dm/@ultirequiem/leap-year?color=cb3837)](https://www.npmjs.com/package/@ultirequiem/leap-year)
7
7
  [![CI](https://github.com/UltiRequiem/leap-year/actions/workflows/ci.yaml/badge.svg)](https://github.com/UltiRequiem/leap-year/actions/workflows/ci.yaml)
8
8
  [![codecov](https://codecov.io/gh/UltiRequiem/leap-year/graph/badge.svg)](https://codecov.io/gh/UltiRequiem/leap-year)
9
9
 
10
+ Check if a year is a [leap year](https://en.wikipedia.org/wiki/Leap_year),
10
11
  that's a calendar year that contains an additional day added to keep the
11
12
  calendar year synchronized with the astronomical year or seasonal year.
12
13
 
@@ -25,16 +26,13 @@ isLeapYear(new Date(2016, 1, 1)); //=> true
25
26
  isLeapYear("13 December 400 00:07:00 GMT", true); //=> { year: 400, result: true }
26
27
  ```
27
28
 
28
- ## Related
29
-
30
- - [leap_year_utils](https://github.com/UltiRequiem/leap_year_utils): Utilities
31
- around this package.
29
+ List the leap years in a range (both ends included):
32
30
 
33
- - [parse_datelike](https://github.com/UltiRequiem/parse_datelike): Parse a
34
- number/string/date to a number/string/date.
31
+ ```javascript
32
+ import { leapYearsInRange } from "@ultirequiem/leap-year";
35
33
 
36
- - [leap-year-api](https://github.com/UltiRequiem/leap-year-api): A REST API to
37
- know if a year is leap or not.
34
+ leapYearsInRange(2000, 2020); //=> [2000, 2004, 2008, 2012, 2016, 2020]
35
+ ```
38
36
 
39
37
  ## Support
40
38