Skip to content

Commit

Permalink
fix: shrinkStrategy should always return an integer
Browse files Browse the repository at this point in the history
`Buffer` inherits from `Uint8Arry` so the constructor needs to be
called with integers and mustn't be called with floats.

This patch ensures that the result of the the calculation
in the `shrinkStrategy` in `Receiver` returns an integer.

The reason why this has not been a problem up to now is that
a there is a [V8 Bug](https://code.google.com/p/v8/issues/detail?id=4552)
that the [spec](http://tc39.github.io/ecma262/#sec-typedarray-length)
is not adhered in this case.

This is a blocking issue for [Karma](karma-runner/karma#1768)
as the upgrade to [[email protected]](https://github.com/zloirock/core-js)
now enforces this error.
  • Loading branch information
dignifiedquire committed Dec 27, 2015
1 parent bcecb42 commit 62b7abb
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/Receiver.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ function Receiver (extensions) {
return db.used + length;
}, function(db) {
return fragmentedPoolPrevUsed = fragmentedPoolPrevUsed >= 0 ?
(fragmentedPoolPrevUsed + db.used) / 2 :
Math.ceil((fragmentedPoolPrevUsed + db.used) / 2) :
db.used;
});

Expand All @@ -36,7 +36,7 @@ function Receiver (extensions) {
return db.used + length;
}, function(db) {
return unfragmentedPoolPrevUsed = unfragmentedPoolPrevUsed >= 0 ?
(unfragmentedPoolPrevUsed + db.used) / 2 :
Math.ceil((unfragmentedPoolPrevUsed + db.used) / 2) :
db.used;
});

Expand Down

0 comments on commit 62b7abb

Please sign in to comment.