Comparing version 3.0.0 to 4.0.0
@@ -1,15 +0,13 @@ | ||
declare namespace monthDays { | ||
interface Options { | ||
/** | ||
Note that the month is zero-index to be consistent with the native date methods. | ||
export interface Options { | ||
/** | ||
Note that the month is zero-index to be consistent with the native date methods. | ||
@default (new Date()).getUTCMonth() | ||
*/ | ||
readonly month?: number; | ||
@default (new Date()).getUTCMonth() | ||
*/ | ||
readonly month?: number; | ||
/** | ||
@default (new Date).getUTCFullYear() | ||
*/ | ||
readonly year?: number; | ||
} | ||
/** | ||
@default (new Date).getUTCFullYear() | ||
*/ | ||
readonly year?: number; | ||
} | ||
@@ -22,3 +20,3 @@ | ||
``` | ||
import monthDays = require('month-days'); | ||
import monthDays from 'month-days'; | ||
@@ -29,4 +27,2 @@ monthDays({month: 1, year: 2016}); | ||
*/ | ||
declare function monthDays(options?: monthDays.Options): number; | ||
export = monthDays; | ||
export default function monthDays(options?: Options): number; |
@@ -1,5 +0,4 @@ | ||
'use strict'; | ||
const isDefined = value => value !== undefined; | ||
module.exports = ({month, year} = {}) => { | ||
export default function monthDays({month, year} = {}) { | ||
if (isDefined(month) && typeof month !== 'number') { | ||
@@ -18,2 +17,2 @@ throw new TypeError(`Expected \`month\` to be of type \`number\`, got \`${typeof month}\``); | ||
return new Date(Date.UTC(year, month + 1, 0)).getUTCDate(); | ||
}; | ||
} |
{ | ||
"name": "month-days", | ||
"version": "3.0.0", | ||
"version": "4.0.0", | ||
"description": "Get the number of days in a month", | ||
"license": "MIT", | ||
"repository": "sindresorhus/month-days", | ||
"funding": "https://github.com/sponsors/sindresorhus", | ||
"author": { | ||
"name": "Sindre Sorhus", | ||
"email": "sindresorhus@gmail.com", | ||
"url": "sindresorhus.com" | ||
"url": "https://sindresorhus.com" | ||
}, | ||
"type": "module", | ||
"exports": "./index.js", | ||
"engines": { | ||
"node": ">=8" | ||
"node": "^12.20.0 || ^14.13.1 || >=16.0.0" | ||
}, | ||
@@ -32,6 +35,6 @@ "scripts": { | ||
"devDependencies": { | ||
"ava": "^1.4.1", | ||
"tsd": "^0.7.2", | ||
"xo": "^0.24.0" | ||
"ava": "^3.15.0", | ||
"tsd": "^0.18.0", | ||
"xo": "^0.45.0" | ||
} | ||
} |
@@ -1,17 +0,15 @@ | ||
# month-days [](https://travis-ci.org/sindresorhus/month-days) | ||
# month-days | ||
> Get the number of days in a month | ||
## Install | ||
```sh | ||
npm install month-days | ||
``` | ||
$ npm install month-days | ||
``` | ||
## Usage | ||
```js | ||
const monthDays = require('month-days'); | ||
import monthDays from 'month-days'; | ||
@@ -22,6 +20,5 @@ monthDays({month: 1, year: 2016}); | ||
## API | ||
### monthDays([options]) | ||
### monthDays(options?) | ||
@@ -34,3 +31,3 @@ #### options | ||
Type: `number`<br> | ||
Type: `number`\ | ||
Default: Current UTC month | ||
@@ -42,8 +39,3 @@ | ||
Type: `number`<br> | ||
Type: `number`\ | ||
Default: Current UTC year | ||
## License | ||
MIT © [Sindre Sorhus](https://sindresorhus.com) |
Sorry, the diff of this file is not supported yet
Yes
3346
34
39