moment-range
Advanced tools
Comparing version
@@ -10,2 +10,20 @@ # Moment Range | ||
## [4.0.2] | ||
### Added | ||
* Added TypeScript & flow types missing options argument for `add` method | ||
* Added overloaded TypeScript declarations allowing for calling `moment.range()` without arguments | ||
### Changed | ||
* Changed second parameter of `diff` & `duration` from `rounded` to `precise` to reflect the underlying moment method | ||
* Changed the `moment.range()` & `DateRange` `constructor` types to allow mixed `Date` & `Moment` parameters | ||
* Changed the `interval`/`unit` flow parameter types in the `by`, `diff`, `duration`, `reverseBy` & `snapTo` to include all strings allowed by moment | ||
* Changed internal TypeScript version to `3.3.3333` | ||
* Changed internal moment version to `2.24.0` | ||
* Changed CircleCI to version `2` | ||
### Fixed | ||
* Fixed the return type of `add` and `intersect` to `DateRange | null` as opposed to `DateRange | undefined` | ||
* Fixed the flow `toDate()` method return type from an array of `Date`s to a `Date` tuple | ||
* Fixed `extendMoment()` typescript declaration to give access to moment namespace variables, e.g. `moment.duration()`, `moment.HTML5_FMT` | ||
## [4.0.1] | ||
@@ -12,0 +30,0 @@ ### Fixed |
@@ -8,11 +8,10 @@ import * as moment from 'moment'; | ||
constructor(start: Date, end: Date); | ||
constructor(start: Moment, end: Moment); | ||
constructor(range: [Date, Date]); | ||
constructor(range: [Moment, Moment]); | ||
constructor(start: Date | Moment, end: Date | Moment); | ||
constructor(range: [Date | Moment, Date | Moment]); | ||
constructor(range: string); | ||
constructor(); | ||
adjacent(other: DateRange): boolean; | ||
add(other: DateRange): DateRange | undefined; | ||
add(other: DateRange, options?: { adjacent?: boolean }): DateRange | null; | ||
@@ -35,7 +34,7 @@ by(interval: unitOfTime.Diff, options?: { excludeEnd?: boolean; step?: number; }): Iterable<Moment>; | ||
diff(unit?: unitOfTime.Diff, rounded?: boolean): number; | ||
diff(unit?: unitOfTime.Diff, precise?: boolean): number; | ||
duration(unit?: unitOfTime.Diff, rounded?: boolean): number; | ||
duration(unit?: unitOfTime.Diff, precise?: boolean): number; | ||
intersect(other: DateRange): DateRange | undefined; | ||
intersect(other: DateRange): DateRange | null; | ||
@@ -68,7 +67,6 @@ isEqual(other: DateRange): boolean; | ||
export interface MomentRangeStaticMethods { | ||
range(start: Date, end: Date): DateRange; | ||
range(start: Moment, end: Moment): DateRange; | ||
range(range: [Date, Date]): DateRange; | ||
range(range: [Moment, Moment]): DateRange; | ||
range(start: Date | Moment, end: Date | Moment): DateRange; | ||
range(range: [Date | Moment, Date | Moment]): DateRange; | ||
range(range: string): DateRange; | ||
range(): DateRange; | ||
@@ -94,2 +92,2 @@ rangeFromInterval(interval: unitOfTime.Diff, count?: number, date?: Date | Moment): DateRange; | ||
export function extendMoment(momentClass: Moment | typeof moment): MomentRange & Moment; | ||
export function extendMoment(momentClass: typeof moment): MomentRange & typeof moment; |
@@ -30,3 +30,3 @@ { | ||
"main": "./dist/moment-range", | ||
"version": "4.0.1", | ||
"version": "4.0.2", | ||
"engines": { | ||
@@ -40,3 +40,3 @@ "node": "*" | ||
"build": "webpack -p", | ||
"check": "yarn run check:flow && yarn run check:typescript", | ||
"check": "yarn check:flow && yarn check:typescript", | ||
"check:flow": "flow", | ||
@@ -46,6 +46,6 @@ "check:typescript": "tsc --project ./typing-tests/typescript", | ||
"lint": "eslint ./lib/", | ||
"prepublishOnly": "yarn run build && cp ./lib/*.flow ./lib/*.d.ts ./dist", | ||
"preversion": "yarn run check && yarn run lint && yarn run test", | ||
"prepublishOnly": "yarn build && cp ./lib/*.flow ./lib/*.d.ts ./dist", | ||
"preversion": "yarn check && yarn lint && yarn test", | ||
"test": "karma start ./karma.conf.js", | ||
"version": "yarn run build && cp ./lib/*.flow ./lib/*.d.ts ./dist" | ||
"version": "yarn build && cp ./lib/*.flow ./lib/*.d.ts ./dist" | ||
}, | ||
@@ -61,3 +61,3 @@ "typings": "./dist/moment-range.d.ts", | ||
"babel-preset-stage-0": "^6.16.0", | ||
"doctoc": "^1.2.0", | ||
"doctoc": "^1.4.0", | ||
"eslint": "^3.11.1", | ||
@@ -76,4 +76,4 @@ "eslint-loader": "^1.6.1", | ||
"mocha": "^2.5.3", | ||
"moment": "^2.17.1", | ||
"typescript": "^2.6.2", | ||
"moment": "^2.24.0", | ||
"typescript": "^3.3.3333", | ||
"webpack": "^2.2.1" | ||
@@ -80,0 +80,0 @@ }, |
@@ -654,4 +654,4 @@ # moment-range [](https://circleci.com/gh/rotaready/moment-range) | ||
Optionally you may specify if the difference should be rounded, by default it | ||
mimics moment-js' behaviour and rounds the values: | ||
Optionally you may specify if the difference should not be truncated. By default it | ||
mimics moment-js' behaviour and truncates the values: | ||
@@ -665,3 +665,3 @@ ``` js | ||
range.diff('days', false) // 4 | ||
range.diff('days', true) // 4.5 | ||
range.diff('days', true) // 4.75 | ||
``` | ||
@@ -668,0 +668,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
130567
0.93%109
-1.8%1
Infinity%