Skip to content

Commit b0b1b88

Browse files
committed
Refactor: DRY
1 parent 9b048d5 commit b0b1b88

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

lib/charSet.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,13 +79,15 @@ const _ndxFn = (bitsPerChar) => {
7979
let slicesPerChunk = lcm(bitsPerChar, bitsPerByte) / bitsPerByte
8080
let bNum = chunk * slicesPerChunk
8181

82+
let offset = (slice*bitsPerChar)/bitsPerByte
83+
let lOffset = Math.floor(offset)
84+
let rOffset = Math.ceil(offset)
85+
8286
let rShift = bitsPerByte - bitsPerChar
83-
let lOffset = Math.floor((slice*bitsPerChar)/bitsPerByte)
8487
let lShift = (slice*bitsPerChar) % bitsPerByte
8588

8689
let ndx = ((bytes[bNum+lOffset]<<lShift)&0xff)>>rShift
8790

88-
let rOffset = Math.ceil((slice*bitsPerChar)/bitsPerByte)
8991
let rShiftIt = ((rOffset+1)*bitsPerByte - (slice+1)*bitsPerChar) % bitsPerByte
9092
if (rShift < rShiftIt) {
9193
ndx += bytes[bNum+rOffset]>>rShiftIt

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy