@dereekb/util 9.24.30 → 9.24.31
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/CHANGELOG.md +4 -0
- package/fetch/CHANGELOG.md +4 -0
- package/fetch/package.json +2 -2
- package/package.json +1 -1
- package/src/lib/date/hour.d.ts +38 -0
- package/src/lib/date/hour.js +44 -0
- package/src/lib/date/hour.js.map +1 -0
- package/src/lib/date/index.d.ts +1 -0
- package/src/lib/date/index.js +1 -0
- package/src/lib/date/index.js.map +1 -1
- package/test/CHANGELOG.md +4 -0
- package/test/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,10 @@
|
|
|
2
2
|
|
|
3
3
|
This file was generated using [@jscutlery/semver](https://github.com/jscutlery/semver).
|
|
4
4
|
|
|
5
|
+
## [9.24.31](https://github.com/dereekb/dbx-components/compare/v9.24.30-dev...v9.24.31) (2023-08-17)
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
|
|
5
9
|
## [9.24.30](https://github.com/dereekb/dbx-components/compare/v9.24.29-dev...v9.24.30) (2023-08-16)
|
|
6
10
|
|
|
7
11
|
|
package/fetch/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,10 @@
|
|
|
2
2
|
|
|
3
3
|
This file was generated using [@jscutlery/semver](https://github.com/jscutlery/semver).
|
|
4
4
|
|
|
5
|
+
## [9.24.31](https://github.com/dereekb/dbx-components/compare/v9.24.30-dev...v9.24.31) (2023-08-17)
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
|
|
5
9
|
## [9.24.30](https://github.com/dereekb/dbx-components/compare/v9.24.29-dev...v9.24.30) (2023-08-16)
|
|
6
10
|
|
|
7
11
|
|
package/fetch/package.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dereekb/util/fetch",
|
|
3
|
-
"version": "9.24.
|
|
3
|
+
"version": "9.24.31",
|
|
4
4
|
"main": "./src/index.js",
|
|
5
5
|
"types": "./src/index.d.ts",
|
|
6
6
|
"dependencies": {},
|
|
7
7
|
"peerDependencies": {
|
|
8
|
-
"@dereekb/util": "9.24.
|
|
8
|
+
"@dereekb/util": "9.24.31",
|
|
9
9
|
"lodash.isequal": "^4.5.0",
|
|
10
10
|
"make-error": "^1.3.0",
|
|
11
11
|
"class-validator": "^0.13.2",
|
package/package.json
CHANGED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { Maybe } from '../value/maybe.type';
|
|
2
|
+
import { Hours, Minutes } from './date';
|
|
3
|
+
/**
|
|
4
|
+
* A number that represents hours and rounded to the nearest minute.
|
|
5
|
+
*
|
|
6
|
+
* It has only three decimal places max.
|
|
7
|
+
*
|
|
8
|
+
* Fractional hours are safe to add together.
|
|
9
|
+
*
|
|
10
|
+
* For example:
|
|
11
|
+
*
|
|
12
|
+
* - 10 minutes: 0.16
|
|
13
|
+
* - 15 minutes : 0.25
|
|
14
|
+
*/
|
|
15
|
+
export declare type FractionalHour = number;
|
|
16
|
+
export declare const FRACTIONAL_HOURS_PRECISION_FUNCTION: import("../number/round").CutValueToPrecisionFunction;
|
|
17
|
+
/**
|
|
18
|
+
* Converts the number of minnutes to a fractional hour.
|
|
19
|
+
*
|
|
20
|
+
* Minutes are rounded down.
|
|
21
|
+
*/
|
|
22
|
+
export declare function minutesToFractionalHours(minutes: Minutes): FractionalHour;
|
|
23
|
+
/**
|
|
24
|
+
* Converts the fractional hour to a minute.
|
|
25
|
+
*/
|
|
26
|
+
export declare function fractionalHoursToMinutes(hours: FractionalHour): Minutes;
|
|
27
|
+
/**
|
|
28
|
+
* Rounds the input hour to the nearest FractionalHour.
|
|
29
|
+
*
|
|
30
|
+
* @param hour
|
|
31
|
+
* @returns
|
|
32
|
+
*/
|
|
33
|
+
export declare function hourToFractionalHour(hour: Hours): FractionalHour;
|
|
34
|
+
export interface ComputeFractionalHour {
|
|
35
|
+
readonly minutes?: Maybe<Minutes>;
|
|
36
|
+
readonly hours?: Maybe<Hours>;
|
|
37
|
+
}
|
|
38
|
+
export declare function computeNextFractionalHour(input: FractionalHour, change: ComputeFractionalHour): FractionalHour;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.computeNextFractionalHour = exports.hourToFractionalHour = exports.fractionalHoursToMinutes = exports.minutesToFractionalHours = exports.FRACTIONAL_HOURS_PRECISION_FUNCTION = void 0;
|
|
4
|
+
const round_1 = require("../number/round");
|
|
5
|
+
const date_1 = require("./date");
|
|
6
|
+
exports.FRACTIONAL_HOURS_PRECISION_FUNCTION = (0, round_1.cutValueToPrecisionFunction)(3);
|
|
7
|
+
/**
|
|
8
|
+
* Converts the number of minnutes to a fractional hour.
|
|
9
|
+
*
|
|
10
|
+
* Minutes are rounded down.
|
|
11
|
+
*/
|
|
12
|
+
function minutesToFractionalHours(minutes) {
|
|
13
|
+
return (0, exports.FRACTIONAL_HOURS_PRECISION_FUNCTION)(Math.floor(minutes) / date_1.MINUTES_IN_HOUR);
|
|
14
|
+
}
|
|
15
|
+
exports.minutesToFractionalHours = minutesToFractionalHours;
|
|
16
|
+
/**
|
|
17
|
+
* Converts the fractional hour to a minute.
|
|
18
|
+
*/
|
|
19
|
+
function fractionalHoursToMinutes(hours) {
|
|
20
|
+
return Math.round(hours * date_1.MINUTES_IN_HOUR);
|
|
21
|
+
}
|
|
22
|
+
exports.fractionalHoursToMinutes = fractionalHoursToMinutes;
|
|
23
|
+
/**
|
|
24
|
+
* Rounds the input hour to the nearest FractionalHour.
|
|
25
|
+
*
|
|
26
|
+
* @param hour
|
|
27
|
+
* @returns
|
|
28
|
+
*/
|
|
29
|
+
function hourToFractionalHour(hour) {
|
|
30
|
+
return minutesToFractionalHours(fractionalHoursToMinutes(hour));
|
|
31
|
+
}
|
|
32
|
+
exports.hourToFractionalHour = hourToFractionalHour;
|
|
33
|
+
function computeNextFractionalHour(input, change) {
|
|
34
|
+
let result = input;
|
|
35
|
+
if (change.minutes) {
|
|
36
|
+
result += minutesToFractionalHours(change.minutes);
|
|
37
|
+
}
|
|
38
|
+
if (change.hours) {
|
|
39
|
+
result += hourToFractionalHour(change.hours);
|
|
40
|
+
}
|
|
41
|
+
return result;
|
|
42
|
+
}
|
|
43
|
+
exports.computeNextFractionalHour = computeNextFractionalHour;
|
|
44
|
+
//# sourceMappingURL=hour.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hour.js","sourceRoot":"","sources":["../../../../../../packages/util/src/lib/date/hour.ts"],"names":[],"mappings":";;;AAAA,2CAA8D;AAE9D,iCAAyD;AAgB5C,QAAA,mCAAmC,GAAG,IAAA,mCAA2B,EAAC,CAAC,CAAC,CAAC;AAElF;;;;GAIG;AACH,SAAgB,wBAAwB,CAAC,OAAgB;IACvD,OAAO,IAAA,2CAAmC,EAAC,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,GAAG,sBAAe,CAAC,CAAC;AACpF,CAAC;AAFD,4DAEC;AAED;;GAEG;AACH,SAAgB,wBAAwB,CAAC,KAAqB;IAC5D,OAAO,IAAI,CAAC,KAAK,CAAC,KAAK,GAAG,sBAAe,CAAC,CAAC;AAC7C,CAAC;AAFD,4DAEC;AAED;;;;;GAKG;AACH,SAAgB,oBAAoB,CAAC,IAAW;IAC9C,OAAO,wBAAwB,CAAC,wBAAwB,CAAC,IAAI,CAAC,CAAC,CAAC;AAClE,CAAC;AAFD,oDAEC;AAOD,SAAgB,yBAAyB,CAAC,KAAqB,EAAE,MAA6B;IAC5F,IAAI,MAAM,GAAG,KAAK,CAAC;IAEnB,IAAI,MAAM,CAAC,OAAO,EAAE;QAClB,MAAM,IAAI,wBAAwB,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;KACpD;IAED,IAAI,MAAM,CAAC,KAAK,EAAE;QAChB,MAAM,IAAI,oBAAoB,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;KAC9C;IAED,OAAO,MAAM,CAAC;AAChB,CAAC;AAZD,8DAYC"}
|
package/src/lib/date/index.d.ts
CHANGED
package/src/lib/date/index.js
CHANGED
|
@@ -3,5 +3,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
const tslib_1 = require("tslib");
|
|
4
4
|
tslib_1.__exportStar(require("./date"), exports);
|
|
5
5
|
tslib_1.__exportStar(require("./week"), exports);
|
|
6
|
+
tslib_1.__exportStar(require("./hour"), exports);
|
|
6
7
|
tslib_1.__exportStar(require("./date.time"), exports);
|
|
7
8
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../packages/util/src/lib/date/index.ts"],"names":[],"mappings":";;;AAAA,iDAAuB;AACvB,iDAAuB;AACvB,sDAA4B"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../packages/util/src/lib/date/index.ts"],"names":[],"mappings":";;;AAAA,iDAAuB;AACvB,iDAAuB;AACvB,iDAAuB;AACvB,sDAA4B"}
|
package/test/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,10 @@
|
|
|
2
2
|
|
|
3
3
|
This file was generated using [@jscutlery/semver](https://github.com/jscutlery/semver).
|
|
4
4
|
|
|
5
|
+
## [9.24.31](https://github.com/dereekb/dbx-components/compare/v9.24.30-dev...v9.24.31) (2023-08-17)
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
|
|
5
9
|
## [9.24.30](https://github.com/dereekb/dbx-components/compare/v9.24.29-dev...v9.24.30) (2023-08-16)
|
|
6
10
|
|
|
7
11
|
|
package/test/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dereekb/util/test",
|
|
3
|
-
"version": "9.24.
|
|
3
|
+
"version": "9.24.31",
|
|
4
4
|
"type": "commonjs",
|
|
5
5
|
"main": "./src/index.js",
|
|
6
6
|
"types": "./src/index.d.ts",
|
|
7
7
|
"dependencies": {},
|
|
8
8
|
"peerDependencies": {
|
|
9
|
-
"@dereekb/util": "9.24.
|
|
9
|
+
"@dereekb/util": "9.24.31",
|
|
10
10
|
"lodash.isequal": "^4.5.0",
|
|
11
11
|
"make-error": "^1.3.0",
|
|
12
12
|
"class-validator": "^0.13.2",
|