f7
f7 is a spreadsheet formula execution library
git clone https://git.vogt.world/f7.git
Log | Files | README.md | LICENSE.md
← All files
name: src/main/js/common/utils/Types.ts
-rw-r--r--
1522
 1/**
 2 * Is the value a function?
 3 * @param value
 4 */
 5import { AbstractStandardError } from "../errors/StandardError";
 6
 7export function isFunction<T>(value: T): boolean {
 8  return typeof value === "function";
 9}
10
11/**
12 * Is the value undefined?
13 * @param value
14 */
15export function isUndefined<T>(value: T): boolean {
16  return value === undefined;
17}
18
19/**
20 * Is the value NOT undefined? Could be null.
21 * @param value - to check
22 */
23export function isNotUndefined<T>(value: T) {
24  return value !== undefined;
25}
26
27/**
28 * Are any of the values undefined?
29 * @param values
30 */
31export function anyUndefined<T>(...values: Array<T>) {
32  for (const value of values) {
33    if (isUndefined(value)) {
34      return true;
35    }
36  }
37}
38
39/**
40 * Is the value null?
41 * @param value
42 */
43export function isNull<T>(value: T): boolean {
44  return value === null;
45}
46
47/**
48 * Is the value NOT null?
49 * @param value
50 */
51export function isNotNull<T>(value: T): boolean {
52  return value !== null;
53}
54
55/**
56 * Does the object have keys?
57 * @param input object to check
58 */
59export function hasKeys(input: { [index: string]: any } | { [index: number]: any }) {
60  return Object.keys(input).length > 0;
61}
62
63/**
64 * Is the value null or undefined?
65 * @param value to check.
66 */
67export function isNullOrUndefined<T>(value: T): boolean {
68  return value === null || value === undefined;
69}
70
71/**
72 * Cast value as standard error.
73 * @param value - to cast.
74 */
75export function asStandardError(value: any): AbstractStandardError {
76  return value as AbstractStandardError;
77}