UNPKG

datadancer

Version:

## What is DataDancer?

308 lines (298 loc) 7.46 kB
declare abstract class Base { /** * fields */ /** * properties */ /** * constructor */ constructor(); /** * methods */ /** * protected Methods */ protected $_forLoop(start: number, end: number, customFunc: (index?: number) => void, isReverse?: boolean): void; protected $_ranRangeNum(min: number, max: number): number; } declare type Deviation = { origin: number[]; avarage: number; deviation: number[]; }; declare type StandardDeviation = { variance: number; standardDeviation: number; }; declare type MinMax = { min: number; max: number; }; declare class NumberMethods extends Base { /** * fields */ private a; /** * properties */ /** * constructor */ constructor(); /** * methods */ /** * you can get number of fixed digit randomly * * (digit: number, isString?: boolean, zeroFixBackDigit?: number) */ getRanDigitNum(digit: number, isString?: boolean, zeroFixBackDigit?: number): any; /** * you can get number from a to b randomly * * (start: number, end: number) */ getRanRangeNum(start: number, end: number): number; /** * you can get sum value of number array * * (arr: number[]) */ sum(arr: number[]): number; /** * you can get avarage value of number array * * (arr: number[]) */ avarage(arr: number[]): number; /** * you can get deviation value of number array * * (arr: number[]) */ deviation(arr: number[]): Deviation; /** * you can get variance value of number array * * (arr: number[]) */ variance(arr: number[]): number; /** * you can get standardDeviation value of number array * * (arr: number[]) */ standardDeviation(arr: number[]): StandardDeviation; /** * you can get minimum and maximum value of number array * * (arr: number[]) */ getMinMax(arr: number[]): MinMax; } declare type Language = 'eng' | 'kor' | 'jp' | 'chi' | 'india' | 'hindi' | 'german'; declare type Gender = 'male' | 'female'; declare class StringMethods extends Base { /** * fields */ /** * properties */ /** * constructor */ constructor(); /** * methods */ /** * nameGenerator * * support eng, japan, korea, chinese, India name * * if you generate eng, japanese, chinese, India, Hindi, German Name, you can choose gender * * (lang?: "kor" | "eng" | "jp" | "chi" | "india" | "hindi" | "german", gender?: "male" | "female") */ nameGenerator(lang?: Language, gender?: Gender): string; /** * you can get password Randomly, use sum nameGenerator function. * * Password must be set at least 4 digits. * * Default return password value is only inludes String. * * If you want to inlude number or symbol or both in password, * * you can also set it * * (digit: number, include?: "string" | "all" | "number" | "symbol") */ passwordGenerator(digit: number, include?: 'string' | 'all' | 'number' | 'symbol'): string | false; } declare class VisualMethods extends Base { /** * fields */ /** * properties */ /** * constructor */ constructor(); /** * methods */ /** * 입력된 클래스 또는 아이디의 DOM 정보를 가져온다. * DOM과 해당 Dom과 관련된 정보(className, onClick, style 등등)들을 반환 * * (type: "id" or "class", name: className or idName) */ /** * you can get color randomly. * * (type: "rgb" | "code") */ colorGenerator(type?: 'rgb' | 'code'): string; /** * you can get gradient randomly * (direction?: "to right" | "to left" | "to top" | "to bottom") */ gradientGenerator(direction?: 'to right' | 'to left' | 'to top' | 'to bottom'): string; } declare class DateMethods { /** * fields */ /** * properties */ /** * constructor */ constructor(); /** * methods */ /** * If you have 2 Date Type Object, dateCompare function gives you which date is latest. * * (fastDate: Date, latestDate: Date) */ dateCompare(fastDate: Date, latestDate: Date): boolean; /** * you can get Date Type Object to String with your own Custom Form * * (date: Date, form: string) */ getFormDate(date: Date, form: string): string; /** * add Year to Date type Object * * (date: Date, years: number) */ addYear(date: Date, years: number): Date; /** * add Month to Date type Object * * (date: Date, months: number) */ addMonths(date: Date, months: number): Date; /** * add Day to Date type Object * * (date: Date, dates: number) */ addDays(date: Date, dates: number): Date; /** * you can get day of the week to String type, use getDayOfWeek * * It support language English, Korean, Japanese, Chinese, India, Hindi, German * * (date: Date, lang?: "eng" | "kor" | "jp" | "chi" | "india" | "hindi" | "german") */ getDayOfWeek(date: Date, lang?: Language): string; } declare class ArrayMethods extends Base { /** * fields */ /** * properties */ /** * constructor */ constructor(); /** * methods */ /** * This is quick sort. * * You can also sorting object array by key. * * (arr: any[], key?: string) */ quickSort(arr: any[], key?: string): any; /** * It is a search function that allows you to quickly search in an array sorted in ascending order. * * You can also search object array by key. * * (arr: any[], search: any, key?: string) */ binarySearch(arr: any[], search: any, key?: string): false | { idx: number; val: any; }; /** * you can search value of index in array or object array, use linearSearch * * You can also search object array by key. * * (arr: any[], search: any, key?: string) */ linearSearch(arr: any[], search: any, key?: string): false | { idx: number; val: any; }; /** * remove the middle element of an array * * It is also possible to remove multiple middle elements of an array. * * (arr: any[], target: number | number[]) */ rmMiddleArrIdx(arr: any[], target: number | number[]): any[]; /** * you can get the elements of an array randomly, use getRanElement. * * It is also possible to get multiple random elements of an array. * * (arr: any[], howMany?: number) */ getRanElement(arr: any[], howMany?: number): any; /** * internal member */ private $_binarySearchAl; } declare const arr: typeof ArrayMethods; declare class DataDancer { static NumberMethods: typeof NumberMethods; static StringMethods: typeof StringMethods; static VisualMethods: typeof VisualMethods; static DateMethods: typeof DateMethods; static ArrayMethods: typeof ArrayMethods; } export default DataDancer; export { DateMethods, NumberMethods, StringMethods, VisualMethods, arr };