@tanstack/table-core 8.0.0-alpha.9 → 8.0.0-beta.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/cjs/aggregationFns.js +120 -0
- package/build/cjs/aggregationFns.js.map +1 -0
- package/build/cjs/core/cell.js +40 -0
- package/build/cjs/core/cell.js.map +1 -0
- package/build/cjs/core/column.js +88 -0
- package/build/cjs/core/column.js.map +1 -0
- package/build/cjs/core/headers.js +403 -0
- package/build/cjs/core/headers.js.map +1 -0
- package/build/cjs/core/instance.js +255 -0
- package/build/cjs/core/instance.js.map +1 -0
- package/build/cjs/core/row.js +77 -0
- package/build/cjs/core/row.js.map +1 -0
- package/build/cjs/createTable.js +36 -29
- package/build/cjs/createTable.js.map +1 -1
- package/build/cjs/features/ColumnSizing.js +157 -189
- package/build/cjs/features/ColumnSizing.js.map +1 -1
- package/build/cjs/features/Expanding.js +103 -155
- package/build/cjs/features/Expanding.js.map +1 -1
- package/build/cjs/features/Filters.js +155 -304
- package/build/cjs/features/Filters.js.map +1 -1
- package/build/cjs/features/Grouping.js +97 -157
- package/build/cjs/features/Grouping.js.map +1 -1
- package/build/cjs/features/Ordering.js +30 -41
- package/build/cjs/features/Ordering.js.map +1 -1
- package/build/cjs/features/Pagination.js +102 -105
- package/build/cjs/features/Pagination.js.map +1 -1
- package/build/cjs/features/Pinning.js +131 -89
- package/build/cjs/features/Pinning.js.map +1 -1
- package/build/cjs/features/RowSelection.js +138 -267
- package/build/cjs/features/RowSelection.js.map +1 -1
- package/build/cjs/features/Sorting.js +82 -167
- package/build/cjs/features/Sorting.js.map +1 -1
- package/build/cjs/features/Visibility.js +69 -115
- package/build/cjs/features/Visibility.js.map +1 -1
- package/build/cjs/filterFns.js +107 -0
- package/build/cjs/filterFns.js.map +1 -0
- package/build/cjs/index.js +36 -23
- package/build/cjs/index.js.map +1 -1
- package/build/cjs/sortingFns.js +124 -0
- package/build/cjs/sortingFns.js.map +1 -0
- package/build/cjs/utils/filterRowsUtils.js +117 -0
- package/build/cjs/utils/filterRowsUtils.js.map +1 -0
- package/build/cjs/utils/getCoreRowModel.js +79 -0
- package/build/cjs/utils/getCoreRowModel.js.map +1 -0
- package/build/cjs/utils/getExpandedRowModel.js +57 -0
- package/build/cjs/utils/getExpandedRowModel.js.map +1 -0
- package/build/cjs/utils/getFacetedMinMaxValues.js +54 -0
- package/build/cjs/utils/getFacetedMinMaxValues.js.map +1 -0
- package/build/cjs/utils/getFacetedRowModel.js +50 -0
- package/build/cjs/utils/getFacetedRowModel.js.map +1 -0
- package/build/cjs/utils/getFacetedUniqueValues.js +48 -0
- package/build/cjs/utils/getFacetedUniqueValues.js.map +1 -0
- package/build/cjs/utils/getFilteredRowModel.js +139 -0
- package/build/cjs/utils/getFilteredRowModel.js.map +1 -0
- package/build/cjs/utils/getGroupedRowModel.js +161 -0
- package/build/cjs/utils/getGroupedRowModel.js.map +1 -0
- package/build/cjs/utils/getPaginationRowModel.js +61 -0
- package/build/cjs/utils/getPaginationRowModel.js.map +1 -0
- package/build/cjs/utils/getSortedRowModel.js +110 -0
- package/build/cjs/utils/getSortedRowModel.js.map +1 -0
- package/build/cjs/utils.js +38 -107
- package/build/cjs/utils.js.map +1 -1
- package/build/esm/index.js +2976 -3853
- package/build/esm/index.js.map +1 -1
- package/build/stats-html.html +1 -1
- package/build/stats-react.json +586 -408
- package/build/types/aggregationFns.d.ts +13 -0
- package/build/types/core/cell.d.ts +9 -0
- package/build/types/core/column.d.ts +40 -0
- package/build/types/core/headers.d.ts +46 -0
- package/build/types/core/instance.d.ts +57 -0
- package/build/types/core/row.d.ts +15 -0
- package/build/types/createTable.d.ts +47 -26
- package/build/types/features/ColumnSizing.d.ts +32 -44
- package/build/types/features/Expanding.d.ts +15 -26
- package/build/types/features/Filters.d.ts +64 -63
- package/build/types/features/Grouping.d.ts +32 -46
- package/build/types/features/Ordering.d.ts +7 -10
- package/build/types/features/Pagination.d.ts +16 -15
- package/build/types/features/Pinning.d.ts +16 -17
- package/build/types/features/RowSelection.d.ts +13 -33
- package/build/types/features/Sorting.d.ts +25 -44
- package/build/types/features/Visibility.d.ts +16 -25
- package/build/types/filterFns.d.ts +13 -0
- package/build/types/index.d.ts +16 -10
- package/build/types/sortingFns.d.ts +11 -0
- package/build/types/types.d.ts +37 -122
- package/build/types/utils/filterRowsUtils.d.ts +4 -0
- package/build/types/utils/getCoreRowModel.d.ts +2 -0
- package/build/types/utils/getExpandedRowModel.d.ts +7 -0
- package/build/types/utils/getFacetedMinMaxValues.d.ts +2 -0
- package/build/types/utils/getFacetedRowModel.d.ts +2 -0
- package/build/types/utils/getFacetedUniqueValues.d.ts +2 -0
- package/build/types/utils/getFilteredRowModel.d.ts +2 -0
- package/build/types/utils/getGroupedRowModel.d.ts +2 -0
- package/build/types/utils/getPaginationRowModel.d.ts +4 -0
- package/build/types/utils/getSortedRowModel.d.ts +2 -0
- package/build/types/utils.d.ts +7 -11
- package/build/umd/index.development.js +3024 -3893
- package/build/umd/index.development.js.map +1 -1
- package/build/umd/index.production.js +1 -1
- package/build/umd/index.production.js.map +1 -1
- package/package.json +9 -10
- package/src/aggregationFns.ts +123 -0
- package/src/core/cell.ts +48 -0
- package/src/core/column.ts +147 -0
- package/src/core/headers.ts +575 -0
- package/src/core/instance.ts +359 -0
- package/src/core/row.ts +85 -0
- package/src/createTable.ts +188 -0
- package/src/features/ColumnSizing.ts +170 -185
- package/src/features/Expanding.ts +120 -194
- package/src/features/Filters.ts +299 -381
- package/src/features/Grouping.ts +158 -220
- package/src/features/Ordering.ts +24 -25
- package/src/features/Pagination.ts +88 -73
- package/src/features/Pinning.ts +186 -63
- package/src/features/RowSelection.ts +107 -245
- package/src/features/Sorting.ts +125 -225
- package/src/features/Visibility.ts +116 -132
- package/src/filterFns.ts +135 -0
- package/src/index.ts +29 -0
- package/src/{sortTypes.ts → sortingFns.ts} +63 -85
- package/src/types.ts +62 -168
- package/src/utils/filterRowsUtils.ts +112 -0
- package/src/utils/getCoreRowModel.ts +84 -0
- package/src/utils/getExpandedRowModel.ts +54 -0
- package/src/utils/getFacetedMinMaxValues.ts +40 -0
- package/src/utils/getFacetedRowModel.ts +50 -0
- package/src/utils/getFacetedUniqueValues.ts +37 -0
- package/src/utils/getFilteredRowModel.ts +159 -0
- package/src/utils/getGroupedRowModel.ts +175 -0
- package/src/utils/getPaginationRowModel.ts +48 -0
- package/src/utils/getSortedRowModel.ts +116 -0
- package/src/utils.ts +126 -0
- package/build/cjs/_virtual/_rollupPluginBabelHelpers.js +0 -112
- package/build/cjs/_virtual/_rollupPluginBabelHelpers.js.map +0 -1
- package/build/cjs/aggregationTypes.js +0 -130
- package/build/cjs/aggregationTypes.js.map +0 -1
- package/build/cjs/core.js +0 -545
- package/build/cjs/core.js.map +0 -1
- package/build/cjs/features/Headers.js +0 -630
- package/build/cjs/features/Headers.js.map +0 -1
- package/build/cjs/filterTypes.js +0 -172
- package/build/cjs/filterTypes.js.map +0 -1
- package/build/cjs/sortTypes.js +0 -122
- package/build/cjs/sortTypes.js.map +0 -1
- package/build/cjs/types.js +0 -22
- package/build/cjs/types.js.map +0 -1
- package/build/cjs/utils/columnFilterRowsFn.js +0 -131
- package/build/cjs/utils/columnFilterRowsFn.js.map +0 -1
- package/build/cjs/utils/expandRowsFn.js +0 -38
- package/build/cjs/utils/expandRowsFn.js.map +0 -1
- package/build/cjs/utils/globalFilterRowsFn.js +0 -101
- package/build/cjs/utils/globalFilterRowsFn.js.map +0 -1
- package/build/cjs/utils/groupRowsFn.js +0 -155
- package/build/cjs/utils/groupRowsFn.js.map +0 -1
- package/build/cjs/utils/paginateRowsFn.js +0 -44
- package/build/cjs/utils/paginateRowsFn.js.map +0 -1
- package/build/cjs/utils/sortRowsFn.js +0 -94
- package/build/cjs/utils/sortRowsFn.js.map +0 -1
- package/build/types/aggregationTypes.d.ts +0 -22
- package/build/types/core.d.ts +0 -105
- package/build/types/features/Headers.d.ts +0 -43
- package/build/types/filterTypes.d.ts +0 -50
- package/build/types/sortTypes.d.ts +0 -18
- package/build/types/utils/columnFilterRowsFn.d.ts +0 -2
- package/build/types/utils/expandRowsFn.d.ts +0 -2
- package/build/types/utils/globalFilterRowsFn.d.ts +0 -2
- package/build/types/utils/groupRowsFn.d.ts +0 -2
- package/build/types/utils/paginateRowsFn.d.ts +0 -2
- package/build/types/utils/sortRowsFn.d.ts +0 -2
- package/src/.DS_Store +0 -0
- package/src/aggregationTypes.ts +0 -115
- package/src/core.tsx +0 -763
- package/src/createTable.tsx +0 -137
- package/src/features/Headers.ts +0 -747
- package/src/filterTypes.ts +0 -188
- package/src/index.tsx +0 -23
- package/src/utils/columnFilterRowsFn.ts +0 -113
- package/src/utils/expandRowsFn.ts +0 -30
- package/src/utils/globalFilterRowsFn.ts +0 -89
- package/src/utils/groupRowsFn.ts +0 -170
- package/src/utils/paginateRowsFn.ts +0 -28
- package/src/utils/sortRowsFn.ts +0 -95
- package/src/utils.tsx +0 -221
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import { Cell, Column, FooterGroupProps, FooterProps, Getter, Header, HeaderGroup, HeaderGroupProps, HeaderProps, PartialGenerics, PropGetterValue, TableInstance, Row } from '../types';
|
|
2
|
-
export declare type HeadersRow<TGenerics extends PartialGenerics> = {
|
|
3
|
-
_getAllVisibleCells: () => Cell<TGenerics>[];
|
|
4
|
-
getVisibleCells: () => Cell<TGenerics>[];
|
|
5
|
-
getLeftVisibleCells: () => Cell<TGenerics>[];
|
|
6
|
-
getCenterVisibleCells: () => Cell<TGenerics>[];
|
|
7
|
-
getRightVisibleCells: () => Cell<TGenerics>[];
|
|
8
|
-
};
|
|
9
|
-
export declare type HeadersInstance<TGenerics extends PartialGenerics> = {
|
|
10
|
-
createHeader: (column: Column<TGenerics>, options: {
|
|
11
|
-
id?: string;
|
|
12
|
-
isPlaceholder?: boolean;
|
|
13
|
-
placeholderId?: string;
|
|
14
|
-
depth: number;
|
|
15
|
-
}) => Header<TGenerics>;
|
|
16
|
-
getHeaderGroups: () => HeaderGroup<TGenerics>[];
|
|
17
|
-
getLeftHeaderGroups: () => HeaderGroup<TGenerics>[];
|
|
18
|
-
getCenterHeaderGroups: () => HeaderGroup<TGenerics>[];
|
|
19
|
-
getRightHeaderGroups: () => HeaderGroup<TGenerics>[];
|
|
20
|
-
getFooterGroups: () => HeaderGroup<TGenerics>[];
|
|
21
|
-
getLeftFooterGroups: () => HeaderGroup<TGenerics>[];
|
|
22
|
-
getCenterFooterGroups: () => HeaderGroup<TGenerics>[];
|
|
23
|
-
getRightFooterGroups: () => HeaderGroup<TGenerics>[];
|
|
24
|
-
getFlatHeaders: () => Header<TGenerics>[];
|
|
25
|
-
getLeftFlatHeaders: () => Header<TGenerics>[];
|
|
26
|
-
getCenterFlatHeaders: () => Header<TGenerics>[];
|
|
27
|
-
getRightFlatHeaders: () => Header<TGenerics>[];
|
|
28
|
-
getLeafHeaders: () => Header<TGenerics>[];
|
|
29
|
-
getLeftLeafHeaders: () => Header<TGenerics>[];
|
|
30
|
-
getCenterLeafHeaders: () => Header<TGenerics>[];
|
|
31
|
-
getRightLeafHeaders: () => Header<TGenerics>[];
|
|
32
|
-
getHeader: (id: string) => Header<TGenerics>;
|
|
33
|
-
getHeaderGroupProps: <TGetter extends Getter<HeaderGroupProps>>(id: string, userProps?: TGetter) => undefined | PropGetterValue<HeaderGroupProps, TGetter>;
|
|
34
|
-
getFooterGroupProps: <TGetter extends Getter<FooterGroupProps>>(id: string, userProps?: TGetter) => undefined | PropGetterValue<FooterGroupProps, TGetter>;
|
|
35
|
-
getHeaderProps: <TGetter extends Getter<HeaderProps>>(headerId: string, userProps?: TGetter) => undefined | PropGetterValue<HeaderProps, TGetter>;
|
|
36
|
-
getFooterProps: <TGetter extends Getter<FooterProps>>(headerId: string, userProps?: TGetter) => undefined | PropGetterValue<FooterProps, TGetter>;
|
|
37
|
-
getTotalWidth: () => number;
|
|
38
|
-
};
|
|
39
|
-
export declare const Headers: {
|
|
40
|
-
createRow: <TGenerics extends Partial<import("../types").DefaultGenerics>>(row: Row<TGenerics>, instance: TableInstance<TGenerics>) => HeadersRow<TGenerics>;
|
|
41
|
-
getInstance: <TGenerics_1 extends Partial<import("../types").DefaultGenerics>>(instance: TableInstance<TGenerics_1>) => HeadersInstance<TGenerics_1>;
|
|
42
|
-
};
|
|
43
|
-
export declare function buildHeaderGroups<TGenerics extends PartialGenerics>(allColumns: Column<TGenerics>[], columnsToGroup: Column<TGenerics>[], instance: TableInstance<TGenerics>, headerFamily?: 'center' | 'left' | 'right'): HeaderGroup<TGenerics>[];
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
import { PartialGenerics, Row } from './types';
|
|
2
|
-
export declare const filterTypes: {
|
|
3
|
-
includesString: typeof includesString;
|
|
4
|
-
includesStringSensitive: typeof includesStringSensitive;
|
|
5
|
-
equalsString: typeof equalsString;
|
|
6
|
-
equalsStringSensitive: typeof equalsStringSensitive;
|
|
7
|
-
arrIncludes: typeof arrIncludes;
|
|
8
|
-
arrIncludesAll: typeof arrIncludesAll;
|
|
9
|
-
equals: typeof equals;
|
|
10
|
-
weakEquals: typeof weakEquals;
|
|
11
|
-
betweenNumberRange: typeof betweenNumberRange;
|
|
12
|
-
};
|
|
13
|
-
export declare type BuiltInFilterType = keyof typeof filterTypes;
|
|
14
|
-
declare function includesString<TGenerics extends PartialGenerics>(rows: Row<TGenerics>[], columnIds: string[], filterValue: unknown): Row<TGenerics>[];
|
|
15
|
-
declare namespace includesString {
|
|
16
|
-
var autoRemove: (val: any) => boolean;
|
|
17
|
-
}
|
|
18
|
-
declare function includesStringSensitive<TGenerics extends PartialGenerics>(rows: Row<TGenerics>[], columnIds: string[], filterValue: unknown): Row<TGenerics>[];
|
|
19
|
-
declare namespace includesStringSensitive {
|
|
20
|
-
var autoRemove: (val: any) => boolean;
|
|
21
|
-
}
|
|
22
|
-
declare function equalsString<TGenerics extends PartialGenerics>(rows: Row<TGenerics>[], columnIds: string[], filterValue: unknown): Row<TGenerics>[];
|
|
23
|
-
declare namespace equalsString {
|
|
24
|
-
var autoRemove: (val: any) => boolean;
|
|
25
|
-
}
|
|
26
|
-
declare function equalsStringSensitive<TGenerics extends PartialGenerics>(rows: Row<TGenerics>[], columnIds: string[], filterValue: unknown): Row<TGenerics>[];
|
|
27
|
-
declare namespace equalsStringSensitive {
|
|
28
|
-
var autoRemove: (val: any) => boolean;
|
|
29
|
-
}
|
|
30
|
-
declare function arrIncludes<TGenerics extends PartialGenerics>(rows: Row<TGenerics>[], columnIds: string[], filterValue: unknown): Row<TGenerics>[];
|
|
31
|
-
declare namespace arrIncludes {
|
|
32
|
-
var autoRemove: (val: any) => boolean;
|
|
33
|
-
}
|
|
34
|
-
declare function arrIncludesAll<TGenerics extends PartialGenerics>(rows: Row<TGenerics>[], columnIds: string[], filterValue: unknown[]): Row<TGenerics>[];
|
|
35
|
-
declare namespace arrIncludesAll {
|
|
36
|
-
var autoRemove: (val: any) => boolean;
|
|
37
|
-
}
|
|
38
|
-
declare function equals<TGenerics extends PartialGenerics>(rows: Row<TGenerics>[], columnIds: string[], filterValue: unknown): Row<TGenerics>[];
|
|
39
|
-
declare namespace equals {
|
|
40
|
-
var autoRemove: (val: any) => boolean;
|
|
41
|
-
}
|
|
42
|
-
declare function weakEquals<TGenerics extends PartialGenerics>(rows: Row<TGenerics>[], columnIds: string[], filterValue: unknown): Row<TGenerics>[];
|
|
43
|
-
declare namespace weakEquals {
|
|
44
|
-
var autoRemove: (val: any) => boolean;
|
|
45
|
-
}
|
|
46
|
-
declare function betweenNumberRange<TGenerics extends PartialGenerics>(rows: Row<TGenerics>[], columnIds: string[], filterValue: [unknown, unknown]): Row<TGenerics>[];
|
|
47
|
-
declare namespace betweenNumberRange {
|
|
48
|
-
var autoRemove: (val: any) => boolean;
|
|
49
|
-
}
|
|
50
|
-
export {};
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { PartialGenerics, Row } from './types';
|
|
2
|
-
export declare const reSplitAlphaNumeric: RegExp;
|
|
3
|
-
export declare const sortTypes: {
|
|
4
|
-
alphanumeric: typeof alphanumeric;
|
|
5
|
-
alphanumericCaseSensitive: typeof alphanumericCaseSensitive;
|
|
6
|
-
text: typeof text;
|
|
7
|
-
textCaseSensitive: typeof textCaseSensitive;
|
|
8
|
-
datetime: typeof datetime;
|
|
9
|
-
basic: typeof basic;
|
|
10
|
-
};
|
|
11
|
-
export declare type BuiltInSortType = keyof typeof sortTypes;
|
|
12
|
-
declare function alphanumeric<TGenerics extends PartialGenerics>(rowA: Row<TGenerics>, rowB: Row<TGenerics>, columnId: string): number;
|
|
13
|
-
declare function alphanumericCaseSensitive<TGenerics extends PartialGenerics>(rowA: Row<TGenerics>, rowB: Row<TGenerics>, columnId: string): number;
|
|
14
|
-
declare function text<TGenerics extends PartialGenerics>(rowA: Row<TGenerics>, rowB: Row<TGenerics>, columnId: string): 0 | 1 | -1;
|
|
15
|
-
declare function textCaseSensitive<TGenerics extends PartialGenerics>(rowA: Row<TGenerics>, rowB: Row<TGenerics>, columnId: string): 0 | 1 | -1;
|
|
16
|
-
declare function datetime<TGenerics extends PartialGenerics>(rowA: Row<TGenerics>, rowB: Row<TGenerics>, columnId: string): 0 | 1 | -1;
|
|
17
|
-
declare function basic<TGenerics extends PartialGenerics>(rowA: Row<TGenerics>, rowB: Row<TGenerics>, columnId: string): 0 | 1 | -1;
|
|
18
|
-
export {};
|
package/src/.DS_Store
DELETED
|
Binary file
|
package/src/aggregationTypes.ts
DELETED
|
@@ -1,115 +0,0 @@
|
|
|
1
|
-
export const aggregationTypes = {
|
|
2
|
-
sum,
|
|
3
|
-
min,
|
|
4
|
-
max,
|
|
5
|
-
extent,
|
|
6
|
-
mean,
|
|
7
|
-
median,
|
|
8
|
-
unique,
|
|
9
|
-
uniqueCount,
|
|
10
|
-
count,
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
export type BuiltInAggregationType = keyof typeof aggregationTypes
|
|
14
|
-
|
|
15
|
-
function sum(_leafValues: unknown[], childValues: unknown[]) {
|
|
16
|
-
// It's faster to just add the aggregations together instead of
|
|
17
|
-
// process leaf nodes individually
|
|
18
|
-
return childValues.reduce(
|
|
19
|
-
(sum: number, next: unknown) => sum + (typeof next === 'number' ? next : 0),
|
|
20
|
-
0
|
|
21
|
-
)
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
function min(_leafValues: unknown[], childValues: unknown[]) {
|
|
25
|
-
let min: number | undefined
|
|
26
|
-
|
|
27
|
-
for (const value of childValues as number[]) {
|
|
28
|
-
if (
|
|
29
|
-
value != null &&
|
|
30
|
-
(min! > value || (min === undefined && value >= value))
|
|
31
|
-
) {
|
|
32
|
-
min = value
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
return min
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
function max(_leafValues: unknown[], childValues: unknown[]) {
|
|
40
|
-
let max: number | undefined
|
|
41
|
-
|
|
42
|
-
for (const value of childValues as number[]) {
|
|
43
|
-
if (
|
|
44
|
-
value != null &&
|
|
45
|
-
(max! < value || (max === undefined && value >= value))
|
|
46
|
-
) {
|
|
47
|
-
max = value
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
return max
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
function extent(_leafValues: unknown[], childValues: unknown[]) {
|
|
55
|
-
let min: number | undefined
|
|
56
|
-
let max: number | undefined
|
|
57
|
-
|
|
58
|
-
for (const value of childValues as number[]) {
|
|
59
|
-
if (value != null) {
|
|
60
|
-
if (min === undefined) {
|
|
61
|
-
if (value >= value) min = max = value
|
|
62
|
-
} else {
|
|
63
|
-
if (min > value) min = value
|
|
64
|
-
if (max! < value) max = value
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
return [min, max]
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
function mean(leafValues: unknown[]) {
|
|
73
|
-
let count = 0
|
|
74
|
-
let sum = 0
|
|
75
|
-
|
|
76
|
-
for (let value of leafValues as number[]) {
|
|
77
|
-
if (value != null && (value = +value) >= value) {
|
|
78
|
-
++count, (sum += value)
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
if (count) return sum / count
|
|
83
|
-
|
|
84
|
-
return
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
function median(values: unknown[]) {
|
|
88
|
-
if (!values.length) {
|
|
89
|
-
return
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
let min = 0
|
|
93
|
-
let max = 0
|
|
94
|
-
|
|
95
|
-
values.forEach(value => {
|
|
96
|
-
if (typeof value === 'number') {
|
|
97
|
-
min = Math.min(min, value)
|
|
98
|
-
max = Math.max(max, value)
|
|
99
|
-
}
|
|
100
|
-
})
|
|
101
|
-
|
|
102
|
-
return (min + max) / 2
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
function unique<T>(values: T[]) {
|
|
106
|
-
return Array.from(new Set(values).values())
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
function uniqueCount(values: unknown[]) {
|
|
110
|
-
return new Set(values).size
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
function count(values: unknown[]) {
|
|
114
|
-
return values.length
|
|
115
|
-
}
|