scratch – Blame information for rev 125

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