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

Commit

Permalink
Avoid erroring with Benchmark.options event handlers. [closes #180]
Browse files Browse the repository at this point in the history
  • Loading branch information
jdalton committed Dec 24, 2016
1 parent 785aa51 commit 13ccb9a
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions benchmark.js
Original file line number Diff line number Diff line change
Expand Up @@ -1473,21 +1473,24 @@
if (key.charAt(0) == '_') {
return;
}
if (value && typeof value == 'object') {
if (_.isObjectLike(value)) {
if (_.isArray(value)) {
// Check if an array value has changed to a non-array value.
if (!_.isArray(currValue)) {
changed = currValue = [];
changed = true;
currValue = [];
}
// Check if an array has changed its length.
if (currValue.length != value.length) {
changed = currValue = currValue.slice(0, value.length);
else if (currValue.length != value.length) {
changed = true;
currValue = currValue.slice(0, value.length);
currValue.length = value.length;
}
}
// Check if an object has changed to a non-object value.
else if (!currValue || typeof currValue != 'object') {
changed = currValue = {};
else if (!_.isObjectLike(currValue)) {
changed = true;
currValue = {};
}
// Register a changed object.
if (changed) {
Expand Down

0 comments on commit 13ccb9a

Please sign in to comment.