-
Notifications
You must be signed in to change notification settings - Fork 26
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
New version octoliner.js using new interface agreement #78
Conversation
modules/@amperka/octoliner.js
Outdated
Octoliner.prototype.analogReadAll = function(analogArray) { | ||
for (var i = 0; i < 8; i++) { | ||
analogArray[i] = this.analogRead(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.
No reason to do this in JS. JavaScript memory is managed, so just create an array and return it.
Like (not checked):
var values = [0, 0, 0, 0, 0, 0, 0, 0];
for (var i = 0; i < 8; i++) {
values[i] = this.analogRead(i);
}
return values;
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.
It is right. I am tryed to save the same interface.
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.
Done.
Do not forget to indicate the difference in the version of the API for JS.
modules/@amperka/octoliner.js
Outdated
this.mapPatternToLine = this.defaultMapPatternToLine; | ||
this.mapAnalogToPattern = this.defaultMapAnalogToPattern; |
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.
Why so? Just define mapPatternToLine
, mapAnalogToPattern
. A user may override them using regular prototypal JS-inheritance.
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.
It seems so clearer to me. I clearly indicate that this can be changed.
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 is not a native way for JS. It can confuse people who use JS in the JS-way. Suggest making the methods regular.
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.
Done
Co-Authored-By: Victor Nakoryakov <[email protected]>
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.
👍 LGTM
@igor89, any feedback? |
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.
LGTM
New version octoliner.js using new API agreement.
API agreement you can look at: https://github.com/amperka/Octoliner/blob/V2/API.md