UNPKG

@kwiz/common

Version:

KWIZ common utilities and helpers for M365 platform

58 lines (57 loc) 3.86 kB
/** check if a global object in that full name exists and return its type or "undefined" */ export declare function typeofFullName(fullName: string, windowOrParent?: Window | any): "string" | "number" | "bigint" | "boolean" | "symbol" | "undefined" | "object" | "function"; /** get the value by full name of property */ export declare function getFromFullName<T>(fullName: string, windowOrParent?: Window | any): T; export declare function isTypeofFullNameObject(fullName: string, windowOrParent?: Window | any): boolean; export declare function isTypeofFullNameString(fullName: string, windowOrParent?: Window | any): boolean; export declare function isTypeofFullNameNumber(fullName: string, windowOrParent?: Window | any): boolean; export declare function isTypeofFullNameNullOrUndefined(fullName: string, windowOrParent?: Window | any): boolean; export declare function isTypeofFullNameUndefined(fullName: string, windowOrParent?: Window | any): boolean; export declare function isTypeofFullNameFunction(fullName: string, windowOrParent?: Window | any): boolean; export declare function isTypeofFullNameBoolean(fullName: string, windowOrParent?: Window | any): boolean; export declare function isType(obj: any, str: string): boolean; export declare function isObject(obj: any): obj is object; /** Checks if obj is empty - as primitive, array or object * If an object, pass an optional array of keys to ignore */ export declare function isEmptyObject(obj: any, options?: { ignoreKeys?: string[]; }): boolean; export declare function isNullOrUndefined(obj: any): boolean; /** return true if o is undefined, null or not a number */ export declare function isNullOrNaN(o: any): boolean; /** return true if o is undefined, null or empty string */ export declare function isNullOrEmptyString(o: any): o is null | undefined | ""; /** o is an array that is not empty (length > 0) */ export declare function isNotEmptyArray(o: any): o is any[]; /** o is undefined, null or an empty array */ export declare function isNullOrEmptyArray(o: any): boolean; export declare function isString(obj: any): obj is string; export declare function isNotEmptyString(obj: any): obj is string; /** true if object is a Date object */ export declare function isDate(obj: any): obj is Date; /** true if obj is a number or a numeric string */ export declare function isNumeric(obj: any): obj is number | string; /** true if obj is a number */ export declare function isNumber(obj?: any): obj is number; export declare function isNumberArray(obj: any[]): obj is number[]; export declare function isUndefined(obj: any): obj is undefined; export declare function isFunction(obj: any): obj is Function; export declare function isBoolean(obj: any): obj is boolean; export declare function isPromise<t>(obj: any): obj is Promise<t>; export type primitiveTypes = string | number | Date | boolean | null; /**returns true if object is string, number, date, boolean value or null*/ export declare function isPrimitiveValue(obj: any): obj is primitiveTypes; export declare function isValidGuid(str: string): boolean; export declare var BoolTrueStrings: string[]; export declare var BoolFalseStrings: string[]; export declare function isTrueString(str: string, options?: { allowPositiveNumbers?: boolean; }): boolean; export declare function newGuid(): string; /** check if object has all members (they are not undefined) */ export declare function hasMembers(o: any, ...members: string[]): boolean; /** compares 2 versions. if v1 is bigger return 1, if v2 is bigger returns -1, if equals return 0 */ export declare function CompareVersion(v1: string, v2: string): 0 | 1 | -1; /** pass along a list of unsafe tests to get a value, the first one that doesn't throw an exception and doesnt return null will get returned */ export declare function SafeIfElse<T>(...list: ((() => T) | T)[]): T;