File tree Expand file tree Collapse file tree 2 files changed +21
-0
lines changed Expand file tree Collapse file tree 2 files changed +21
-0
lines changed Original file line number Diff line number Diff line change @@ -19,6 +19,7 @@ export const SORT_STRATEGIES = [
1919 "visibility" ,
2020 "required-first" ,
2121 "kind" ,
22+ "internal-first" ,
2223] as const ;
2324
2425export type SortStrategy = ( typeof SORT_STRATEGIES ) [ number ] ;
@@ -151,6 +152,9 @@ const sorts: Record<
151152 kind ( a , b , { kindSortOrder } ) {
152153 return kindSortOrder . indexOf ( a . kind ) < kindSortOrder . indexOf ( b . kind ) ;
153154 } ,
155+ "internal-first" ( a , b ) {
156+ return ! a . flags . isExternal && b . flags . isExternal ;
157+ } ,
154158} ;
155159
156160export function getSortFunction ( opts : Options ) {
Original file line number Diff line number Diff line change @@ -209,6 +209,23 @@ describe("Sort", () => {
209209 ) ;
210210 } ) ;
211211
212+ it ( "Should sort by internal first" , ( ) => {
213+ const arr = [
214+ new DeclarationReflection ( "a" , ReflectionKind . Function ) ,
215+ new DeclarationReflection ( "b" , ReflectionKind . Function ) ,
216+ new DeclarationReflection ( "c" , ReflectionKind . Function ) ,
217+ ] ;
218+ arr [ 0 ] . setFlag ( ReflectionFlag . External , true ) ;
219+ arr [ 1 ] . setFlag ( ReflectionFlag . External , false ) ;
220+ arr [ 2 ] . setFlag ( ReflectionFlag . External , true ) ;
221+
222+ sortReflections ( arr , [ "internal-first" ] ) ;
223+ equal (
224+ arr . map ( ( r ) => r . name ) ,
225+ [ "b" , "a" , "c" ] ,
226+ ) ;
227+ } ) ;
228+
212229 it ( "Should sort with multiple strategies" , ( ) => {
213230 resetReflectionID ( ) ;
214231 const arr = [
You can’t perform that action at this time.
0 commit comments