File tree 1 file changed +6
-8
lines changed
1 file changed +6
-8
lines changed Original file line number Diff line number Diff line change @@ -455,17 +455,15 @@ export function bit_array_split_once(bits, pattern) {
455
455
456
456
export function bit_array_split ( bits , pattern ) {
457
457
try {
458
- if ( ! ( bits instanceof BitArray )
459
- || ! ( pattern instanceof BitArray )
460
- || pattern . buffer . length < 1 ) {
458
+ const patternEmpty = pattern . buffer . length < 1
459
+ const incorrectArguments = ! ( bits instanceof BitArray ) || ! ( pattern instanceof BitArray )
460
+ if ( incorrectArguments || patternEmpty ) {
461
461
return new Error ( Nil ) ;
462
462
}
463
463
464
- if ( bits . buffer . length === 0 ) {
465
- return new Ok ( List . fromArray ( [ ] ) ) ;
466
- }
467
-
468
- if ( Buffer . compare ( bits . buffer , pattern . buffer ) === 0 ) {
464
+ const bitsEqualToPattern = Buffer . compare ( bits . buffer , pattern . buffer ) === 0
465
+ const bitsEmpty = bits . buffer . length === 0
466
+ if ( bitsEqualToPattern || bitsEmpty ) {
469
467
return new Ok ( List . fromArray ( [ ] ) ) ;
470
468
}
471
469
You can’t perform that action at this time.
0 commit comments