-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
"for... in" should not be used with arrays. This causes bugs! #1081
Conversation
Could you just replace the |
I already ended up removing many of those changes due to your draconian style checker! The rest is as follows -- There are only four differences now, other than the forEach fixes, and corresponding "my" variables -- the "my" variables isn't something I came up with as it was present in an existing function.
to
and
to
to
Thanks for your work! |
While some of your changes make sense (I'll mark them with a thumbs-up in the changeset), some are arbitrary, and I would rather not create more maintenance work for the |
src/drawer.multicanvas.js
Outdated
@@ -52,24 +53,24 @@ WaveSurfer.util.extend(WaveSurfer.Drawer.MultiCanvas, { | |||
this.removeCanvas(); | |||
} | |||
|
|||
for (var i in this.canvases) { | |||
my.canvases.forEach (function (canvas, i) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 except for the extra space after forEach
– it's not needed.
src/drawer.multicanvas.js
Outdated
var my = this; | ||
my.canvases.forEach (function (canvas) { | ||
my.clearWaveForEntry(canvas); | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
this.canvases.forEach(function (canvas) {
this.clearWaveForEntry(canvas);
}, this);
src/drawer.multicanvas.js
Outdated
this.drawLineToContext(entry, entry.progressCtx, peaks, absmax, halfH, offsetY, start, end); | ||
} | ||
var my = this; | ||
my.canvases.forEach (function (canvas) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The same comment as above.
* | ||
* @param {String} type - an optional value of a format type. Default is image/png. | ||
* @param {Number} quality - an optional value between 0 and 1. Default is 0.92. | ||
* | ||
*/ | ||
getImage: function(type, quality) { | ||
getImage: function (type, quality) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
OK, give me a few minutes to make the appropriate changes. |
Ok, I removed almost all of the other changes. I also implemented your suggestion about inserting a |
I still see a lot of other changes in the diff. |
I fixed some errors. The only other change now is removing space between opening/closing brackets and text. You don't really even have that consistent... those spaces are really terrible... |
Ok, a few more I didn't notice. |
I really hate those extraneous spaces, but I added them back. I also added some extra extraneous spaces in style definition calls for it to be consistent. |
src/drawer.multicanvas.js
Outdated
return; | ||
} else { | ||
peaks = channels[0]; | ||
} | ||
} | ||
|
||
// Support arrays without negative peaks | ||
var hasMinValues = [].some.call(peaks, function (val) { return val < 0; }); | ||
var hasMinValues = [].some.call(peaks, function (val) {return val < 0;}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you revert this change, too?
Ok. |
Merged, thanks! |
See: #1014.
I also changed "entry" to "canvas" since they are canvases. And, uh, just a few styling ideas.