Yaml.js 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. // Generated by CoffeeScript 1.12.4
  2. var Dumper, Parser, Utils, Yaml;
  3. Parser = require('./Parser');
  4. Dumper = require('./Dumper');
  5. Utils = require('./Utils');
  6. Yaml = (function() {
  7. function Yaml() {}
  8. Yaml.parse = function(input, exceptionOnInvalidType, objectDecoder) {
  9. if (exceptionOnInvalidType == null) {
  10. exceptionOnInvalidType = false;
  11. }
  12. if (objectDecoder == null) {
  13. objectDecoder = null;
  14. }
  15. return new Parser().parse(input, exceptionOnInvalidType, objectDecoder);
  16. };
  17. Yaml.parseFile = function(path, callback, exceptionOnInvalidType, objectDecoder) {
  18. var input;
  19. if (callback == null) {
  20. callback = null;
  21. }
  22. if (exceptionOnInvalidType == null) {
  23. exceptionOnInvalidType = false;
  24. }
  25. if (objectDecoder == null) {
  26. objectDecoder = null;
  27. }
  28. if (callback != null) {
  29. return Utils.getStringFromFile(path, (function(_this) {
  30. return function(input) {
  31. var result;
  32. result = null;
  33. if (input != null) {
  34. result = _this.parse(input, exceptionOnInvalidType, objectDecoder);
  35. }
  36. callback(result);
  37. };
  38. })(this));
  39. } else {
  40. input = Utils.getStringFromFile(path);
  41. if (input != null) {
  42. return this.parse(input, exceptionOnInvalidType, objectDecoder);
  43. }
  44. return null;
  45. }
  46. };
  47. Yaml.dump = function(input, inline, indent, exceptionOnInvalidType, objectEncoder) {
  48. var yaml;
  49. if (inline == null) {
  50. inline = 2;
  51. }
  52. if (indent == null) {
  53. indent = 4;
  54. }
  55. if (exceptionOnInvalidType == null) {
  56. exceptionOnInvalidType = false;
  57. }
  58. if (objectEncoder == null) {
  59. objectEncoder = null;
  60. }
  61. yaml = new Dumper();
  62. yaml.indentation = indent;
  63. return yaml.dump(input, inline, 0, exceptionOnInvalidType, objectEncoder);
  64. };
  65. Yaml.stringify = function(input, inline, indent, exceptionOnInvalidType, objectEncoder) {
  66. return this.dump(input, inline, indent, exceptionOnInvalidType, objectEncoder);
  67. };
  68. Yaml.load = function(path, callback, exceptionOnInvalidType, objectDecoder) {
  69. return this.parseFile(path, callback, exceptionOnInvalidType, objectDecoder);
  70. };
  71. return Yaml;
  72. })();
  73. if (typeof window !== "undefined" && window !== null) {
  74. window.YAML = Yaml;
  75. }
  76. if (typeof window === "undefined" || window === null) {
  77. this.YAML = Yaml;
  78. }
  79. module.exports = Yaml;