Total Complexity | 4 |
Complexity/F | 4 |
Lines of Code | 21 |
Function Count | 1 |
Duplicated Lines | 0 |
Ratio | 0 % |
Coverage | 100% |
Changes | 0 |
1 | import { SortOptions } from './types'; |
||
2 | 1 | import { isPrimitive, isNonSortableObject, isObject } from './type-guards'; |
|
3 | 1 | import { sortArray } from './array-sorter'; |
|
4 | 1 | import { sortObject } from './object-sorter'; |
|
5 | |||
6 | 1 | export function sortRecursively<T>(data: T, options: SortOptions): T { |
|
7 | 1660 | if (Array.isArray(data)) { |
|
8 | 72 | return sortArray(data, options) as T; |
|
9 | } |
||
10 | |||
11 | 1588 | if (isPrimitive(data) || isNonSortableObject(data)) { |
|
12 | 186 | return data; |
|
13 | } |
||
14 | |||
15 | 1401 | if (isObject(data)) { |
|
16 | 1398 | return sortObject(data, options) as T; |
|
17 | } |
||
18 | |||
19 | 3 | return data; |
|
20 | } |
||
21 |