Skip to content

Commit

Permalink
Use isObject helper in object key helpers
Browse files Browse the repository at this point in the history
  • Loading branch information
dwmcnelis committed Oct 27, 2017
1 parent 11c80cd commit f64c246
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ var znFilterMatcher = (function() {
* @since 1.1.0
*/
function noKeys(x) {
return (x.constructor === Object) && (Object.keys(x).length === 0);
return isObject(x) && (Object.keys(x).length === 0);
};

/**
Expand All @@ -189,7 +189,7 @@ var znFilterMatcher = (function() {
* @since 1.1.0
*/
function anyKeysLike(x, pattern) {
if (x.constructor !== Object) {
if (!isObject(x)) {
return false;
}
var keys = Object.keys(x);
Expand Down Expand Up @@ -249,9 +249,7 @@ var znFilterMatcher = (function() {
}
if (rule.filter !== undefined) {
var subRecord = record[rule.attribute];
if (subRecord &&
isObject(subRecord) &&
(noKeys(subRecord) || anyKeysLike(subRecord, /^field/))) {
if (subRecord && (noKeys(subRecord) || anyKeysLike(subRecord, /^field/))) {
if (!recordMatchesFilter(subRecord, rule.filter)) {
return false;
}
Expand Down

0 comments on commit f64c246

Please sign in to comment.