@ehmpathy/uni-time 1.6.1 → 1.7.0
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/dist/domain/UniDuration.d.ts +2 -3
- package/dist/domain/UniDuration.js +0 -19
- package/dist/domain/UniDuration.js.map +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/dist/logic/manipulate/addDuration.js +3 -3
- package/dist/logic/manipulate/addDuration.js.map +1 -1
- package/dist/logic/manipulate/getDuration.d.ts +22 -0
- package/dist/logic/manipulate/getDuration.js +62 -0
- package/dist/logic/manipulate/getDuration.js.map +1 -0
- package/dist/logic/manipulate/getDuration.test.d.ts +1 -0
- package/dist/logic/manipulate/getDuration.test.js +121 -0
- package/dist/logic/manipulate/getDuration.test.js.map +1 -0
- package/dist/logic/manipulate/subDuration.js +3 -3
- package/dist/logic/manipulate/subDuration.js.map +1 -1
- package/dist/logic/manipulate/toMilliseconds.d.ts +11 -0
- package/dist/logic/manipulate/toMilliseconds.js +26 -0
- package/dist/logic/manipulate/toMilliseconds.js.map +1 -0
- package/dist/logic/observe/stopwatch/startDurationStopwatch.js +2 -2
- package/dist/logic/observe/stopwatch/startDurationStopwatch.js.map +1 -1
- package/dist/logic/utils/sleep.js +2 -2
- package/dist/logic/utils/sleep.js.map +1 -1
- package/dist/logic/wrappers/waitFor.js +2 -2
- package/dist/logic/wrappers/waitFor.js.map +1 -1
- package/package.json +2 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { AsOfGlossary } from 'domain-glossaries';
|
|
2
|
-
import {
|
|
3
|
-
export type UniDuration = AsOfGlossary<
|
|
2
|
+
import { PickAny } from 'type-fns';
|
|
3
|
+
export type UniDuration = AsOfGlossary<PickAny<{
|
|
4
4
|
weeks: number;
|
|
5
5
|
days: number;
|
|
6
6
|
hours: number;
|
|
@@ -8,4 +8,3 @@ export type UniDuration = AsOfGlossary<PickOne<{
|
|
|
8
8
|
seconds: number;
|
|
9
9
|
milliseconds: number;
|
|
10
10
|
}>, 'uni-time', false>;
|
|
11
|
-
export declare const toMilliseconds: (duration: UniDuration) => number;
|
|
@@ -1,22 +1,3 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.toMilliseconds = void 0;
|
|
4
|
-
const error_fns_1 = require("@ehmpathy/error-fns");
|
|
5
|
-
const type_fns_1 = require("type-fns");
|
|
6
|
-
const toMilliseconds = (duration) => {
|
|
7
|
-
if ((0, type_fns_1.isPresent)(duration.weeks))
|
|
8
|
-
return duration.weeks * 7 * 24 * 60 * 60 * 1000;
|
|
9
|
-
if ((0, type_fns_1.isPresent)(duration.days))
|
|
10
|
-
return duration.days * 24 * 60 * 60 * 1000;
|
|
11
|
-
if ((0, type_fns_1.isPresent)(duration.hours))
|
|
12
|
-
return duration.hours * 60 * 60 * 1000;
|
|
13
|
-
if ((0, type_fns_1.isPresent)(duration.minutes))
|
|
14
|
-
return duration.minutes * 60 * 1000;
|
|
15
|
-
if ((0, type_fns_1.isPresent)(duration.seconds))
|
|
16
|
-
return duration.seconds * 1000;
|
|
17
|
-
if ((0, type_fns_1.isPresent)(duration.milliseconds))
|
|
18
|
-
return duration.milliseconds;
|
|
19
|
-
throw new error_fns_1.UnexpectedCodePathError('unsupported duration unit to convert to milliseconds', { duration });
|
|
20
|
-
};
|
|
21
|
-
exports.toMilliseconds = toMilliseconds;
|
|
22
3
|
//# sourceMappingURL=UniDuration.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UniDuration.js","sourceRoot":"","sources":["../../src/domain/UniDuration.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"UniDuration.js","sourceRoot":"","sources":["../../src/domain/UniDuration.ts"],"names":[],"mappings":""}
|
package/dist/index.d.ts
CHANGED
|
@@ -5,6 +5,8 @@ export * from './logic/checks/isUniDate';
|
|
|
5
5
|
export * from './logic/checks/isUniDateTime';
|
|
6
6
|
export * from './logic/casts/toMillisecondsSinceEpoch';
|
|
7
7
|
export * from './logic/manipulate/addDuration';
|
|
8
|
+
export * from './logic/manipulate/getDuration';
|
|
8
9
|
export * from './logic/manipulate/subDuration';
|
|
10
|
+
export * from './logic/manipulate/toMilliseconds';
|
|
9
11
|
export * from './logic/wrappers/waitFor';
|
|
10
12
|
export * from './logic/observe/stopwatch/startDurationStopwatch';
|
package/dist/index.js
CHANGED
|
@@ -21,7 +21,9 @@ __exportStar(require("./logic/checks/isUniDate"), exports);
|
|
|
21
21
|
__exportStar(require("./logic/checks/isUniDateTime"), exports);
|
|
22
22
|
__exportStar(require("./logic/casts/toMillisecondsSinceEpoch"), exports);
|
|
23
23
|
__exportStar(require("./logic/manipulate/addDuration"), exports);
|
|
24
|
+
__exportStar(require("./logic/manipulate/getDuration"), exports);
|
|
24
25
|
__exportStar(require("./logic/manipulate/subDuration"), exports);
|
|
26
|
+
__exportStar(require("./logic/manipulate/toMilliseconds"), exports);
|
|
25
27
|
__exportStar(require("./logic/wrappers/waitFor"), exports);
|
|
26
28
|
__exportStar(require("./logic/observe/stopwatch/startDurationStopwatch"), exports);
|
|
27
29
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,uDAAqC;AACrC,uDAAqC;AACrC,sDAAoC;AACpC,2DAAyC;AACzC,+DAA6C;AAC7C,yEAAuD;AACvD,iEAA+C;AAC/C,iEAA+C;AAC/C,2DAAyC;AACzC,mFAAiE"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,uDAAqC;AACrC,uDAAqC;AACrC,sDAAoC;AACpC,2DAAyC;AACzC,+DAA6C;AAC7C,yEAAuD;AACvD,iEAA+C;AAC/C,iEAA+C;AAC/C,iEAA+C;AAC/C,oEAAkD;AAClD,2DAAyC;AACzC,mFAAiE"}
|
|
@@ -2,14 +2,14 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.subDuration = void 0;
|
|
4
4
|
const date_fns_1 = require("date-fns");
|
|
5
|
-
const UniDuration_1 = require("../../domain/UniDuration");
|
|
6
5
|
const isUniDate_1 = require("../checks/isUniDate");
|
|
7
6
|
const isUniDateTime_1 = require("../checks/isUniDateTime");
|
|
7
|
+
const toMilliseconds_1 = require("./toMilliseconds");
|
|
8
8
|
/**
|
|
9
9
|
* subtract a duration from a datetime
|
|
10
10
|
*/
|
|
11
11
|
const subDuration = (...args) => (0, isUniDate_1.isUniDate)(args[0])
|
|
12
|
-
? (0, isUniDate_1.asUniDate)((0, date_fns_1.subMilliseconds)((0, date_fns_1.parseISO)(args[0]), (0,
|
|
13
|
-
: (0, isUniDateTime_1.asUniDateTime)((0, date_fns_1.subMilliseconds)((0, date_fns_1.parseISO)(args[0]), (0,
|
|
12
|
+
? (0, isUniDate_1.asUniDate)((0, date_fns_1.subMilliseconds)((0, date_fns_1.parseISO)(args[0]), (0, toMilliseconds_1.toMilliseconds)(args[1])))
|
|
13
|
+
: (0, isUniDateTime_1.asUniDateTime)((0, date_fns_1.subMilliseconds)((0, date_fns_1.parseISO)(args[0]), (0, toMilliseconds_1.toMilliseconds)(args[1])));
|
|
14
14
|
exports.subDuration = subDuration;
|
|
15
15
|
//# sourceMappingURL=addDuration.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"addDuration.js","sourceRoot":"","sources":["../../../src/logic/manipulate/addDuration.ts"],"names":[],"mappings":";;;AAAA,uCAAqD;
|
|
1
|
+
{"version":3,"file":"addDuration.js","sourceRoot":"","sources":["../../../src/logic/manipulate/addDuration.ts"],"names":[],"mappings":";;;AAAA,uCAAqD;AAKrD,mDAA2D;AAC3D,2DAAwD;AACxD,qDAAkD;AAElD;;GAEG;AACI,MAAM,WAAW,GAAG,CACzB,GAAG,IAEwD,EAC3D,EAAE,CACF,IAAA,qBAAS,EAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAChB,CAAC,CAAC,IAAA,qBAAS,EAAC,IAAA,0BAAe,EAAC,IAAA,mBAAQ,EAAC,IAAI,CAAC,CAAC,CAAC,CAAC,EAAE,IAAA,+BAAc,EAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IACxE,CAAC,CAAC,IAAA,6BAAa,EACX,IAAA,0BAAe,EAAC,IAAA,mBAAQ,EAAC,IAAI,CAAC,CAAC,CAAC,CAAC,EAAE,IAAA,+BAAc,EAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAC5D,CAAC;AATK,QAAA,WAAW,eAShB"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { PickOne } from 'type-fns';
|
|
2
|
+
import { UniDateTimeRange } from '../../domain/UniDateTime';
|
|
3
|
+
import { UniDuration } from '../../domain/UniDuration';
|
|
4
|
+
/**
|
|
5
|
+
* .what = calculates the duration of a time range
|
|
6
|
+
*/
|
|
7
|
+
export declare const getDuration: (input: {
|
|
8
|
+
/**
|
|
9
|
+
* what measure of time to extract a duration from
|
|
10
|
+
*/
|
|
11
|
+
of: PickOne<{
|
|
12
|
+
range: UniDateTimeRange;
|
|
13
|
+
milliseconds: number;
|
|
14
|
+
}>;
|
|
15
|
+
/**
|
|
16
|
+
* the unit to define the duration in, if desired
|
|
17
|
+
*
|
|
18
|
+
* note
|
|
19
|
+
* - by default, it will define it via all of them
|
|
20
|
+
*/
|
|
21
|
+
as?: keyof UniDuration;
|
|
22
|
+
}) => UniDuration;
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getDuration = void 0;
|
|
4
|
+
const error_fns_1 = require("@ehmpathy/error-fns");
|
|
5
|
+
const toMillisecondsSinceEpoch_1 = require("../casts/toMillisecondsSinceEpoch");
|
|
6
|
+
const toMilliseconds_1 = require("./toMilliseconds");
|
|
7
|
+
/**
|
|
8
|
+
* .what = calculates the duration of a time range
|
|
9
|
+
*/
|
|
10
|
+
const getDuration = (input) => {
|
|
11
|
+
// handle range inputs
|
|
12
|
+
if (input.of.range)
|
|
13
|
+
return (0, exports.getDuration)({
|
|
14
|
+
of: {
|
|
15
|
+
milliseconds: (0, toMillisecondsSinceEpoch_1.toMse)(input.of.range.until) - (0, toMillisecondsSinceEpoch_1.toMse)(input.of.range.since),
|
|
16
|
+
},
|
|
17
|
+
as: input.as,
|
|
18
|
+
});
|
|
19
|
+
// handle milliseconds
|
|
20
|
+
if (input.of.milliseconds) {
|
|
21
|
+
// if asked to define in a specific unit, define it in that unit
|
|
22
|
+
if (input.as) {
|
|
23
|
+
if (input.as === 'weeks')
|
|
24
|
+
return { weeks: input.of.milliseconds / toMilliseconds_1.MILLISECONDS_PER_WEEK };
|
|
25
|
+
if (input.as === 'days')
|
|
26
|
+
return { days: input.of.milliseconds / toMilliseconds_1.MILLISECONDS_PER_DAY };
|
|
27
|
+
if (input.as === 'hours')
|
|
28
|
+
return { hours: input.of.milliseconds / toMilliseconds_1.MILLISECONDS_PER_HOUR };
|
|
29
|
+
if (input.as === 'minutes')
|
|
30
|
+
return { minutes: input.of.milliseconds / toMilliseconds_1.MILLISECONDS_PER_MINUTE };
|
|
31
|
+
if (input.as === 'seconds')
|
|
32
|
+
return { seconds: input.of.milliseconds / toMilliseconds_1.MILLISECONDS_PER_SECOND };
|
|
33
|
+
if (input.as === 'milliseconds')
|
|
34
|
+
return { milliseconds: input.of.milliseconds };
|
|
35
|
+
throw new error_fns_1.UnexpectedCodePathError('input.as does not specify a valid unit', { input });
|
|
36
|
+
}
|
|
37
|
+
// otherwise, define it via all of the units
|
|
38
|
+
const weeks = Math.floor(input.of.milliseconds / toMilliseconds_1.MILLISECONDS_PER_WEEK);
|
|
39
|
+
const days = Math.floor((input.of.milliseconds % toMilliseconds_1.MILLISECONDS_PER_WEEK) / toMilliseconds_1.MILLISECONDS_PER_DAY);
|
|
40
|
+
const hours = Math.floor((input.of.milliseconds % toMilliseconds_1.MILLISECONDS_PER_DAY) / toMilliseconds_1.MILLISECONDS_PER_HOUR);
|
|
41
|
+
const minutes = Math.floor((input.of.milliseconds % toMilliseconds_1.MILLISECONDS_PER_HOUR) / toMilliseconds_1.MILLISECONDS_PER_MINUTE);
|
|
42
|
+
const seconds = Math.floor((input.of.milliseconds % toMilliseconds_1.MILLISECONDS_PER_MINUTE) /
|
|
43
|
+
toMilliseconds_1.MILLISECONDS_PER_SECOND);
|
|
44
|
+
const milliseconds = input.of.milliseconds % toMilliseconds_1.MILLISECONDS_PER_SECOND;
|
|
45
|
+
const durationWithRedundantZeros = {
|
|
46
|
+
weeks,
|
|
47
|
+
days,
|
|
48
|
+
hours,
|
|
49
|
+
minutes,
|
|
50
|
+
seconds,
|
|
51
|
+
milliseconds,
|
|
52
|
+
};
|
|
53
|
+
const duration = Object.fromEntries(Object.entries(durationWithRedundantZeros).filter(([key, val]) => val > 0));
|
|
54
|
+
return duration;
|
|
55
|
+
}
|
|
56
|
+
// otherwise, unsupported
|
|
57
|
+
throw new error_fns_1.UnexpectedCodePathError('input.of choice is not supported', {
|
|
58
|
+
input,
|
|
59
|
+
});
|
|
60
|
+
};
|
|
61
|
+
exports.getDuration = getDuration;
|
|
62
|
+
//# sourceMappingURL=getDuration.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getDuration.js","sourceRoot":"","sources":["../../../src/logic/manipulate/getDuration.ts"],"names":[],"mappings":";;;AAAA,mDAA8D;AAK9D,gFAA0D;AAC1D,qDAM0B;AAE1B;;GAEG;AACI,MAAM,WAAW,GAAG,CAAC,KAa3B,EAAe,EAAE;IAChB,sBAAsB;IACtB,IAAI,KAAK,CAAC,EAAE,CAAC,KAAK;QAChB,OAAO,IAAA,mBAAW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0,0 +1,121 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const test_fns_1 = require("test-fns");
|
|
4
|
+
const isUniDateTime_1 = require("../checks/isUniDateTime");
|
|
5
|
+
const getDuration_1 = require("./getDuration");
|
|
6
|
+
const toMilliseconds_1 = require("./toMilliseconds");
|
|
7
|
+
describe('getDuration', () => {
|
|
8
|
+
(0, test_fns_1.given)('milliseconds', () => {
|
|
9
|
+
(0, test_fns_1.when)('less than a second', () => {
|
|
10
|
+
(0, test_fns_1.then)('it should accurately define the duration', () => {
|
|
11
|
+
const duration = (0, getDuration_1.getDuration)({ of: { milliseconds: 69 } });
|
|
12
|
+
expect(duration).toEqual({ milliseconds: 69 });
|
|
13
|
+
});
|
|
14
|
+
});
|
|
15
|
+
(0, test_fns_1.when)('less than a minute', () => {
|
|
16
|
+
(0, test_fns_1.then)('it should accurately define the duration', () => {
|
|
17
|
+
const duration = (0, getDuration_1.getDuration)({ of: { milliseconds: 1069 } });
|
|
18
|
+
expect(duration).toEqual({ seconds: 1, milliseconds: 69 });
|
|
19
|
+
});
|
|
20
|
+
});
|
|
21
|
+
(0, test_fns_1.when)('less than an day', () => {
|
|
22
|
+
(0, test_fns_1.then)('it should accurately define the duration', () => {
|
|
23
|
+
const duration = (0, getDuration_1.getDuration)({
|
|
24
|
+
of: { milliseconds: 7 * toMilliseconds_1.MILLISECONDS_PER_HOUR + 1069 },
|
|
25
|
+
});
|
|
26
|
+
expect(duration).toEqual({ hours: 7, seconds: 1, milliseconds: 69 });
|
|
27
|
+
});
|
|
28
|
+
});
|
|
29
|
+
(0, test_fns_1.when)('less than a week', () => {
|
|
30
|
+
(0, test_fns_1.then)('it should accurately define the duration', () => {
|
|
31
|
+
const duration = (0, getDuration_1.getDuration)({
|
|
32
|
+
of: {
|
|
33
|
+
milliseconds: 3 * toMilliseconds_1.MILLISECONDS_PER_DAY + 7 * toMilliseconds_1.MILLISECONDS_PER_HOUR + 1069,
|
|
34
|
+
},
|
|
35
|
+
});
|
|
36
|
+
expect(duration).toEqual({
|
|
37
|
+
days: 3,
|
|
38
|
+
hours: 7,
|
|
39
|
+
seconds: 1,
|
|
40
|
+
milliseconds: 69,
|
|
41
|
+
});
|
|
42
|
+
});
|
|
43
|
+
});
|
|
44
|
+
(0, test_fns_1.when)('less than a month ', () => {
|
|
45
|
+
(0, test_fns_1.then)('it should accurately define the duration', () => {
|
|
46
|
+
const duration = (0, getDuration_1.getDuration)({
|
|
47
|
+
of: {
|
|
48
|
+
milliseconds: 5 * toMilliseconds_1.MILLISECONDS_PER_WEEK +
|
|
49
|
+
3 * toMilliseconds_1.MILLISECONDS_PER_DAY +
|
|
50
|
+
7 * toMilliseconds_1.MILLISECONDS_PER_HOUR +
|
|
51
|
+
1069,
|
|
52
|
+
},
|
|
53
|
+
});
|
|
54
|
+
expect(duration).toEqual({
|
|
55
|
+
weeks: 5,
|
|
56
|
+
days: 3,
|
|
57
|
+
hours: 7,
|
|
58
|
+
seconds: 1,
|
|
59
|
+
milliseconds: 69,
|
|
60
|
+
});
|
|
61
|
+
});
|
|
62
|
+
});
|
|
63
|
+
});
|
|
64
|
+
(0, test_fns_1.given)('range', () => {
|
|
65
|
+
(0, test_fns_1.when)('has parts of each time unit', () => {
|
|
66
|
+
(0, test_fns_1.then)('it should accurately define the duration', () => {
|
|
67
|
+
const duration = (0, getDuration_1.getDuration)({
|
|
68
|
+
of: {
|
|
69
|
+
range: {
|
|
70
|
+
since: (0, isUniDateTime_1.asUniDateTime)('2024-09-09T13:08:21.4269Z'),
|
|
71
|
+
until: (0, isUniDateTime_1.asUniDateTime)('2024-09-17T15:53:31.3157Z'),
|
|
72
|
+
},
|
|
73
|
+
},
|
|
74
|
+
});
|
|
75
|
+
expect(duration).toEqual({
|
|
76
|
+
weeks: 1,
|
|
77
|
+
days: 1,
|
|
78
|
+
hours: 2,
|
|
79
|
+
minutes: 45,
|
|
80
|
+
seconds: 9,
|
|
81
|
+
milliseconds: 889,
|
|
82
|
+
});
|
|
83
|
+
});
|
|
84
|
+
});
|
|
85
|
+
});
|
|
86
|
+
(0, test_fns_1.given)('a unit to get the duration in', () => {
|
|
87
|
+
(0, test_fns_1.when)('asked to define it in seconds', () => {
|
|
88
|
+
(0, test_fns_1.then)('it should accurately define the duration', () => {
|
|
89
|
+
const duration = (0, getDuration_1.getDuration)({
|
|
90
|
+
of: {
|
|
91
|
+
range: {
|
|
92
|
+
since: (0, isUniDateTime_1.asUniDateTime)('2024-09-09T13:08:21.4269Z'),
|
|
93
|
+
until: (0, isUniDateTime_1.asUniDateTime)('2024-09-17T15:53:31.3157Z'),
|
|
94
|
+
},
|
|
95
|
+
},
|
|
96
|
+
as: 'seconds',
|
|
97
|
+
});
|
|
98
|
+
expect(duration).toEqual({
|
|
99
|
+
seconds: 701109.889,
|
|
100
|
+
});
|
|
101
|
+
});
|
|
102
|
+
});
|
|
103
|
+
(0, test_fns_1.when)('asked to define it in seconds', () => {
|
|
104
|
+
(0, test_fns_1.then)('it should accurately define the duration', () => {
|
|
105
|
+
const duration = (0, getDuration_1.getDuration)({
|
|
106
|
+
of: {
|
|
107
|
+
range: {
|
|
108
|
+
since: (0, isUniDateTime_1.asUniDateTime)('2024-09-09T13:08:21.4269Z'),
|
|
109
|
+
until: (0, isUniDateTime_1.asUniDateTime)('2024-09-17T15:53:31.3157Z'),
|
|
110
|
+
},
|
|
111
|
+
},
|
|
112
|
+
as: 'minutes',
|
|
113
|
+
});
|
|
114
|
+
expect(duration).toEqual({
|
|
115
|
+
minutes: 11685.164816666667,
|
|
116
|
+
});
|
|
117
|
+
});
|
|
118
|
+
});
|
|
119
|
+
});
|
|
120
|
+
});
|
|
121
|
+
//# sourceMappingURL=getDuration.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getDuration.test.js","sourceRoot":"","sources":["../../../src/logic/manipulate/getDuration.test.ts"],"names":[],"mappings":";;AAAA,uCAA6C;AAE7C,2D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AAK,EAAE;4BACL,KAAK,EAAE,IAAA,6BAAa,EAAC,2BAA2B,CAAC;4BACjD,KAAK,EAAE,IAAA,6BAAa,EAAC,2BAA2B,CAAC;yBAClD;qBACF;oBACD,EAAE,EAAE,SAAS;iBACd,CAAC,CAAC;gBACH,MAAM,CAAC,QAAQ,CAAC,CAAC,OAAO,CAAC;oBACvB,OAAO,EAAE,kBAAkB;iBAC5B,CAAC,CAAC;YACL,CAAC,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -2,14 +2,14 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.addDuration = void 0;
|
|
4
4
|
const date_fns_1 = require("date-fns");
|
|
5
|
-
const UniDuration_1 = require("../../domain/UniDuration");
|
|
6
5
|
const isUniDate_1 = require("../checks/isUniDate");
|
|
7
6
|
const isUniDateTime_1 = require("../checks/isUniDateTime");
|
|
7
|
+
const toMilliseconds_1 = require("./toMilliseconds");
|
|
8
8
|
/**
|
|
9
9
|
* add a duration to a datetime
|
|
10
10
|
*/
|
|
11
11
|
const addDuration = (...args) => (0, isUniDate_1.isUniDate)(args[0])
|
|
12
|
-
? (0, isUniDate_1.asUniDate)((0, date_fns_1.addMilliseconds)((0, date_fns_1.parseISO)(args[0]), (0,
|
|
13
|
-
: (0, isUniDateTime_1.asUniDateTime)((0, date_fns_1.addMilliseconds)((0, date_fns_1.parseISO)(args[0]), (0,
|
|
12
|
+
? (0, isUniDate_1.asUniDate)((0, date_fns_1.addMilliseconds)((0, date_fns_1.parseISO)(args[0]), (0, toMilliseconds_1.toMilliseconds)(args[1])))
|
|
13
|
+
: (0, isUniDateTime_1.asUniDateTime)((0, date_fns_1.addMilliseconds)((0, date_fns_1.parseISO)(args[0]), (0, toMilliseconds_1.toMilliseconds)(args[1])));
|
|
14
14
|
exports.addDuration = addDuration;
|
|
15
15
|
//# sourceMappingURL=subDuration.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"subDuration.js","sourceRoot":"","sources":["../../../src/logic/manipulate/subDuration.ts"],"names":[],"mappings":";;;AAAA,uCAAqD;
|
|
1
|
+
{"version":3,"file":"subDuration.js","sourceRoot":"","sources":["../../../src/logic/manipulate/subDuration.ts"],"names":[],"mappings":";;;AAAA,uCAAqD;AAKrD,mDAA2D;AAC3D,2DAAwD;AACxD,qDAAkD;AAElD;;GAEG;AACI,MAAM,WAAW,GAAG,CACzB,GAAG,IAEwD,EAC3D,EAAE,CACF,IAAA,qBAAS,EAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAChB,CAAC,CAAC,IAAA,qBAAS,EAAC,IAAA,0BAAe,EAAC,IAAA,mBAAQ,EAAC,IAAI,CAAC,CAAC,CAAC,CAAC,EAAE,IAAA,+BAAc,EAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IACxE,CAAC,CAAC,IAAA,6BAAa,EACX,IAAA,0BAAe,EAAC,IAAA,mBAAQ,EAAC,IAAI,CAAC,CAAC,CAAC,CAAC,EAAE,IAAA,+BAAc,EAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAC5D,CAAC;AATK,QAAA,WAAW,eAShB"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { UniDuration } from '../../domain/UniDuration';
|
|
2
|
+
export declare const DAYS_PER_WEEK = 7;
|
|
3
|
+
export declare const HOURS_PER_DAY = 24;
|
|
4
|
+
export declare const MINUTES_PER_HOUR = 60;
|
|
5
|
+
export declare const SECONDS_PER_MINUTE = 60;
|
|
6
|
+
export declare const MILLISECONDS_PER_SECOND = 1000;
|
|
7
|
+
export declare const MILLISECONDS_PER_MINUTE: number;
|
|
8
|
+
export declare const MILLISECONDS_PER_HOUR: number;
|
|
9
|
+
export declare const MILLISECONDS_PER_DAY: number;
|
|
10
|
+
export declare const MILLISECONDS_PER_WEEK: number;
|
|
11
|
+
export declare const toMilliseconds: (duration: UniDuration) => number;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.toMilliseconds = exports.MILLISECONDS_PER_WEEK = exports.MILLISECONDS_PER_DAY = exports.MILLISECONDS_PER_HOUR = exports.MILLISECONDS_PER_MINUTE = exports.MILLISECONDS_PER_SECOND = exports.SECONDS_PER_MINUTE = exports.MINUTES_PER_HOUR = exports.HOURS_PER_DAY = exports.DAYS_PER_WEEK = void 0;
|
|
4
|
+
exports.DAYS_PER_WEEK = 7;
|
|
5
|
+
exports.HOURS_PER_DAY = 24;
|
|
6
|
+
exports.MINUTES_PER_HOUR = 60;
|
|
7
|
+
exports.SECONDS_PER_MINUTE = 60;
|
|
8
|
+
exports.MILLISECONDS_PER_SECOND = 1000;
|
|
9
|
+
exports.MILLISECONDS_PER_MINUTE = exports.MILLISECONDS_PER_SECOND * exports.SECONDS_PER_MINUTE;
|
|
10
|
+
exports.MILLISECONDS_PER_HOUR = exports.MILLISECONDS_PER_MINUTE * exports.MINUTES_PER_HOUR;
|
|
11
|
+
exports.MILLISECONDS_PER_DAY = exports.MILLISECONDS_PER_HOUR * exports.HOURS_PER_DAY;
|
|
12
|
+
exports.MILLISECONDS_PER_WEEK = exports.MILLISECONDS_PER_DAY * exports.DAYS_PER_WEEK;
|
|
13
|
+
const toMilliseconds = (duration) => {
|
|
14
|
+
var _a, _b, _c, _d, _e, _f;
|
|
15
|
+
const total = [
|
|
16
|
+
((_a = duration.weeks) !== null && _a !== void 0 ? _a : 0) * exports.MILLISECONDS_PER_WEEK,
|
|
17
|
+
((_b = duration.days) !== null && _b !== void 0 ? _b : 0) * exports.MILLISECONDS_PER_DAY,
|
|
18
|
+
((_c = duration.hours) !== null && _c !== void 0 ? _c : 0) * exports.MILLISECONDS_PER_HOUR,
|
|
19
|
+
((_d = duration.minutes) !== null && _d !== void 0 ? _d : 0) * exports.MILLISECONDS_PER_MINUTE,
|
|
20
|
+
((_e = duration.seconds) !== null && _e !== void 0 ? _e : 0) * exports.MILLISECONDS_PER_SECOND,
|
|
21
|
+
(_f = duration.milliseconds) !== null && _f !== void 0 ? _f : 0,
|
|
22
|
+
].reduce((totalNow, thisMilliseconds) => totalNow + thisMilliseconds, 0);
|
|
23
|
+
return total;
|
|
24
|
+
};
|
|
25
|
+
exports.toMilliseconds = toMilliseconds;
|
|
26
|
+
//# sourceMappingURL=toMilliseconds.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"toMilliseconds.js","sourceRoot":"","sources":["../../../src/logic/manipulate/toMilliseconds.ts"],"names":[],"mappings":";;;AAEa,QAAA,aAAa,GAAG,CAAC,CAAC;AAClB,QAAA,aAAa,GAAG,EAAE,CAAC;AACnB,QAAA,gBAAgB,GAAG,EAAE,CAAC;AACtB,QAAA,kBAAkB,GAAG,EAAE,CAAC;AACxB,QAAA,uBAAuB,GAAG,IAAI,CAAC;AAC/B,QAAA,uBAAuB,GAClC,+BAAuB,GAAG,0BAAkB,CAAC;AAClC,QAAA,qBAAqB,GAAG,+BAAuB,GAAG,wBAAgB,CAAC;AACnE,QAAA,oBAAoB,GAAG,6BAAqB,GAAG,qBAAa,CAAC;AAC7D,QAAA,qBAAqB,GAAG,4BAAoB,GAAG,qBAAa,CAAC;AAEnE,MAAM,cAAc,GAAG,CAAC,QAAqB,EAAU,EAAE;;IAC9D,MAAM,KAAK,GAAG;QACZ,CAAC,MAAA,QAAQ,CAAC,KAAK,mCAAI,CAAC,CAAC,GAAG,6BAAqB;QAC7C,CAAC,MAAA,QAAQ,CAAC,IAAI,mCAAI,CAAC,CAAC,GAAG,4BAAoB;QAC3C,CAAC,MAAA,QAAQ,CAAC,KAAK,mCAAI,CAAC,CAAC,GAAG,6BAAqB;QAC7C,CAAC,MAAA,QAAQ,CAAC,OAAO,mCAAI,CAAC,CAAC,GAAG,+BAAuB;QACjD,CAAC,MAAA,QAAQ,CAAC,OAAO,mCAAI,CAAC,CAAC,GAAG,+BAAuB;QACjD,MAAA,QAAQ,CAAC,YAAY,mCAAI,CAAC;KAC3B,CAAC,MAAM,CAAC,CAAC,QAAQ,EAAE,gBAAgB,EAAE,EAAE,CAAC,QAAQ,GAAG,gBAAgB,EAAE,CAAC,CAAC,CAAC;IACzE,OAAO,KAAK,CAAC;AACf,CAAC,CAAC;AAVW,QAAA,cAAc,kBAUzB"}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.startDurationStopwatch = void 0;
|
|
4
4
|
const process_1 = require("process");
|
|
5
|
-
const
|
|
5
|
+
const toMilliseconds_1 = require("../../manipulate/toMilliseconds");
|
|
6
6
|
const roundToHundredths = (num) => Math.round(num * 100) / 100; // https://stackoverflow.com/a/14968691/3068233
|
|
7
7
|
/**
|
|
8
8
|
* .what = a procedure which returns a duration stopwatch
|
|
@@ -28,7 +28,7 @@ const startDurationStopwatch = (input, context) => {
|
|
|
28
28
|
if (!canLog)
|
|
29
29
|
return output;
|
|
30
30
|
// determine if we should log, based on threshold
|
|
31
|
-
const durationThresholdInMilliseconds = (0,
|
|
31
|
+
const durationThresholdInMilliseconds = (0, toMilliseconds_1.toMilliseconds)(typeof logOptions === 'boolean' || !(logOptions === null || logOptions === void 0 ? void 0 : logOptions.threshold)
|
|
32
32
|
? { seconds: 1 }
|
|
33
33
|
: logOptions.threshold);
|
|
34
34
|
const durationThresholdWasBreached = durationThresholdInMilliseconds <= durationInMilliseconds;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"startDurationStopwatch.js","sourceRoot":"","sources":["../../../../src/logic/observe/stopwatch/startDurationStopwatch.ts"],"names":[],"mappings":";;;AAAA,qCAAiC;
|
|
1
|
+
{"version":3,"file":"startDurationStopwatch.js","sourceRoot":"","sources":["../../../../src/logic/observe/stopwatch/startDurationStopwatch.ts"],"names":[],"mappings":";;;AAAA,qCAAiC;AAKjC,o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;QACF,MAAM,4BAA4B,GAChC,+BAA+B,IAAI,sBAAsB,CAAC;QAC5D,IAAI,CAAC,4BAA4B;YAAE,OAAO,MAAM,CAAC;QAEjD,4DAA4D;QAC5D,MAAM,QAAQ,GACZ,OAAO,UAAU,KAAK,SAAS,IAAI,CAAC,CAAA,UAAU,aAAV,UAAU,uBAAV,UAAU,CAAE,KAAK,CAAA;YACnD,CAAC,CAAC,OAAO;YACT,CAAC,CAAC,UAAU,CAAC,KAAK,CAAC;QACvB,MAAM,iBAAiB,GAAG,iBAAiB,CACzC,MAAM,CAAC,qBAAqB,CAAC,GAAG,GAAG,CACpC,CAAC,CAAC,+CAA+C;QAClD,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,CACnB,GAAG,KAAK,SAAS,iBAAiB,qBAAqB,EACvD;YACE,GAAG,EAAE,KAAK;YACV,QAAQ,EAAE;gBACR,OAAO,EAAE,iBAAiB;gBAC1B,YAAY,EAAE,sBAAsB;aACrC;SACF,CACF,CAAC;QACF,OAAO,MAAM,CAAC;IAChB,CAAC,CAAC;IAEF,uBAAuB;IACvB,OAAO;QACL,sCAAsC;QACtC,IAAI;KACL,CAAC;AACJ,CAAC,CAAC;AA9DW,QAAA,sBAAsB,0BA8DjC"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.sleep = void 0;
|
|
4
|
-
const
|
|
5
|
-
const sleep = (ms) => new Promise((resolve) => setTimeout(resolve, typeof ms === 'number' ? ms : (0,
|
|
4
|
+
const toMilliseconds_1 = require("../manipulate/toMilliseconds");
|
|
5
|
+
const sleep = (ms) => new Promise((resolve) => setTimeout(resolve, typeof ms === 'number' ? ms : (0, toMilliseconds_1.toMilliseconds)(ms)));
|
|
6
6
|
exports.sleep = sleep;
|
|
7
7
|
//# sourceMappingURL=sleep.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sleep.js","sourceRoot":"","sources":["../../../src/logic/utils/sleep.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"sleep.js","sourceRoot":"","sources":["../../../src/logic/utils/sleep.ts"],"names":[],"mappings":";;;AACA,iEAA8D;AAEvD,MAAM,KAAK,GAAG,CAAC,EAAwB,EAAiB,EAAE,CAC/D,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE,CACtB,UAAU,CAAC,OAAO,EAAE,OAAO,EAAE,KAAK,QAAQ,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAA,+BAAc,EAAC,EAAE,CAAC,CAAC,CACtE,CAAC;AAHS,QAAA,KAAK,SAGd"}
|
|
@@ -12,7 +12,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
12
12
|
exports.waitFor = exports.WaitForTimedOutError = void 0;
|
|
13
13
|
const error_fns_1 = require("@ehmpathy/error-fns");
|
|
14
14
|
const type_fns_1 = require("type-fns");
|
|
15
|
-
const
|
|
15
|
+
const toMilliseconds_1 = require("../manipulate/toMilliseconds");
|
|
16
16
|
const sleep_1 = require("../utils/sleep");
|
|
17
17
|
const DEFAULT_TIMEOUT = { seconds: 60 };
|
|
18
18
|
const DEFAULT_INTERVAL = { seconds: 10 };
|
|
@@ -45,7 +45,7 @@ options) => __awaiter(void 0, void 0, void 0, function* () {
|
|
|
45
45
|
const interval = (_b = options === null || options === void 0 ? void 0 : options.interval) !== null && _b !== void 0 ? _b : DEFAULT_INTERVAL;
|
|
46
46
|
// track the timestamps of interest
|
|
47
47
|
const startAtMSE = new Date().getTime();
|
|
48
|
-
const timeoutAtMSE = startAtMSE + (0,
|
|
48
|
+
const timeoutAtMSE = startAtMSE + (0, toMilliseconds_1.toMilliseconds)(timeout);
|
|
49
49
|
// check each interval
|
|
50
50
|
while (new Date().getTime() < timeoutAtMSE) {
|
|
51
51
|
const output = yield extractor();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"waitFor.js","sourceRoot":"","sources":["../../../src/logic/wrappers/waitFor.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,mDAAmD;AACnD,uCAAwD;
|
|
1
|
+
{"version":3,"file":"waitFor.js","sourceRoot":"","sources":["../../../src/logic/wrappers/waitFor.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,mDAAmD;AACnD,uCAAwD;AAGxD,iEAA8D;AAC9D,0CAAuC;AAEvC,MAAM,eAAe,GAAgB,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC;AACrD,MAAM,gBAAgB,GAAgB,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC;AAEtD,MAAa,oBAAqB,SAAQ,wBAAY;CAAG;AAAzD,oDAAyD;AAEzD;;;;;;;GAOG;AACI,MAAM,OAAO,GAAG;AACrB;;;;;GAKG;AACH,SAA2B;AAE3B;;GAEG;AACH,OAUC,EACyB,EAAE;;IAC5B,kCAAkC;IAClC,MAAM,OAAO,GAAG,MAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,OAAO,mCAAI,eAAe,CAAC;IACpD,MAAM,QAAQ,GAAG,MAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,QAAQ,mCAAI,gBAAgB,CAAC;IAEvD,mCAAmC;IACnC,MAAM,UAAU,GAAW,IAAI,IAAI,EAAE,CAAC,OAAO,EAAE,CAAC;IAChD,MAAM,YAAY,GAAW,UAAU,GAAG,IAAA,+BAAc,EAAC,OAAO,CAAC,CAAC;IAElE,sBAAsB;IACtB,OAAO,IAAI,IAAI,EAAE,CAAC,OAAO,EAAE,GAAG,YAAY,EAAE,CAAC;QAC3C,MAAM,MAAM,GAAG,MAAM,SAAS,EAAE,CAAC;QACjC,IAAI,IAAA,yBAAc,EAAC,MAAM,CAAC;YAAE,OAAO,MAAM,CAAC;QAC1C,MAAM,IAAA,aAAK,EAAC,QAAQ,CAAC,CAAC;IACxB,CAAC;IAED,6DAA6D;IAC7D,MAAM,IAAI,oBAAoB,CAAC,2CAA2C,EAAE;QAC1E,QAAQ;QACR,OAAO;KACR,CAAC,CAAC;AACL,CAAC,CAAA,CAAC;AA5CW,QAAA,OAAO,WA4ClB"}
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@ehmpathy/uni-time",
|
|
3
3
|
"author": "ehmpathy",
|
|
4
4
|
"description": "a glossary of universally intuitive time, date, and duration domain literals",
|
|
5
|
-
"version": "1.
|
|
5
|
+
"version": "1.7.0",
|
|
6
6
|
"repository": "ehmpathy/uni-time",
|
|
7
7
|
"homepage": "https://github.com/ehmpathy/uni-time",
|
|
8
8
|
"keywords": [
|
|
@@ -54,6 +54,7 @@
|
|
|
54
54
|
"@ehmpathy/error-fns": "1.0.2",
|
|
55
55
|
"date-fns": "3.6.0",
|
|
56
56
|
"domain-glossaries": "1.0.0",
|
|
57
|
+
"test-fns": "1.5.0",
|
|
57
58
|
"type-fns": "1.19.0"
|
|
58
59
|
},
|
|
59
60
|
"devDependencies": {
|