redux-persist-transform-filter
Advanced tools
Comparing version 0.0.13 to 0.0.14
@@ -73,2 +73,7 @@ 'use strict'; | ||
var value = (0, _lodash2.default)(state, path); | ||
if (value instanceof Array) { | ||
return value.filter(filterFunction); | ||
} | ||
return (0, _lodash8.default)(value, filterFunction); | ||
@@ -111,5 +116,11 @@ } | ||
if (!(0, _lodash10.default)(value)) { | ||
(0, _lodash12.default)(value, function (value, key) { | ||
(0, _lodash6.default)(subset, path.path + '.' + key); | ||
}); | ||
if (value instanceof Array) { | ||
(0, _lodash4.default)(subset, path.path, (0, _lodash2.default)(subset, path.path).filter(function (x) { | ||
return false; | ||
})); | ||
} else { | ||
(0, _lodash12.default)(value, function (value, key) { | ||
(0, _lodash6.default)(subset, path.path + '[' + key + ']'); | ||
}); | ||
} | ||
} | ||
@@ -116,0 +127,0 @@ } else { |
17
index.js
@@ -38,4 +38,9 @@ import { createTransform } from 'redux-persist'; | ||
function filterObject({ path, filterFunction = () => true }, state) { | ||
const value = get(state, path); | ||
return pickBy(value, filterFunction); | ||
const value = get(state, path); | ||
if (value instanceof Array) { | ||
return value.filter(filterFunction) | ||
} | ||
return pickBy(value, filterFunction); | ||
} | ||
@@ -74,3 +79,7 @@ | ||
if (!isEmpty(value)) { | ||
forIn(value, (value, key) => { unset(subset, `${path.path}.${key}`) }); | ||
if (value instanceof Array) { | ||
set(subset, path.path, get(subset, path.path).filter((x) => false)); | ||
} else { | ||
forIn(value, (value, key) => { unset(subset, `${path.path}[${key}]`) }); | ||
} | ||
} | ||
@@ -83,3 +92,3 @@ } else { | ||
} | ||
} | ||
} | ||
}); | ||
@@ -86,0 +95,0 @@ } else { |
{ | ||
"name": "redux-persist-transform-filter", | ||
"version": "0.0.13", | ||
"version": "0.0.14", | ||
"description": "Filter transformator for redux-persist", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
10907
186