@@ -161,7 +161,7 @@ function resolveBitString(pattern: Types.BitStringMatch): Function {
161161
162162 for ( let bitstringMatchPart of pattern . values ) {
163163 if ( Checks . is_variable ( bitstringMatchPart . value ) ) {
164- let size = getLength ( bitstringMatchPart . type , bitstringMatchPart . unit , bitstringMatchPart . size ) ;
164+ let size = getSize ( bitstringMatchPart . unit , bitstringMatchPart . size ) ;
165165 fillArray ( patternBitString , size ) ;
166166 } else {
167167 patternBitString = patternBitString . concat ( new BitString ( bitstringMatchPart ) . value ) ;
@@ -198,7 +198,7 @@ function resolveBitString(pattern: Types.BitStringMatch): Function {
198198 let size = 0 ;
199199 let bsValueArrayPart = [ ] ;
200200 let patternBitStringArrayPart = [ ] ;
201- size = getLength ( bitstringMatchPart . type , bitstringMatchPart . unit , bitstringMatchPart . size ) ;
201+ size = getSize ( bitstringMatchPart . unit , bitstringMatchPart . size ) ;
202202
203203 if ( i === patternValues . length - 1 ) {
204204 bsValueArrayPart = bsValue . value . slice ( beginningIndex ) ;
@@ -263,18 +263,8 @@ function resolveBitString(pattern: Types.BitStringMatch): Function {
263263
264264}
265265
266- function getLength ( type , unit , size ) {
267- if ( type === 'integer' && size === 8 ) {
268- return 1 ;
269- } else if ( type === 'float' && size === 32 ) {
270- return 4 ;
271- } else if ( type === 'float' && size === 64 ) {
272- return 8 ;
273- } else if ( type === 'binary' ) {
274- return size ;
275- } else {
276- return unit * size ;
277- }
266+ function getSize ( unit , size ) {
267+ return ( unit * size ) / 8 ;
278268}
279269
280270function arraysEqual ( a , b ) {
0 commit comments