diff options
author | Jérémy Faivre <jeremy.faivre@gmail.com> | 2014-09-14 15:22:52 +0200 |
---|---|---|
committer | Jérémy Faivre <jeremy.faivre@gmail.com> | 2014-09-14 15:22:52 +0200 |
commit | ffe715eb2ff31db93cf36d28728e03dd28a84381 (patch) | |
tree | 2ef364cd727aa6ba51956f9922316436627806be /lib | |
parent | e3efe9d4ee17efad2583bdb82cb26527b749c67b (diff) | |
download | yamljs-ffe715eb2ff31db93cf36d28728e03dd28a84381.tar.gz |
Add additional tests. Fix asynchronous loading.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/Utils.js | 2 | ||||
-rw-r--r-- | lib/Yaml.js | 10 |
2 files changed, 7 insertions, 5 deletions
diff --git a/lib/Utils.js b/lib/Utils.js index 4f1f3da..30a1023 100644 --- a/lib/Utils.js +++ b/lib/Utils.js @@ -264,7 +264,7 @@ Utils = (function() { if (err) { return callback(null); } else { - return callback(data); + return callback(String(data)); } }); } else { diff --git a/lib/Yaml.js b/lib/Yaml.js index 8ab695f..67bd634 100644 --- a/lib/Yaml.js +++ b/lib/Yaml.js @@ -34,10 +34,12 @@ Yaml = (function() { if (callback != null) { return Utils.getStringFromFile(path, (function(_this) { return function(input) { + var result; + result = null; if (input != null) { - return _this.parse(input, exceptionOnInvalidType, objectDecoder); + result = _this.parse(input, exceptionOnInvalidType, objectDecoder); } - return null; + callback(result); }; })(this)); } else { @@ -79,11 +81,11 @@ Yaml = (function() { } }; - Yaml.prototype.stringify = function(input, inline, indent, exceptionOnInvalidType, objectEncoder) { + Yaml.stringify = function(input, inline, indent, exceptionOnInvalidType, objectEncoder) { return this.dump(input, inline, indent, exceptionOnInvalidType, objectEncoder); }; - Yaml.prototype.load = function(path, callback, exceptionOnInvalidType, objectDecoder) { + Yaml.load = function(path, callback, exceptionOnInvalidType, objectDecoder) { return this.parseFile(path, callback, exceptionOnInvalidType, objectDecoder); }; |