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

Commit

Permalink
Replace type check with ramda type function.
Browse files Browse the repository at this point in the history
  • Loading branch information
T4rk1n committed Sep 21, 2018
1 parent beaef00 commit d2b2d82
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/components/Storage.react.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ function dataCheck(data, old) {
if (R.isNil(old) || R.isNil(data)) {
return true;
}
if (data.constructor === Array)
const type = R.type(data);
if (type === 'Array')
{
if (data.length !== old.length) {
return true;
Expand All @@ -18,13 +19,13 @@ function dataCheck(data, old) {
}
}
}
else if (data instanceof Object)
else if (R.contains(type, ['String', 'Number']))
{
return R.any(([k,v]) => old[k] !== v)(Object.entries(data));
return old !== data
}
else if (data instanceof String || data instanceof Number)
else if (type === 'Object')
{
return old !== data
return R.any(([k,v]) => old[k] !== v)(Object.entries(data));
}
return false;
}
Expand Down

0 comments on commit d2b2d82

Please sign in to comment.