summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJérémy Faivre <jeremy.faivre@gmail.com>2014-09-14 15:22:52 +0200
committerJérémy Faivre <jeremy.faivre@gmail.com>2014-09-14 15:22:52 +0200
commitffe715eb2ff31db93cf36d28728e03dd28a84381 (patch)
tree2ef364cd727aa6ba51956f9922316436627806be /src
parente3efe9d4ee17efad2583bdb82cb26527b749c67b (diff)
downloadyamljs-ffe715eb2ff31db93cf36d28728e03dd28a84381.tar.gz
Add additional tests. Fix asynchronous loading.
Diffstat (limited to 'src')
-rw-r--r--src/Utils.coffee2
-rw-r--r--src/Yaml.coffee10
2 files changed, 7 insertions, 5 deletions
diff --git a/src/Utils.coffee b/src/Utils.coffee
index bc18405..a78fd39 100644
--- a/src/Utils.coffee
+++ b/src/Utils.coffee
@@ -328,7 +328,7 @@ class Utils
if err
callback null
else
- callback data
+ callback String(data)
else
# Sync
diff --git a/src/Yaml.coffee b/src/Yaml.coffee
index fd16cd2..81deb38 100644
--- a/src/Yaml.coffee
+++ b/src/Yaml.coffee
@@ -49,9 +49,11 @@ class Yaml
if callback?
# Async
Utils.getStringFromFile path, (input) =>
+ result = null
if input?
- return @parse input, exceptionOnInvalidType, objectDecoder
- return null
+ result = @parse input, exceptionOnInvalidType, objectDecoder
+ callback result
+ return
else
# Sync
input = Utils.getStringFromFile path
@@ -96,13 +98,13 @@ class Yaml
# Alias of dump() method for compatibility reasons.
#
- stringify: (input, inline, indent, exceptionOnInvalidType, objectEncoder) ->
+ @stringify: (input, inline, indent, exceptionOnInvalidType, objectEncoder) ->
return @dump input, inline, indent, exceptionOnInvalidType, objectEncoder
# Alias of parseFile() method for compatibility reasons.
#
- load: (path, callback, exceptionOnInvalidType, objectDecoder) ->
+ @load: (path, callback, exceptionOnInvalidType, objectDecoder) ->
return @parseFile path, callback, exceptionOnInvalidType, objectDecoder