Skip to content

Commit

Permalink
refactor(transducers-binary): minor update bits()
Browse files Browse the repository at this point in the history
  • Loading branch information
postspectacular committed Feb 6, 2020
1 parent a3ad805 commit b78f166
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions packages/transducers-binary/src/bits.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,19 +38,19 @@ export function bits(...args: any[]): any {
$iter(bits, args, iterator) ||
((rfn: Reducer<any, number>) => {
const reduce = rfn[2];
const size = (args[0] || 8) - 1;
const size = args[0] || 8;
const msb = args[1] !== false;
return compR(
rfn,
msb
? (acc, x: number) => {
for (let i = size; i >= 0 && !isReduced(acc); i--) {
for (let i = size; --i >= 0 && !isReduced(acc); ) {
acc = reduce(acc, (x >>> i) & 1);
}
return acc;
}
: (acc, x: number) => {
for (let i = 0; i <= size && !isReduced(acc); i++) {
for (let i = 0; i < size && !isReduced(acc); i++) {
acc = reduce(acc, (x >>> i) & 1);
}
return acc;
Expand Down

0 comments on commit b78f166

Please sign in to comment.