@mikezimm/npmfunctions
Version:
Functions used in my SPFx webparts
143 lines (140 loc) • 9.25 kB
TypeScript
/***
* .d8888. d888888b d8888b. d888888b d8b db d888b .d8888.
* 88' YP `~~88~~' 88 `8D `88' 888o 88 88' Y8b 88' YP
* `8bo. 88 88oobY' 88 88V8o 88 88 `8bo.
* `Y8b. 88 88`8b 88 88 V8o88 88 ooo `Y8b.
* db 8D 88 88 `88. .88. 88 V888 88. ~8~ db 8D
* `8888Y' YP 88 YD Y888888P VP V8P Y888P `8888Y'
*
*
import { cleanSPListURL, cleanURL, encodeDecodeString, } from '@mikezimm/npmfunctions/dist/Services/Strings/urlServices';
import { makeid, isGuidgetStringArrayFromString, cleanEmptyElementsFromString } from '@mikezimm/npmfunctions/dist/Services/Strings/stringServices';
import { camelToSentanceCase, camelize, randomizeCase, upperFirstLetter, lowerFirstLetter } from '@mikezimm/npmfunctions/dist/Services/Strings/stringCase';
*/
import { ISeriesSort } from '../../CSSCharts/ICSSCharts';
/***
* db db d8888b. d8888b. .d8b. d888888b d88888b d8b db d88888b db db d888888b .d88b. d8888b. d88888b d8b db d888888b d8b db d8888b. d88888b db db
* 88 88 88 `8D 88 `8D d8' `8b `~~88~~' 88' 888o 88 88' `8b d8' `~~88~~' .8P Y8. 88 `8D 88' 888o 88 `88' 888o 88 88 `8D 88' `8b d8'
* 88 88 88oodD' 88 88 88ooo88 88 88ooooo 88V8o 88 88ooooo `8bd8' 88 88 88 88oodD' 88ooooo 88V8o 88 88 88V8o 88 88 88 88ooooo `8bd8'
* 88 88 88~~~ 88 88 88~~~88 88 88~~~~~ 88 V8o88 88~~~~~ .dPYb. 88 88 88 88~~~ 88~~~~~ 88 V8o88 88 88 V8o88 88 88 88~~~~~ .dPYb.
* 88b d88 88 88 .8D 88 88 88 88. 88 V888 88. .8P Y8. 88 `8b d8' 88 88. 88 V888 .88. 88 V888 88 .8D 88. .8P Y8.
* ~Y8888P' 88 Y8888D' YP YP YP Y88888P VP V8P Y88888P YP YP YP `Y88P' 88 Y88888P VP V8P Y888888P VP V8P Y8888D' Y88888P YP YP
*
* import { updateNextOpenIndex } from '@mikezimm/npmfunctions/dist/Services/Strings/stringServices';
*/
export declare function updateNextOpenIndex(targetArray: any[], start: number, value: any): any[];
/***
* .88b d88. .d8b. db dD d88888b d888888b d8888b.
* 88'YbdP`88 d8' `8b 88 ,8P' 88' `88' 88 `8D
* 88 88 88 88ooo88 88,8P 88ooooo 88 88 88
* 88 88 88 88~~~88 88`8b 88~~~~~ 88 88 88
* 88 88 88 88 88 88 `88. 88. .88. 88 .8D
* YP YP YP YP YP YP YD Y88888P Y888888P Y8888D'
*
*
*/
export declare function makeid(length: number): string;
/***
* d888888b .d8888. d888b db db d888888b d8888b.
* `88' 88' YP 88' Y8b 88 88 `88' 88 `8D
* 88 `8bo. 88 88 88 88 88 88
* 88 `Y8b. 88 ooo 88 88 88 88 88
* .88. db 8D 88. ~8~ 88b d88 .88. 88 .8D
* Y888888P `8888Y' Y888P ~Y8888P' Y888888P Y8888D'
*
*
*/
/**
* Regex courtesy of: https://stackoverflow.com/a/13653180/4210807
*
* NOTES:
* ^ at the beginning denotes the test string must START with that: ^ asserts position at start of the string
* ^ at the beginning denotes the test string must END with that: $ asserts position at the end of the string, or before the line terminator right at the end of the string (if any)
* [0-9a-f]{8} - 8 characters between 0-9 and a-f
* [0-9a-f]{4} - 4 characters between 0-9 and a-f
* [1-5][0-9a-f]{3} - one character between 1-5 and 3 between 0-9 and a-f
* [1-5][0-9a-f]{3} - one character between 1-5 and 3 between 0-9 and a-f
* [0-9a-f]{12} - 12 characters between 0-9 and a-f
*
*/
export declare const ValidGuidRegexExact: RegExp;
export declare const ValidGuidRegexStart: RegExp;
export declare const ValidGuidRegexEnd: RegExp;
export declare const ValidGuidRegexContains: RegExp;
export declare const ValidGuidRegexExactGlobal: RegExp;
export declare const ValidGuidRegexStartGlobal: RegExp;
export declare const ValidGuidRegexEndGlobal: RegExp;
export declare const ValidGuidRegexContainsGlobal: RegExp;
export declare type IIsGuidTestLocation = 'exact' | 'start' | 'end' | 'contains';
export declare function isGuid(input: any, compareType?: IIsGuidTestLocation): boolean;
/**
* getGuidsFromString is similar to isGuid except it returns the guid(s) found in the string
*
* https://regex101.com/
*
* Returns null if no guid is found.
* Returns array of string containing the first guid found in the string ( g modifier: global. All matches (don't return after first match) )
*
* @param testMe
* @param compareType
*/
export declare function getGuidsFromString(input: any, compareType?: IIsGuidTestLocation): any;
/***
* d888b d88888b d888888b .d8888. d888888b d8888b. d888888b d8b db d888b .d8b. d8888b. d8888b. .d8b. db db
* 88' Y8b 88' `~~88~~' 88' YP `~~88~~' 88 `8D `88' 888o 88 88' Y8b d8' `8b 88 `8D 88 `8D d8' `8b `8b d8'
* 88 88ooooo 88 `8bo. 88 88oobY' 88 88V8o 88 88 88ooo88 88oobY' 88oobY' 88ooo88 `8bd8'
* 88 ooo 88~~~~~ 88 `Y8b. 88 88`8b 88 88 V8o88 88 ooo 88~~~88 88`8b 88`8b 88~~~88 88
* 88. ~8~ 88. 88 db 8D 88 88 `88. .88. 88 V888 88. ~8~ 88 88 88 `88. 88 `88. 88 88 88
* Y888P Y88888P YP `8888Y' YP 88 YD Y888888P VP V8P Y888P YP YP 88 YD 88 YD YP YP YP
*
*
* d88888b d8888b. .d88b. .88b d88. .d8888. d888888b d8888b. d888888b d8b db d888b
* 88' 88 `8D .8P Y8. 88'YbdP`88 88' YP `~~88~~' 88 `8D `88' 888o 88 88' Y8b
* 88ooo 88oobY' 88 88 88 88 88 `8bo. 88 88oobY' 88 88V8o 88 88
* 88~~~ 88`8b 88 88 88 88 88 `Y8b. 88 88`8b 88 88 V8o88 88 ooo
* 88 88 `88. `8b d8' 88 88 88 db 8D 88 88 `88. .88. 88 V888 88. ~8~
* YP 88 YD `Y88P' YP YP YP `8888Y' YP 88 YD Y888888P VP V8P Y888P
*
*
*/
/** was: cleanProjEditOptions from TrackMyTime7
* This function takes a string with ;, converts to array of strings and removes empty elements (like if ; is at the end.)
*
* example input: ";test;this;string;;now;"
* example result: ['test','this','string','now']
*
* @param str
*
*
* @param delim - exactly what you pass or
* use delim = ',or;' || ';or,' to clean up string property pane values (uses 2 delimiters)
* @param trim - default = false. true will just remove any leading or trailing spaces from string value
*/
export declare function getStringArrayFromString(input: any, delim: string, removeEmpty: boolean, sort: 'asc' | 'dec' | null, trim?: boolean): string[] | null;
export declare function getNumberArrayFromString(input: string, delim: string, removeEmpty: boolean, removeZeros: boolean, order: ISeriesSort, def?: any): number[] | null;
/***
* .o88b. db d88888b .d8b. d8b db d88888b .88b d88. d8888b. d888888b db db d88888b db d88888b .88b d88. d88888b d8b db d888888b .d8888.
* d8P Y8 88 88' d8' `8b 888o 88 88' 88'YbdP`88 88 `8D `~~88~~' `8b d8' 88' 88 88' 88'YbdP`88 88' 888o 88 `~~88~~' 88' YP
* 8P 88 88ooooo 88ooo88 88V8o 88 88ooooo 88 88 88 88oodD' 88 `8bd8' 88ooooo 88 88ooooo 88 88 88 88ooooo 88V8o 88 88 `8bo.
* 8b 88 88~~~~~ 88~~~88 88 V8o88 88~~~~~ 88 88 88 88~~~ 88 88 88~~~~~ 88 88~~~~~ 88 88 88 88~~~~~ 88 V8o88 88 `Y8b.
* Y8b d8 88booo. 88. 88 88 88 V888 88. 88 88 88 88 88 88 88. 88booo. 88. 88 88 88 88. 88 V888 88 db 8D
* `Y88P' Y88888P Y88888P YP YP VP V8P Y88888P YP YP YP 88 YP YP Y88888P Y88888P Y88888P YP YP YP Y88888P VP V8P YP `8888Y'
*
*
* d88888b d8888b. .d88b. .88b d88. .d8888. d888888b d8888b. d888888b d8b db d888b
* 88' 88 `8D .8P Y8. 88'YbdP`88 88' YP `~~88~~' 88 `8D `88' 888o 88 88' Y8b
* 88ooo 88oobY' 88 88 88 88 88 `8bo. 88 88oobY' 88 88V8o 88 88
* 88~~~ 88`8b 88 88 88 88 88 `Y8b. 88 88`8b 88 88 V8o88 88 ooo
* 88 88 `88. `8b d8' 88 88 88 db 8D 88 88 `88. .88. 88 V888 88. ~8~
* YP 88 YD `Y88P' YP YP YP `8888Y' YP 88 YD Y888888P VP V8P Y888P
*
*
*/
/** was originally copied from cleanProjEditOptions from TrackMyTime7
* This function takes a string with ;, converts to array of strings and removes empty elements (like if ; is at the end.)
*
* example input: ";test;this;string;;now;"
* example result: "test;this;string;now"
* @param str
*/
export declare function cleanEmptyElementsFromString(input: any, delim: string, removeEmpty: boolean, sort: 'asc' | 'dec' | null): string;