@mikezimm/npmfunctions
Version:
Functions used in my SPFx webparts
107 lines (104 loc) • 6.32 kB
TypeScript
/***
* .d8b. d8888b. d8888b. .d8b. db db .d8888.
* d8' `8b 88 `8D 88 `8D d8' `8b `8b d8' 88' YP
* 88ooo88 88oobY' 88oobY' 88ooo88 `8bd8' `8bo.
* 88~~~88 88`8b 88`8b 88~~~88 88 `Y8b.
* 88 88 88 `88. 88 `88. 88 88 88 db 8D
* YP YP 88 YD 88 YD YP YP YP `8888Y'
*
*
//Sorting
import { sortStringArray, sortObjectArrayByStringKey, sortNumberArray, sortObjectArrayByNumberKey, sortKeysByOtherKey
} from '@mikezimm/npmfunctions/dist/Services/arraySorting';
*/
/**
*
* export interface
* export interface
* export interface
*
* export function sortStringArray
* export function sortObjectArrayByStringKey
* export function sortNumberArray
* export function sortObjectArrayByNumberKey
* export function sortKeysByOtherKey
*
*/
import { ISeriesSort } from '../../CSSCharts/ICSSCharts';
/***
* .d8888. .d88b. d8888b. d888888b .d8888. d888888b d8888b. d888888b d8b db d888b .d8b. d8888b. d8888b. .d8b. db db
* 88' YP .8P Y8. 88 `8D `~~88~~' 88' YP `~~88~~' 88 `8D `88' 888o 88 88' Y8b d8' `8b 88 `8D 88 `8D d8' `8b `8b d8'
* `8bo. 88 88 88oobY' 88 `8bo. 88 88oobY' 88 88V8o 88 88 88ooo88 88oobY' 88oobY' 88ooo88 `8bd8'
* `Y8b. 88 88 88`8b 88 `Y8b. 88 88`8b 88 88 V8o88 88 ooo 88~~~88 88`8b 88`8b 88~~~88 88
* db 8D `8b d8' 88 `88. 88 db 8D 88 88 `88. .88. 88 V888 88. ~8~ 88 88 88 `88. 88 `88. 88 88 88
* `8888Y' `Y88P' 88 YD YP `8888Y' YP 88 YD Y888888P VP V8P Y888P YP YP 88 YD 88 YD YP YP YP
*
* 2020-12-14
* sortStringArray was added to remove typescript errors in sortKeysByOtherKey
* @param arr
* @param order
*/
export declare function sortStringArray(arr: string[], order: ISeriesSort, convertNullToEmpty?: boolean): string[];
export declare function sortStringArrayCollator(arr: string[], order: ISeriesSort, convertNullToEmpty?: boolean, localLanguage?: string): string[];
export declare function sortObjectArrayByStringKey(arr: any[], order: ISeriesSort, key: string): any[];
/**
*
*
* NOTE sortObjectArrayByStringKeyCollator HAS NOT BEEN TESTED IN ANY WAY.
* JUST MODIFIED based upon sortStringArrayCollator
*
* @param arr
* @param order
* @param key
* @param convertNullToEmpty
* @param localLanguage
*/
export declare function sortObjectArrayByStringKeyCollator(arr: any[], order: ISeriesSort, key: string, convertNullToEmpty?: boolean, localLanguage?: string): any[];
/***
* .d8888. .d88b. d8888b. d888888b d8b db db db .88b d88. d8888b. d88888b d8888b. .d8b. d8888b. d8888b. .d8b. db db
* 88' YP .8P Y8. 88 `8D `~~88~~' 888o 88 88 88 88'YbdP`88 88 `8D 88' 88 `8D d8' `8b 88 `8D 88 `8D d8' `8b `8b d8'
* `8bo. 88 88 88oobY' 88 88V8o 88 88 88 88 88 88 88oooY' 88ooooo 88oobY' 88ooo88 88oobY' 88oobY' 88ooo88 `8bd8'
* `Y8b. 88 88 88`8b 88 88 V8o88 88 88 88 88 88 88~~~b. 88~~~~~ 88`8b 88~~~88 88`8b 88`8b 88~~~88 88
* db 8D `8b d8' 88 `88. 88 88 V888 88b d88 88 88 88 88 8D 88. 88 `88. 88 88 88 `88. 88 `88. 88 88 88
* `8888Y' `Y88P' 88 YD YP VP V8P ~Y8888P' YP YP YP Y8888P' Y88888P 88 YD YP YP 88 YD 88 YD YP YP YP
*
*
* 2020-12-14
* sortNumberArray was added to remove typescript errors in sortKeysByOtherKey
* @param arr
* @param order
*
* NOTE PER DOCS: Sorts as strings
* The sort() sorts the elements as strings in alphabetical and ascending order.
*/
export declare function sortNumberArray(arr: number[], order: ISeriesSort): number[];
export declare function sortObjectArrayByNumberKey(arr: any[], order: ISeriesSort, key: string): any[];
/**
* This is different from sortObjectArrayByNumberKey in that you can look at nested children.
* In the case of ExtremeContents:
* There is an array of File types call infoTypes
* I wanted to sort by type.summary.keyToSortBy.
* This will let you pass in a key string like: key ='summary.count' and it will look at the children objects.
* NOTE: The keys are determined using the '.'
*
* @param arr
* @param order
* @param key
*/
export declare function sortObjectArrayByChildNumberKey(arr: any[], order: ISeriesSort, key: string): any[];
/***
* .d8888. .d88b. d8888b. d888888b db dD d88888b db db .d8888. d8888b. db db .d88b. d888888b db db d88888b d8888b. db dD d88888b db db
* 88' YP .8P Y8. 88 `8D `~~88~~' 88 ,8P' 88' `8b d8' 88' YP 88 `8D `8b d8' .8P Y8. `~~88~~' 88 88 88' 88 `8D 88 ,8P' 88' `8b d8'
* `8bo. 88 88 88oobY' 88 88,8P 88ooooo `8bd8' `8bo. 88oooY' `8bd8' 88 88 88 88ooo88 88ooooo 88oobY' 88,8P 88ooooo `8bd8'
* `Y8b. 88 88 88`8b 88 88`8b 88~~~~~ 88 `Y8b. 88~~~b. 88 88 88 88 88~~~88 88~~~~~ 88`8b 88`8b 88~~~~~ 88
* db 8D `8b d8' 88 `88. 88 88 `88. 88. 88 db 8D 88 8D 88 `8b d8' 88 88 88 88. 88 `88. 88 `88. 88. 88
* `8888Y' `Y88P' 88 YD YP YP YD Y88888P YP `8888Y' Y8888P' YP `Y88P' YP YP YP Y88888P 88 YD YP YD Y88888P YP
*
* 2020-12-14
* This function caused errors in TrackMyTime which was based on @yo 1.9.1 but works in Drilldown and ActionNews @yo 1.11.0
*
* Cannot invoke an expression whose type lacks a call signature. Type '((compareFn?: (a: string, b: string) => number) => string[]) | ((compareFn?: (a: number, b: numbe...' has no compatible call signatures.
*
* Rebuilt and added sortNumberArray and sortStringArray and it seems to work ok.
*/
export declare function sortKeysByOtherKey(obj: any, sortKey: ISeriesSort, order: ISeriesSort, dataType: 'number' | 'string', otherKeys: string[], convertNullToEmpty?: boolean, localLanguage?: string): any;