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

Commit 34aecae

Browse files
committed
Replace type check with ramda type function.
1 parent a8900fb commit 34aecae

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

src/components/Storage.react.js

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@ function dataCheck(data, old) {
77
if (R.isNil(old) || R.isNil(data)) {
88
return true;
99
}
10-
if (data.constructor === Array)
10+
const type = R.type(data);
11+
if (type === 'Array')
1112
{
1213
if (data.length !== old.length) {
1314
return true;
@@ -18,13 +19,13 @@ function dataCheck(data, old) {
1819
}
1920
}
2021
}
21-
else if (data instanceof Object)
22+
else if (R.contains(type, ['String', 'Number']))
2223
{
23-
return R.any(([k,v]) => old[k] !== v)(Object.entries(data));
24+
return old !== data
2425
}
25-
else if (data instanceof String || data instanceof Number)
26+
else if (type === 'Object')
2627
{
27-
return old !== data
28+
return R.any(([k,v]) => old[k] !== v)(Object.entries(data));
2829
}
2930
return false;
3031
}

0 commit comments

Comments
 (0)