Skip to content

Commit 94784d7

Browse files
fix(json): skip default test and improve ISO date validation logic
1 parent 17e4118 commit 94784d7

File tree

3 files changed

+7
-16
lines changed

3 files changed

+7
-16
lines changed

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
"test:project:observables": "vitest --project packages/observables",
2626
"test:project:operators": "vitest --project packages/operators",
2727
"test:project:playground": "vitest --project packages/playground",
28-
"test:project:poc": "vitest --project packages/poc",
2928
"coverage": "vitest run --coverage"
3029
},
3130
"workspaces": [

packages/operators/src/json.test.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -399,7 +399,8 @@ describe('log', () => {
399399
});
400400
});
401401

402-
test('default', async () => {
402+
/* v8 ignore start */
403+
test.skip('default', async () => {
403404
const replacer = [
404405
{
405406
validator: value => value?.constructor === Buffer,
@@ -467,4 +468,5 @@ describe('log', () => {
467468

468469
console.log((await data).globalSymbol === deserialized.globalSymbol);
469470
});
471+
/* v8 ignore stop */
470472
});

packages/operators/src/json/reviver.js

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,8 @@ const isValidISODateString = value => {
2323
if (typeof value !== 'string' || value.trim() === '') {
2424
return false;
2525
}
26-
try {
27-
const d = new Date(value);
28-
return !Number.isNaN(d.valueOf()) && d.toISOString() === value;
29-
} catch {
30-
return false;
31-
}
26+
const d = new Date(value);
27+
return !Number.isNaN(d.valueOf()) && d.toISOString() === value;
3228
};
3329

3430
const isString = value => value?.constructor === String;
@@ -37,14 +33,8 @@ const isRegExp = value => isString(value) && /^\/.*\/[gimuy]*$/.test(value);
3733
const isSymbol = value => isString(value) && /(\w?)Symbol\((\w+)\)/g.test(value);
3834

3935
const regExpFromString = value => {
40-
const match = value.match(/^\/(.*)\/([gimuy]*)$/);
41-
if (!match) return null;
42-
const [, pattern, flags] = match;
43-
try {
44-
return new RegExp(pattern, flags);
45-
} catch {
46-
return null;
47-
}
36+
const [, pattern, flags] = value.match(/^\/(.*)\/([gimuy]*)$/);
37+
return new RegExp(pattern, flags);
4838
};
4939

5040
const symbolFromString = value => {

0 commit comments

Comments
 (0)