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