1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
|
// Generated by CoffeeScript 1.7.1
var Dumper, Inline, Utils;
Utils = require('./Utils');
Inline = require('./Inline');
Dumper = (function() {
function Dumper() {}
Dumper.indentation = 4;
Dumper.prototype.dump = function(input, inline, indent, exceptionOnInvalidType, objectEncoder) {
var key, output, prefix, value, willBeInlined, _i, _len;
if (inline == null) {
inline = 0;
}
if (indent == null) {
indent = 0;
}
if (exceptionOnInvalidType == null) {
exceptionOnInvalidType = false;
}
if (objectEncoder == null) {
objectEncoder = null;
}
output = '';
prefix = (indent ? Utils.strRepeat(' ', indent) : '');
if (inline <= 0 || typeof input !== 'object' || input instanceof Date || Utils.isEmpty(input)) {
output += prefix + Inline.dump(input, exceptionOnInvalidType, objectEncoder);
} else {
if (input instanceof Array) {
for (_i = 0, _len = input.length; _i < _len; _i++) {
value = input[_i];
willBeInlined = inline - 1 <= 0 || typeof value !== 'object' || Utils.isEmpty(value);
output += prefix + '-' + (willBeInlined ? ' ' : "\n") + this.dump(value, inline - 1, (willBeInlined ? 0 : indent + this.indentation), exceptionOnInvalidType, objectEncoder) + (willBeInlined ? "\n" : '');
}
} else {
for (key in input) {
value = input[key];
willBeInlined = inline - 1 <= 0 || typeof value !== 'object' || Utils.isEmpty(value);
output += prefix + Inline.dump(key, exceptionOnInvalidType, objectEncoder) + ':' + (willBeInlined ? ' ' : "\n") + this.dump(value, inline - 1, (willBeInlined ? 0 : indent + this.indentation), exceptionOnInvalidType, objectEncoder) + (willBeInlined ? "\n" : '');
}
}
}
return output;
};
return Dumper;
})();
module.exports = Dumper;
|