@teamkeel/testing-runtime 0.404.1 → 0.405.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/package.json +1 -1
- package/src/Executor.mjs +32 -3
package/package.json
CHANGED
package/src/Executor.mjs
CHANGED
|
@@ -201,11 +201,40 @@ function isPlainObject(obj) {
|
|
|
201
201
|
return Object.prototype.toString.call(obj) === "[object Object]";
|
|
202
202
|
}
|
|
203
203
|
|
|
204
|
-
const dateFormat =
|
|
204
|
+
const dateFormat =
|
|
205
|
+
/^\d{4}-\d{2}-\d{2}(?:T\d{2}:\d{2}:\d{2}(?:\.\d+)?(?:Z|[+-]\d{2}:?\d{2})?)?$/;
|
|
205
206
|
|
|
206
207
|
function reviver(key, value) {
|
|
207
|
-
|
|
208
|
-
|
|
208
|
+
// Handle date strings
|
|
209
|
+
if (typeof value === "string") {
|
|
210
|
+
if (dateFormat.test(value)) {
|
|
211
|
+
return new Date(value);
|
|
212
|
+
}
|
|
209
213
|
}
|
|
214
|
+
|
|
215
|
+
// Handle nested objects
|
|
216
|
+
if (value !== null && typeof value === "object") {
|
|
217
|
+
// Handle arrays
|
|
218
|
+
if (Array.isArray(value)) {
|
|
219
|
+
return value.map((item) => {
|
|
220
|
+
if (typeof item === "string") {
|
|
221
|
+
if (dateFormat.test(item)) {
|
|
222
|
+
return new Date(item);
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
return item;
|
|
226
|
+
});
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
// Handle plain objects
|
|
230
|
+
for (const k in value) {
|
|
231
|
+
if (typeof value[k] === "string") {
|
|
232
|
+
if (dateFormat.test(value[k])) {
|
|
233
|
+
value[k] = new Date(value[k]);
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
|
|
210
239
|
return value;
|
|
211
240
|
}
|