Skip to content

Commit 4eee27d

Browse files
committed
Create utilities.class.js
1 parent ef14b81 commit 4eee27d

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

src/lib/utilities.class.js

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
class Utility {
2+
isEmpty = data => {
3+
let result;
4+
if (typeof data === 'array') result = this.#isArrayEmpty(data)
5+
if (typeof data === 'object') result = this.#isObjEmpty(data)
6+
7+
return result
8+
}
9+
10+
#isArrayEmpty = (data = []) => {
11+
return (data === undefined || data.length === 0) ? false : true
12+
}
13+
14+
#isObjEmpty = (data = {}) => {
15+
for (const prop in data)
16+
if (Object.hasOwn(data, prop)) return false
17+
return true
18+
}
19+
}
20+
21+
export default new Utility()

0 commit comments

Comments
 (0)