Skip to content
This repository was archived by the owner on Jun 21, 2023. It is now read-only.

Commit ce0a0c2

Browse files
authored
Merge pull request #9 from AckeeCZ/grissius-patch-1
Remove redundant array check
2 parents 72b16dd + 09aab61 commit ce0a0c2

1 file changed

Lines changed: 4 additions & 10 deletions

File tree

src/serializers.ts

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -54,13 +54,10 @@ const serializers: Dictionary<SerializerFn> = {
5454
},
5555
};
5656

57-
const sliceByPrefix = (prefix: string, paths: string[]) =>
58-
paths.filter(field => field.startsWith(prefix)).map(field => field.slice(prefix.length));
57+
const sliceByPrefix = (prefix: string, paths?: string[]) =>
58+
(paths || []).filter(field => field.startsWith(prefix)).map(field => field.slice(prefix.length));
5959

60-
const disablePaths = (paths: string[] | undefined) => {
61-
if (!paths || paths.length <= 0) {
62-
return;
63-
}
60+
const disablePaths = (paths?: string[]) => {
6461
forEach(serializers, (value, key) => {
6562
const affectedFields = sliceByPrefix(`${key}.`, paths);
6663

@@ -73,10 +70,7 @@ const disablePaths = (paths: string[] | undefined) => {
7370
});
7471
};
7572

76-
const enablePaths = (paths: string[] | undefined) => {
77-
if (!paths || paths.length <= 0) {
78-
return;
79-
}
73+
const enablePaths = (paths?: string[]) => {
8074
forEach(serializers, (value, key) => {
8175
const affectedFields = sliceByPrefix(`${key}.`, paths);
8276

0 commit comments

Comments
 (0)