summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThom Williams <thom.williams@pnnl.gov>2016-08-19 13:27:51 -0700
committerThom Williams <thom.williams@pnnl.gov>2016-08-19 13:27:51 -0700
commitca83acf0b806f6561ac96e34bfa913fc83e5586d (patch)
treeb1b0840df9e1e13f22a688738b5b53fee95eb6ac
parent97d39b6c2bf533d33538205a399638b63f6baa66 (diff)
downloadyamljs-ca83acf0b806f6561ac96e34bfa913fc83e5586d.tar.gz
Solve issue 59: Stringify empty objects inline
-rw-r--r--src/Utils.coffee12
1 files changed, 6 insertions, 6 deletions
diff --git a/src/Utils.coffee b/src/Utils.coffee
index 6ab1116..1c36faa 100644
--- a/src/Utils.coffee
+++ b/src/Utils.coffee
@@ -86,7 +86,7 @@ class Utils
# @return [Boolean] true if the value is empty
#
@isEmpty: (value) ->
- return not(value) or value is '' or value is '0' or (value instanceof Array and value.length is 0)
+ 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)
# Counts the number of occurences of subString inside string
@@ -100,22 +100,22 @@ class Utils
#
@subStrCount: (string, subString, start, length) ->
c = 0
-
+
string = '' + string
subString = '' + subString
-
+
if start?
string = string[start..]
if length?
string = string[0...length]
-
+
len = string.length
sublen = subString.length
for i in [0...len]
if subString is string[i...sublen]
c++
i += sublen - 1
-
+
return c
@@ -308,7 +308,7 @@ class Utils
callback(null)
xhr.open 'GET', path, true
xhr.send null
-
+
else
# Sync
xhr.open 'GET', path, false