UNPKG

@alessiofrittoli/web-utils

Version:
102 lines (100 loc) 2.83 kB
/** * Check whether Node.js runtime environment is in development mode. * * @returns True if current runtime environment is in development environment, false otherwise. */ declare const isDev: () => boolean; /** * Check whether Node.js runtime environment is in test mode. * * @returns True if current runtime environment is in test environment, false otherwise. */ declare const isTest: () => boolean; /** * Check whether result is a Promise. * * @param p The result to check. * @returns True if result is a Promise, false otherwise. */ declare const isPromise: <T>(p: unknown) => p is Promise<T>; /** * Check whether variable is an AsyncFunction. * * @param f The variable to check. * @returns True if variable is an AsyncFunction, false otherwise. */ declare const isAsyncFunction: <T extends CallableFunction>(f: T) => f is T; /** * Check whether a variable is a string or not. * * @param s The variable to check. * @returns boolean */ declare const isString: (s: unknown) => s is string; /** * Check if object is array. * * @param a The object / array to check. * * @returns boolean */ declare const isArray: (a: unknown) => a is Array<unknown>; /** * Check whether an Array is an empty Array. * * @param a The Array to check. * @returns True if the Array has no entries, false otherwise. */ declare const isEmptyArray: <T>(a: Array<T>) => boolean; /** * Check if object is an object. * * @param a The object / array to check. * * @returns boolean */ declare const isObject: (a: unknown) => a is object; /** * Check whether an object is an empty object. * * @param obj The object to check. * @returns True if the object has no entries, false otherwise. */ declare const isEmptyObject: (obj: object) => boolean; /** * Check if string is a valid JSON object. * * @param string * * @returns boolean */ declare const isJson: (string: unknown) => string is string; /** * Check whether a variable is a NodeList or not. * * @param n The variable to check. * @returns boolean */ declare const isNodeList: (n: unknown) => n is NodeList; /** * Check whether a variable is an HTML DOM Element or not. * * @param e The variable to check. * @returns boolean */ declare const isNodeElement: (e: unknown) => e is Element; /** * Check if event is a TouchEvent. * * @param event The native event interface. * * @returns True if event is TouchEvent, false otherwise. */ declare const isTouchEvent: (event: Event) => event is TouchEvent; /** * Check if device is a Touch device. * * @returns True if device is a Touch device, false otherwise. */ declare const isTouchDevice: () => boolean; export { isArray, isAsyncFunction, isDev, isEmptyArray, isEmptyObject, isJson, isNodeElement, isNodeList, isObject, isPromise, isString, isTest, isTouchDevice, isTouchEvent };