chronokinesis 4.0.0 → 4.0.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/dist/chronokinesis.js +9 -19
- package/dist/index.es.js +9 -13
- package/index.js +8 -1
- package/package.json +10 -14
package/dist/chronokinesis.js
CHANGED
|
@@ -115,12 +115,6 @@ var chronokinesis = (function (exports) {
|
|
|
115
115
|
return typeof key === "symbol" ? key : String(key);
|
|
116
116
|
}
|
|
117
117
|
|
|
118
|
-
/**
|
|
119
|
-
* Inspired by Time keeper - EEasy testing of time-dependent code.
|
|
120
|
-
*
|
|
121
|
-
* Veselin Todorov <hi@vesln.com>
|
|
122
|
-
* MIT License.
|
|
123
|
-
*/
|
|
124
118
|
var NativeDate = Date;
|
|
125
119
|
var nativeGetTimezoneOffset = NativeDate.prototype.getTimezoneOffset;
|
|
126
120
|
var freezedAt = null;
|
|
@@ -168,6 +162,10 @@ var chronokinesis = (function (exports) {
|
|
|
168
162
|
args[_key2] = arguments[_key2];
|
|
169
163
|
}
|
|
170
164
|
freezedAt = instantiate(Date, args);
|
|
165
|
+
if (isNaN(freezedAt)) {
|
|
166
|
+
reset();
|
|
167
|
+
throw new TypeError('Chronokinesis cannot freeze to invalid date, check your arguments. Chronokinesis is reset');
|
|
168
|
+
}
|
|
171
169
|
return freezedAt;
|
|
172
170
|
}
|
|
173
171
|
function defrost() {
|
|
@@ -179,6 +177,10 @@ var chronokinesis = (function (exports) {
|
|
|
179
177
|
args[_key3] = arguments[_key3];
|
|
180
178
|
}
|
|
181
179
|
var travelToDate = instantiate(Date, args);
|
|
180
|
+
if (isNaN(travelToDate)) {
|
|
181
|
+
reset();
|
|
182
|
+
throw new TypeError('Chronokinesis cannot travel to invalid date, check your arguments. Chronokinesis is reset');
|
|
183
|
+
}
|
|
182
184
|
traveledTo = travelToDate.getTime();
|
|
183
185
|
started = NativeDate.now();
|
|
184
186
|
if (freezedAt) {
|
|
@@ -293,20 +295,8 @@ var chronokinesis = (function (exports) {
|
|
|
293
295
|
}
|
|
294
296
|
return NativeDate.UTC(year, month, day, hour, minute, second, dt.getMilliseconds());
|
|
295
297
|
}
|
|
296
|
-
var chronokinesis_1 = chronokinesis.freeze;
|
|
297
|
-
var chronokinesis_2 = chronokinesis.defrost;
|
|
298
|
-
var chronokinesis_3 = chronokinesis.travel;
|
|
299
|
-
var chronokinesis_4 = chronokinesis.reset;
|
|
300
|
-
var chronokinesis_5 = chronokinesis.isKeepingTime;
|
|
301
|
-
var chronokinesis_6 = chronokinesis.timezone;
|
|
302
298
|
|
|
303
|
-
exports
|
|
304
|
-
exports.defrost = chronokinesis_2;
|
|
305
|
-
exports.freeze = chronokinesis_1;
|
|
306
|
-
exports.isKeepingTime = chronokinesis_5;
|
|
307
|
-
exports.reset = chronokinesis_4;
|
|
308
|
-
exports.timezone = chronokinesis_6;
|
|
309
|
-
exports.travel = chronokinesis_3;
|
|
299
|
+
exports.default = chronokinesis;
|
|
310
300
|
|
|
311
301
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
312
302
|
|
package/dist/index.es.js
CHANGED
|
@@ -112,12 +112,6 @@ function _toPropertyKey(arg) {
|
|
|
112
112
|
return typeof key === "symbol" ? key : String(key);
|
|
113
113
|
}
|
|
114
114
|
|
|
115
|
-
/**
|
|
116
|
-
* Inspired by Time keeper - EEasy testing of time-dependent code.
|
|
117
|
-
*
|
|
118
|
-
* Veselin Todorov <hi@vesln.com>
|
|
119
|
-
* MIT License.
|
|
120
|
-
*/
|
|
121
115
|
var NativeDate = Date;
|
|
122
116
|
var nativeGetTimezoneOffset = NativeDate.prototype.getTimezoneOffset;
|
|
123
117
|
var freezedAt = null;
|
|
@@ -165,6 +159,10 @@ function freeze() {
|
|
|
165
159
|
args[_key2] = arguments[_key2];
|
|
166
160
|
}
|
|
167
161
|
freezedAt = instantiate(Date, args);
|
|
162
|
+
if (isNaN(freezedAt)) {
|
|
163
|
+
reset();
|
|
164
|
+
throw new TypeError('Chronokinesis cannot freeze to invalid date, check your arguments. Chronokinesis is reset');
|
|
165
|
+
}
|
|
168
166
|
return freezedAt;
|
|
169
167
|
}
|
|
170
168
|
function defrost() {
|
|
@@ -176,6 +174,10 @@ function travel() {
|
|
|
176
174
|
args[_key3] = arguments[_key3];
|
|
177
175
|
}
|
|
178
176
|
var travelToDate = instantiate(Date, args);
|
|
177
|
+
if (isNaN(travelToDate)) {
|
|
178
|
+
reset();
|
|
179
|
+
throw new TypeError('Chronokinesis cannot travel to invalid date, check your arguments. Chronokinesis is reset');
|
|
180
|
+
}
|
|
179
181
|
traveledTo = travelToDate.getTime();
|
|
180
182
|
started = NativeDate.now();
|
|
181
183
|
if (freezedAt) {
|
|
@@ -290,11 +292,5 @@ function toUTC(formatter, dt) {
|
|
|
290
292
|
}
|
|
291
293
|
return NativeDate.UTC(year, month, day, hour, minute, second, dt.getMilliseconds());
|
|
292
294
|
}
|
|
293
|
-
var chronokinesis_1 = chronokinesis.freeze;
|
|
294
|
-
var chronokinesis_2 = chronokinesis.defrost;
|
|
295
|
-
var chronokinesis_3 = chronokinesis.travel;
|
|
296
|
-
var chronokinesis_4 = chronokinesis.reset;
|
|
297
|
-
var chronokinesis_5 = chronokinesis.isKeepingTime;
|
|
298
|
-
var chronokinesis_6 = chronokinesis.timezone;
|
|
299
295
|
|
|
300
|
-
export { chronokinesis as default
|
|
296
|
+
export { chronokinesis as default };
|
package/index.js
CHANGED
|
@@ -59,6 +59,10 @@ module.exports = {
|
|
|
59
59
|
function freeze(...args) {
|
|
60
60
|
useFakeDate();
|
|
61
61
|
freezedAt = instantiate(Date, args);
|
|
62
|
+
if (isNaN(freezedAt)) {
|
|
63
|
+
reset();
|
|
64
|
+
throw new TypeError('Chronokinesis cannot freeze to invalid date, check your arguments. Chronokinesis is reset');
|
|
65
|
+
}
|
|
62
66
|
return freezedAt;
|
|
63
67
|
}
|
|
64
68
|
|
|
@@ -68,8 +72,11 @@ function defrost() {
|
|
|
68
72
|
|
|
69
73
|
function travel(...args) {
|
|
70
74
|
useFakeDate();
|
|
71
|
-
|
|
72
75
|
const travelToDate = instantiate(Date, args);
|
|
76
|
+
if (isNaN(travelToDate)) {
|
|
77
|
+
reset();
|
|
78
|
+
throw new TypeError('Chronokinesis cannot travel to invalid date, check your arguments. Chronokinesis is reset');
|
|
79
|
+
}
|
|
73
80
|
|
|
74
81
|
traveledTo = travelToDate.getTime();
|
|
75
82
|
started = NativeDate.now();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "chronokinesis",
|
|
3
|
-
"version": "4.0.
|
|
3
|
+
"version": "4.0.1",
|
|
4
4
|
"description": "Module for testing time-dependent code",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "Pål Edman",
|
|
@@ -14,22 +14,19 @@
|
|
|
14
14
|
"type": "git",
|
|
15
15
|
"url": "git://github.com/paed01/chronokinesis"
|
|
16
16
|
},
|
|
17
|
-
"engines": {
|
|
18
|
-
"node": ">=12"
|
|
19
|
-
},
|
|
20
17
|
"scripts": {
|
|
21
18
|
"toc": "node generate-api-toc.js",
|
|
22
19
|
"test": "mocha",
|
|
23
|
-
"
|
|
24
|
-
"test:lcov": "c8 -r lcov npm
|
|
25
|
-
"
|
|
20
|
+
"lint": "eslint . --cache",
|
|
21
|
+
"test:lcov": "c8 -r lcov mocha && npm run lint",
|
|
22
|
+
"posttest": "npm run lint && npm run dist",
|
|
23
|
+
"prepublishOnly": "npm run dist",
|
|
24
|
+
"dist": "npm run toc && rollup -c"
|
|
26
25
|
},
|
|
27
26
|
"files": [
|
|
28
27
|
"index.js",
|
|
29
28
|
"dist/chronokinesis.js",
|
|
30
|
-
"dist/index.es.js"
|
|
31
|
-
"LICENSE",
|
|
32
|
-
"README.md"
|
|
29
|
+
"dist/index.es.js"
|
|
33
30
|
],
|
|
34
31
|
"bugs": {
|
|
35
32
|
"url": "https://github.com/paed01/chronokinesis/issues"
|
|
@@ -49,16 +46,15 @@
|
|
|
49
46
|
"devDependencies": {
|
|
50
47
|
"@babel/core": "^7.12.3",
|
|
51
48
|
"@babel/preset-env": "^7.12.1",
|
|
49
|
+
"@rollup/plugin-babel": "^6.0.3",
|
|
50
|
+
"@rollup/plugin-commonjs": "^23.0.4",
|
|
52
51
|
"c8": "^7.12.0",
|
|
53
52
|
"chai": "^4.3.7",
|
|
54
|
-
"coveralls": "^3.1.0",
|
|
55
53
|
"eslint": "^8.29.0",
|
|
56
54
|
"lodash.clonedeep": "^4.5.0",
|
|
57
55
|
"markdown-toc": "^1.2.0",
|
|
58
56
|
"mocha": "^10.1.0",
|
|
59
57
|
"moment": "^2.29.1",
|
|
60
|
-
"rollup": "^
|
|
61
|
-
"rollup-plugin-babel": "^4.4.0",
|
|
62
|
-
"rollup-plugin-commonjs": "^10.1.0"
|
|
58
|
+
"rollup": "^3.7.0"
|
|
63
59
|
}
|
|
64
60
|
}
|