PluginProbe ʕ •ᴥ•ʔ
Everest Forms – Contact Form, Payment Form, Quiz, Survey & Custom Form Builder with AI / 3.5.2
Everest Forms – Contact Form, Payment Form, Quiz, Survey & Custom Form Builder with AI v3.5.2
3.5.2 3.5.1 3.5.0 3.4.8 3.4.7 3.4.6 1.1.0 1.1.1 1.1.2 1.1.3 1.1.4 1.1.5 1.1.5.1 1.1.6 1.1.7 1.1.8 1.1.9 1.2.0 1.2.1 1.2.2 1.2.3 1.2.4 1.3.0 1.3.1 1.3.2 1.3.3 1.3.4 1.4.0 1.4.1 1.4.2 1.4.3 1.4.4 1.4.5 1.4.6 1.4.7 1.4.8 1.4.9 1.5.0 1.5.1 1.5.10 1.5.2 1.5.3 1.5.4 1.5.5 1.5.6 1.5.7 1.5.8 1.5.9 1.6.0 1.6.1 1.6.2 1.6.3 1.6.4 1.6.5 1.6.6 1.6.6.1 1.6.7 1.7.0 1.7.0.1 1.7.0.2 1.7.0.3 1.7.1 1.7.2 1.7.2.1 1.7.2.2 1.7.3 1.7.4 1.7.5 1.7.5.1 1.7.5.2 1.7.6 1.7.7 1.7.7.1 1.7.7.2 1.7.8 1.7.9 1.8.0 1.8.0.1 1.8.1 1.8.2 1.8.2.1 1.8.2.2 1.8.2.3 1.8.3 1.8.4 1.8.5 1.8.6 1.8.7 1.8.8 1.8.9 1.9.0 1.9.0.1 1.9.1 1.9.2 1.9.3 1.9.4 1.9.4.1 1.9.5 1.9.6 1.9.7 1.9.8 1.9.9 2.0.0 2.0.0.1 2.0.1 2.0.2 2.0.3 2.0.3.1 2.0.4 2.0.4.1 2.0.5 2.0.6 2.0.7 2.0.8 2.0.8.1 2.0.9 3.0.0 3.0.0.1 3.0.1 3.0.2 3.0.3 3.0.3.1 3.0.4 3.0.4.1 3.0.4.2 3.0.5 3.0.5.1 3.0.5.2 3.0.6 3.0.6.1 3.0.7.1 3.0.8 3.0.8.1 3.0.9 3.0.9.1 3.0.9.2 3.0.9.3 3.0.9.4 3.0.9.5 3.1.0 3.1.1 3.1.2 3.2.0 3.2.1 3.2.2 3.2.3 3.2.4 3.2.5 3.2.6 3.3.0 3.4.0 3.4.1 3.4.2 3.4.2.1 3.4.3 3.4.4 3.4.5 trunk 1.0 1.0.1 1.0.2 1.0.3
everest-forms / src / dashboard / utils / utils.js
everest-forms / src / dashboard / utils Last commit date
constants.js 5 months ago utils.js 1 year ago
utils.js
93 lines
1 /**
2 * repr :: gets the string representation of `arg`
3 * @param {} arg :: unknown function argument
4 * @returns {String} :: a string representation of `arg`
5 */
6 export const repr = (arg) => {
7 return Object.prototype.toString.call(arg);
8 };
9
10 /**
11 * isArray
12 * @param {} arg :: unknown function argument
13 * @returns {Boolean} :: returns true if `arg` is an Array, false otherwise
14 */
15 export const isArray = (arg) => {
16 return Array.isArray ? Array.isArray(arg) : repr(arg) === "[object Array]";
17 };
18
19 /**
20 * isObject :: checks if `arg` is an object.
21 * @param {} arg :: unknown function argument
22 * @returns {Boolean} :: returns true if `arg` is an object.
23 */
24 export const isObject = (arg) => {
25 return repr(arg) === "[object Object]";
26 };
27
28 /**
29 * isString :: checks if `arg` is a string.
30 * @param {} arg :: unknown function argument
31 * @returns {Boolean} :: returns true if `arg` is a String, false otherwise
32 */
33 export const isString = (arg) => {
34 return repr(arg) === "[object String]";
35 };
36
37 /**
38 * isNumber :: checks if `arg` is a number.
39 * @param {} arg :: unknown function argument
40 * @returns {Boolean} :: returns true if `arg` is a Number, false otherwise
41 */
42 export const isNumber = (arg) => {
43 return repr(arg) === "[object Number]";
44 };
45
46 export const isFloat = (n) => {
47 return Number(n) === n && n % 1 !== 0;
48 };
49
50 /**
51 * isNull :: checks if `arg` is null.
52 * @param {} arg :: unknown function argument
53 * @returns {Boolean} :: returns true if `arg` is of type Null, false otherwise
54 */
55 export const isNull = (arg) => {
56 return repr(arg) === "[object Null]";
57 };
58
59 /**
60 * isUndefined :: checks if `arg` is undefined.
61 * @param {} arg :: unknown function argument
62 * @returns {Boolean} :: Returns true if `arg` is of type Undefined, false otherwise
63 */
64 export const isUndefined = (arg) => {
65 try {
66 return typeof arg === "undefined";
67 } catch (e) {
68 if (e instanceof ReferenceError) {
69 return true;
70 }
71
72 throw e;
73 }
74 };
75
76 /**
77 * isEmpty :: Checks if `arg` is an empty string, array, or object.
78 *
79 * @param {} arg :: unknown function argument
80 * @returns {Boolean} :: Returns true if `arg` is an empty string,
81 * array, or object. Also returns true is `arg` is null or
82 * undefined. Returns true otherwise.
83 */
84 export const isEmpty = (arg) => {
85 return (
86 isUndefined(arg) ||
87 isNull(arg) ||
88 (isString(arg) && arg.length === 0) ||
89 (isArray(arg) && arg.length === 0) ||
90 (isObject(arg) && Object.keys(arg).length === 0)
91 );
92 };
93