scratch – Diff between revs 75 and 125

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