Skip to content

Commit

Permalink
fixed build issues in formatInputDynamicBytes
Browse files Browse the repository at this point in the history
  • Loading branch information
frozeman committed Jun 22, 2015
1 parent 0e3b29c commit 9061116
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 14 deletions.
6 changes: 3 additions & 3 deletions dist/web3-light.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions dist/web3-light.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/web3-light.min.js

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions dist/web3.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions dist/web3.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/web3.min.js

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions lib/solidity/formatters.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,9 @@ var formatInputBytes = function (value) {
* @returns {SolidityParam}
*/
var formatInputDynamicBytes = function (value) {
var value = utils.toHex(value);
value = utils.toHex(value);
var result = utils.padRight((value).substr(2), 64);
var length = (value.length / 2 - 1) | 0;
var length = (value.length / 2 - 1) || 0;
return new SolidityParam(formatInputInt(length).value + result, 32);
};

Expand Down

5 comments on commit 9061116

@frozeman
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This line is what made the jslint break. And how is a single | correct?

@debris
Copy link
Contributor

@debris debris commented on 9061116 Jun 22, 2015

Choose a reason for hiding this comment

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

docs.

TL;DR

var number = number | 0;

// is equal to

var number = Math.floor(number);

@frozeman
Copy link
Contributor Author

Choose a reason for hiding this comment

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

ok cool, i never pushed bits in js before :P

but why did jslint fail then if its basic operator?

@frozeman
Copy link
Contributor Author

Choose a reason for hiding this comment

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

And if it would mean that all our future PRs are failing checks because of this line, i would rather use Math.floor() ;)

@debris
Copy link
Contributor

@debris debris commented on 9061116 Jun 22, 2015

Choose a reason for hiding this comment

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

by default lint has disabled bitwise operators

This option prohibits the use of bitwise operators such as ^ (XOR), | (OR) and others. Bitwise operators are very rare in JavaScript programs and quite often & is simply a mistyped &&.

Although in our config they are on. You probably run lint with different config on our code. I'm fine with replacing it with Math.floor() if it will make it more readable :)

Please sign in to comment.