Skip to content

Commit

Permalink
Lint
Browse files Browse the repository at this point in the history
  • Loading branch information
b.platroz committed Jun 20, 2023
1 parent a185a77 commit 9d382b0
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ function typeHasher(options, writeTo, context){
var pattern = (/\[object (.*)\]/i);
var objString = Object.prototype.toString.call(object);
var objType = pattern.exec(objString);
var baseKeysPath = [...keysPath];
var baseKeysPath = keysPath.slice(); // clone
if (!objType) { // object type did not match [object ...]
objType = 'unknown:[' + objString + ']';
} else {
Expand Down Expand Up @@ -242,13 +242,13 @@ function typeHasher(options, writeTo, context){
}

if (options.excludeKeys) {
keys = keys.filter(function(key) { return !options.excludeKeys(key, [...keysPath, key]); });
keys = keys.filter(function(key) { return !options.excludeKeys(key, baseKeysPath.concat([key])); });
}

write('object:' + keys.length + ':');
var self = this;
return keys.forEach(function(key){
keysPath = [...baseKeysPath, key];
keysPath = baseKeysPath.concat([key]);

self.dispatch(key);
write(':');
Expand All @@ -262,16 +262,17 @@ function typeHasher(options, writeTo, context){
_array: function(arr, unordered){
unordered = typeof unordered !== 'undefined' ? unordered :
options.unorderedArrays !== false; // default to options.unorderedArrays
var baseKeysPath = [...keysPath];
var baseKeysPath = keysPath.slice(); // clone

if (options.excludeKeys)
arr = arr.filter((entry, index) => !options.excludeKeys(null, [...baseKeysPath, index]))
if (options.excludeKeys) {
arr = arr.filter(function (entry, index) { return !options.excludeKeys(null, baseKeysPath.concat([index])); });
}

var self = this;
write('array:' + arr.length + ':');
if (!unordered || arr.length <= 1) {
return arr.forEach(function(entry, index) {
keysPath = [...baseKeysPath, index];
keysPath = baseKeysPath.concat([index]);
return self.dispatch(entry);
});
}
Expand Down

0 comments on commit 9d382b0

Please sign in to comment.