@@ -146,23 +146,21 @@ window.initSearch = function(rawSearchIndex) {
146
146
147
147
removeEmptyStringsFromArray ( split ) ;
148
148
149
- function transformResults ( results , isType ) {
149
+ function transformResults ( results ) {
150
150
var out = [ ] ;
151
151
for ( var i = 0 , len = results . length ; i < len ; ++ i ) {
152
152
if ( results [ i ] . id > - 1 ) {
153
153
var obj = searchIndex [ results [ i ] . id ] ;
154
154
obj . lev = results [ i ] . lev ;
155
- if ( isType !== true || obj . type ) {
156
- var res = buildHrefAndPath ( obj ) ;
157
- obj . displayPath = pathSplitter ( res [ 0 ] ) ;
158
- obj . fullPath = obj . displayPath + obj . name ;
159
- // To be sure than it some items aren't considered as duplicate.
160
- obj . fullPath += "|" + obj . ty ;
161
- obj . href = res [ 1 ] ;
162
- out . push ( obj ) ;
163
- if ( out . length >= MAX_RESULTS ) {
164
- break ;
165
- }
155
+ var res = buildHrefAndPath ( obj ) ;
156
+ obj . displayPath = pathSplitter ( res [ 0 ] ) ;
157
+ obj . fullPath = obj . displayPath + obj . name ;
158
+ // To be sure than it some items aren't considered as duplicate.
159
+ obj . fullPath += "|" + obj . ty ;
160
+ obj . href = res [ 1 ] ;
161
+ out . push ( obj ) ;
162
+ if ( out . length >= MAX_RESULTS ) {
163
+ break ;
166
164
}
167
165
}
168
166
}
@@ -266,9 +264,7 @@ window.initSearch = function(rawSearchIndex) {
266
264
path = result . item . path . toLowerCase ( ) ,
267
265
parent = result . item . parent ;
268
266
269
- if ( isType !== true &&
270
- validateResult ( name , path , split , parent ) === false )
271
- {
267
+ if ( ! isType && ! validateResult ( name , path , split , parent ) ) {
272
268
result . id = - 1 ;
273
269
}
274
270
}
@@ -352,7 +348,7 @@ window.initSearch = function(rawSearchIndex) {
352
348
var lev_distance = MAX_LEV_DISTANCE + 1 ;
353
349
var len , x , firstGeneric ;
354
350
if ( obj [ NAME ] === val . name ) {
355
- if ( literalSearch === true ) {
351
+ if ( literalSearch ) {
356
352
if ( val . generics && val . generics . length !== 0 ) {
357
353
if ( obj . length > GENERICS_DATA &&
358
354
obj [ GENERICS_DATA ] . length >= val . generics . length ) {
@@ -373,7 +369,7 @@ window.initSearch = function(rawSearchIndex) {
373
369
break ;
374
370
}
375
371
}
376
- if ( allFound === true ) {
372
+ if ( allFound ) {
377
373
return true ;
378
374
}
379
375
} else {
@@ -394,7 +390,7 @@ window.initSearch = function(rawSearchIndex) {
394
390
}
395
391
}
396
392
// Names didn't match so let's check if one of the generic types could.
397
- if ( literalSearch === true ) {
393
+ if ( literalSearch ) {
398
394
if ( obj . length > GENERICS_DATA && obj [ GENERICS_DATA ] . length > 0 ) {
399
395
return obj [ GENERICS_DATA ] . some (
400
396
function ( name ) {
@@ -429,12 +425,12 @@ window.initSearch = function(rawSearchIndex) {
429
425
var length = obj . type [ INPUTS_DATA ] . length ;
430
426
for ( var i = 0 ; i < length ; i ++ ) {
431
427
var tmp = obj . type [ INPUTS_DATA ] [ i ] ;
432
- if ( typePassesFilter ( typeFilter , tmp [ 1 ] ) === false ) {
428
+ if ( ! typePassesFilter ( typeFilter , tmp [ 1 ] ) ) {
433
429
continue ;
434
430
}
435
431
tmp = checkType ( tmp , val , literalSearch ) ;
436
- if ( literalSearch === true ) {
437
- if ( tmp === true ) {
432
+ if ( literalSearch ) {
433
+ if ( tmp ) {
438
434
return true ;
439
435
}
440
436
continue ;
@@ -445,7 +441,7 @@ window.initSearch = function(rawSearchIndex) {
445
441
}
446
442
}
447
443
}
448
- return literalSearch === true ? false : lev_distance ;
444
+ return literalSearch ? false : lev_distance ;
449
445
}
450
446
451
447
function checkReturned ( obj , val , literalSearch , typeFilter ) {
@@ -458,12 +454,12 @@ window.initSearch = function(rawSearchIndex) {
458
454
}
459
455
for ( var x = 0 , len = ret . length ; x < len ; ++ x ) {
460
456
var tmp = ret [ x ] ;
461
- if ( typePassesFilter ( typeFilter , tmp [ 1 ] ) === false ) {
457
+ if ( ! typePassesFilter ( typeFilter , tmp [ 1 ] ) ) {
462
458
continue ;
463
459
}
464
460
tmp = checkType ( tmp , val , literalSearch ) ;
465
- if ( literalSearch === true ) {
466
- if ( tmp === true ) {
461
+ if ( literalSearch ) {
462
+ if ( tmp ) {
467
463
return true ;
468
464
}
469
465
continue ;
@@ -474,7 +470,7 @@ window.initSearch = function(rawSearchIndex) {
474
470
}
475
471
}
476
472
}
477
- return literalSearch === true ? false : lev_distance ;
473
+ return literalSearch ? false : lev_distance ;
478
474
}
479
475
480
476
function checkPath ( contains , lastElem , ty ) {
@@ -507,7 +503,7 @@ window.initSearch = function(rawSearchIndex) {
507
503
}
508
504
lev_total += lev ;
509
505
}
510
- if ( aborted === false ) {
506
+ if ( ! aborted ) {
511
507
ret_lev = Math . min ( ret_lev , Math . round ( lev_total / clength ) ) ;
512
508
}
513
509
}
@@ -634,14 +630,14 @@ window.initSearch = function(rawSearchIndex) {
634
630
dontValidate : true ,
635
631
} ;
636
632
}
637
- if ( in_args === true && results_in_args [ fullId ] === undefined ) {
633
+ if ( in_args && results_in_args [ fullId ] === undefined ) {
638
634
results_in_args [ fullId ] = {
639
635
id : i ,
640
636
index : - 1 ,
641
637
dontValidate : true ,
642
638
} ;
643
639
}
644
- if ( returned === true && results_returned [ fullId ] === undefined ) {
640
+ if ( returned && results_returned [ fullId ] === undefined ) {
645
641
results_returned [ fullId ] = {
646
642
id : i ,
647
643
index : - 1 ,
@@ -676,34 +672,34 @@ window.initSearch = function(rawSearchIndex) {
676
672
fullId = ty . id ;
677
673
678
674
returned = checkReturned ( ty , output , true , NO_TYPE_FILTER ) ;
679
- if ( output . name === "*" || returned === true ) {
675
+ if ( output . name === "*" || returned ) {
680
676
in_args = false ;
681
677
var is_module = false ;
682
678
683
679
if ( input === "*" ) {
684
680
is_module = true ;
685
681
} else {
686
682
var allFound = true ;
687
- for ( it = 0 , len = inputs . length ; allFound === true && it < len ; it ++ ) {
683
+ for ( it = 0 , len = inputs . length ; allFound && it < len ; it ++ ) {
688
684
allFound = checkType ( type , inputs [ it ] , true ) ;
689
685
}
690
686
in_args = allFound ;
691
687
}
692
- if ( in_args === true ) {
688
+ if ( in_args ) {
693
689
results_in_args [ fullId ] = {
694
690
id : i ,
695
691
index : - 1 ,
696
692
dontValidate : true ,
697
693
} ;
698
694
}
699
- if ( returned === true ) {
695
+ if ( returned ) {
700
696
results_returned [ fullId ] = {
701
697
id : i ,
702
698
index : - 1 ,
703
699
dontValidate : true ,
704
700
} ;
705
701
}
706
- if ( is_module === true ) {
702
+ if ( is_module ) {
707
703
results [ fullId ] = {
708
704
id : i ,
709
705
index : - 1 ,
@@ -763,10 +759,10 @@ window.initSearch = function(rawSearchIndex) {
763
759
}
764
760
}
765
761
if ( ( lev = levenshtein ( searchWords [ j ] , val ) ) <= MAX_LEV_DISTANCE ) {
766
- if ( typePassesFilter ( typeFilter , ty . ty ) === false ) {
767
- lev = MAX_LEV_DISTANCE + 1 ;
768
- } else {
762
+ if ( typePassesFilter ( typeFilter , ty . ty ) ) {
769
763
lev += 1 ;
764
+ } else {
765
+ lev = MAX_LEV_DISTANCE + 1 ;
770
766
}
771
767
}
772
768
in_args = findArg ( ty , valGenerics , false , typeFilter ) ;
@@ -821,7 +817,7 @@ window.initSearch = function(rawSearchIndex) {
821
817
var ret = {
822
818
"in_args" : sortResults ( results_in_args , true ) ,
823
819
"returned" : sortResults ( results_returned , true ) ,
824
- "others" : sortResults ( results ) ,
820
+ "others" : sortResults ( results , false ) ,
825
821
} ;
826
822
handleAliases ( ret , query , filterCrates ) ;
827
823
return ret ;
@@ -1263,7 +1259,7 @@ window.initSearch = function(rawSearchIndex) {
1263
1259
if ( query . query . length === 0 ) {
1264
1260
return ;
1265
1261
}
1266
- if ( forced !== true && query . id === currentResults ) {
1262
+ if ( ! forced && query . id === currentResults ) {
1267
1263
if ( query . query . length > 0 ) {
1268
1264
searchState . putBackSearch ( searchState . input ) ;
1269
1265
}
0 commit comments