Skip to content

Commit 0a05cb3

Browse files
committed
Simplify source by adding Utils.isEmptyObject method
1 parent 7b9d29b commit 0a05cb3

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

src/Utils.coffee

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,15 +79,23 @@ class Utils
7979
return str.replace(regexRight, '')
8080

8181

82-
# Checks if the given value is empty (null, undefined, empty string, string '0')
82+
# Checks if the given value is empty (null, undefined, empty string, string '0', empty Array, empty Object)
8383
#
8484
# @param [Object] value The value to check
8585
#
8686
# @return [Boolean] true if the value is empty
8787
#
8888
@isEmpty: (value) ->
89-
return not(value) or value is '' or value is '0' or (value instanceof Array and value.length is 0) or (value instanceof Object and (k for own k of value).length is 0)
89+
return not(value) or value is '' or value is '0' or (value instanceof Array and value.length is 0) or @isEmptyObject(value)
9090

91+
# Checks if the given value is an empty object
92+
#
93+
# @param [Object] value The value to check
94+
#
95+
# @return [Boolean] true if the value is empty and is an object
96+
#
97+
@isEmptyObject: (value) ->
98+
return value instanceof Object and (k for own k of value).length is 0
9199

92100
# Counts the number of occurences of subString inside string
93101
#

0 commit comments

Comments
 (0)