Skip to content
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

Merged
merged 19 commits into from
Nov 6, 2019

Conversation

yurybotov
Copy link
Contributor

New version octoliner.js using new API agreement.
API agreement you can look at: https://github.com/amperka/Octoliner/blob/V2/API.md

modules/@amperka/octoliner.js Outdated Show resolved Hide resolved
Comment on lines 34 to 37
Octoliner.prototype.analogReadAll = function(analogArray) {
for (var i = 0; i < 8; i++) {
analogArray[i] = this.analogRead(i);
}
Copy link
Member

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;

Copy link
Contributor Author

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.

Copy link
Contributor Author

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.

Comment on lines 19 to 20
this.mapPatternToLine = this.defaultMapPatternToLine;
this.mapAnalogToPattern = this.defaultMapAnalogToPattern;
Copy link
Member

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.

Copy link
Contributor Author

@yurybotov yurybotov Nov 1, 2019

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.

Copy link
Member

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@yurybotov yurybotov requested a review from nkrkv November 5, 2019 08:12
Copy link
Member

@nkrkv nkrkv left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 LGTM

@nkrkv
Copy link
Member

nkrkv commented Nov 5, 2019

@igor89, any feedback?

Copy link

@S-VIN S-VIN left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@yurybotov yurybotov merged commit d954570 into master Nov 6, 2019
@yurybotov yurybotov deleted the fix-new-octoliner-interface-on-js branch November 6, 2019 09:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants