File tree Expand file tree Collapse file tree 2 files changed +23
-5
lines changed Expand file tree Collapse file tree 2 files changed +23
-5
lines changed Original file line number Diff line number Diff line change 1
-
2
- Array . prototype . isEmpty = ( arr ) => {
3
- return ( arr === undefined || arr . length === 0 ) ? false : true
4
- }
1
+ import Utility from './utilities.class.js'
5
2
6
3
class Categories {
7
4
getCategoriesFlags = array => {
@@ -17,7 +14,7 @@ class Categories {
17
14
}
18
15
19
16
getCategoriesFromCategoriesFlags = array => {
20
- return ( ! Array . isEmpty ( array ) ) ? array : undefined
17
+ return ( ! Utility . isEmpty ( array ) ) ? array : undefined
21
18
}
22
19
}
23
20
Original file line number Diff line number Diff line change
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 ( )
You can’t perform that action at this time.
0 commit comments