webservice_tester 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ source :gemcutter
2
+
3
+ gem "sinatra"
4
+ gem "sass"
5
+ gem "haml"
6
+ gem "coffee-script"
data/Gemfile.lock ADDED
@@ -0,0 +1,29 @@
1
+ GEM
2
+ remote: http://rubygems.org/
3
+ specs:
4
+ coffee-script (2.2.0)
5
+ coffee-script-source
6
+ execjs
7
+ coffee-script-source (1.4.0)
8
+ execjs (1.4.0)
9
+ multi_json (~> 1.0)
10
+ haml (3.1.7)
11
+ multi_json (1.4.0)
12
+ rack (1.4.1)
13
+ rack-protection (1.2.0)
14
+ rack
15
+ sass (3.2.3)
16
+ sinatra (1.3.3)
17
+ rack (~> 1.3, >= 1.3.6)
18
+ rack-protection (~> 1.2)
19
+ tilt (~> 1.3, >= 1.3.3)
20
+ tilt (1.3.3)
21
+
22
+ PLATFORMS
23
+ ruby
24
+
25
+ DEPENDENCIES
26
+ coffee-script
27
+ haml
28
+ sass
29
+ sinatra
data/config.ru ADDED
@@ -0,0 +1,2 @@
1
+ require './lib/webservice_tester/app'
2
+ run WebserviceTester::App
@@ -0,0 +1,9 @@
1
+ require 'sinatra/base'
2
+
3
+ module WebserviceTester
4
+ class App < Sinatra::Base
5
+ get('/') { haml :main }
6
+ get('/webservice_tester.css') { scss :main }
7
+ get('/webservice_tester.js') { coffee :main }
8
+ end
9
+ end
@@ -0,0 +1,1322 @@
1
+ /*jslint onevar: false, plusplus: false */
2
+ /*jshint curly:true, eqeqeq:true, laxbreak:true, noempty:false */
3
+ /*
4
+
5
+ JS Beautifier
6
+ ---------------
7
+
8
+
9
+ Written by Einar Lielmanis, <einar@jsbeautifier.org>
10
+ http://jsbeautifier.org/
11
+
12
+ Originally converted to javascript by Vital, <vital76@gmail.com>
13
+ "End braces on own line" added by Chris J. Shull, <chrisjshull@gmail.com>
14
+
15
+ You are free to use this in any way you want, in case you find this useful or working for you.
16
+
17
+ Usage:
18
+ js_beautify(js_source_text);
19
+ js_beautify(js_source_text, options);
20
+
21
+ The options are:
22
+ indent_size (default 4) - indentation size,
23
+ indent_char (default space) - character to indent with,
24
+ preserve_newlines (default true) - whether existing line breaks should be preserved,
25
+ max_preserve_newlines (default unlimited) - maximum number of line breaks to be preserved in one chunk,
26
+
27
+ jslint_happy (default false) - if true, then jslint-stricter mode is enforced.
28
+
29
+ jslint_happy !jslint_happy
30
+ ---------------------------------
31
+ function () function()
32
+
33
+ brace_style (default "collapse") - "collapse" | "expand" | "end-expand" | "expand-strict"
34
+ put braces on the same line as control statements (default), or put braces on own line (Allman / ANSI style), or just put end braces on own line.
35
+
36
+ expand-strict: put brace on own line even in such cases:
37
+
38
+ var a =
39
+ {
40
+ a: 5,
41
+ b: 6
42
+ }
43
+ This mode may break your scripts - e.g "return { a: 1 }" will be broken into two lines, so beware.
44
+
45
+ space_before_conditional (default true) - should the space before conditional statement be added, "if(true)" vs "if (true)",
46
+
47
+ unescape_strings (default false) - should printable characters in strings encoded in \xNN notation be unescaped, "example" vs "\x65\x78\x61\x6d\x70\x6c\x65"
48
+
49
+ e.g
50
+
51
+ js_beautify(js_source_text, {
52
+ 'indent_size': 1,
53
+ 'indent_char': '\t'
54
+ });
55
+
56
+
57
+ */
58
+
59
+
60
+
61
+ function js_beautify(js_source_text, options) {
62
+
63
+ var input, output, token_text, last_type, last_text, last_last_text, last_word, flags, flag_store, indent_string;
64
+ var whitespace, wordchar, punct, parser_pos, line_starters, digits;
65
+ var prefix, token_type, do_block_just_closed;
66
+ var wanted_newline, just_added_newline, n_newlines;
67
+ var preindent_string = '';
68
+
69
+
70
+ // Some interpreters have unexpected results with foo = baz || bar;
71
+ options = options ? options : {};
72
+
73
+ var opt_brace_style;
74
+
75
+ // compatibility
76
+ if (options.space_after_anon_function !== undefined && options.jslint_happy === undefined) {
77
+ options.jslint_happy = options.space_after_anon_function;
78
+ }
79
+ if (options.braces_on_own_line !== undefined) { //graceful handling of deprecated option
80
+ opt_brace_style = options.braces_on_own_line ? "expand" : "collapse";
81
+ }
82
+ opt_brace_style = options.brace_style ? options.brace_style : (opt_brace_style ? opt_brace_style : "collapse");
83
+
84
+
85
+ var opt_indent_size = options.indent_size ? options.indent_size : 4;
86
+ var opt_indent_char = options.indent_char ? options.indent_char : ' ';
87
+ var opt_preserve_newlines = typeof options.preserve_newlines === 'undefined' ? true : options.preserve_newlines;
88
+ var opt_max_preserve_newlines = typeof options.max_preserve_newlines === 'undefined' ? false : options.max_preserve_newlines;
89
+ var opt_jslint_happy = options.jslint_happy === 'undefined' ? false : options.jslint_happy;
90
+ var opt_keep_array_indentation = typeof options.keep_array_indentation === 'undefined' ? false : options.keep_array_indentation;
91
+ var opt_space_before_conditional = typeof options.space_before_conditional === 'undefined' ? true : options.space_before_conditional;
92
+ var opt_indent_case = typeof options.indent_case === 'undefined' ? false : options.indent_case;
93
+ var opt_unescape_strings = typeof options.unescape_strings === 'undefined' ? false : options.unescape_strings;
94
+
95
+ just_added_newline = false;
96
+
97
+ // cache the source's length.
98
+ var input_length = js_source_text.length;
99
+
100
+ function trim_output(eat_newlines) {
101
+ eat_newlines = typeof eat_newlines === 'undefined' ? false : eat_newlines;
102
+ while (output.length && (output[output.length - 1] === ' '
103
+ || output[output.length - 1] === indent_string
104
+ || output[output.length - 1] === preindent_string
105
+ || (eat_newlines && (output[output.length - 1] === '\n' || output[output.length - 1] === '\r')))) {
106
+ output.pop();
107
+ }
108
+ }
109
+
110
+ function trim(s) {
111
+ return s.replace(/^\s\s*|\s\s*$/, '');
112
+ }
113
+
114
+ // we could use just string.split, but
115
+ // IE doesn't like returning empty strings
116
+ function split_newlines(s) {
117
+ //return s.split(/\x0d\x0a|\x0a/);
118
+
119
+ s = s.replace(/\x0d/g, '');
120
+ var out = [],
121
+ idx = s.indexOf("\n");
122
+ while (idx !== -1) {
123
+ out.push(s.substring(0, idx));
124
+ s = s.substring(idx + 1);
125
+ idx = s.indexOf("\n");
126
+ }
127
+ if (s.length) {
128
+ out.push(s);
129
+ }
130
+ return out;
131
+ }
132
+
133
+ function force_newline() {
134
+ var old_keep_array_indentation = opt_keep_array_indentation;
135
+ opt_keep_array_indentation = false;
136
+ print_newline();
137
+ opt_keep_array_indentation = old_keep_array_indentation;
138
+ }
139
+
140
+ function print_newline(ignore_repeated) {
141
+
142
+ flags.eat_next_space = false;
143
+ if (opt_keep_array_indentation && is_array(flags.mode)) {
144
+ return;
145
+ }
146
+
147
+ ignore_repeated = typeof ignore_repeated === 'undefined' ? true : ignore_repeated;
148
+
149
+ flags.if_line = false;
150
+ trim_output();
151
+
152
+ if (!output.length) {
153
+ return; // no newline on start of file
154
+ }
155
+
156
+ if (output[output.length - 1] !== "\n" || !ignore_repeated) {
157
+ just_added_newline = true;
158
+ output.push("\n");
159
+ }
160
+ if (preindent_string) {
161
+ output.push(preindent_string);
162
+ }
163
+ for (var i = 0; i < flags.indentation_level; i += 1) {
164
+ output.push(indent_string);
165
+ }
166
+ if (flags.var_line && flags.var_line_reindented) {
167
+ output.push(indent_string); // skip space-stuffing, if indenting with a tab
168
+ }
169
+ if (flags.case_body) {
170
+ output.push(indent_string);
171
+ }
172
+ }
173
+
174
+
175
+
176
+ function print_single_space() {
177
+
178
+ if (last_type === 'TK_COMMENT') {
179
+ return print_newline();
180
+ }
181
+ if (flags.eat_next_space) {
182
+ flags.eat_next_space = false;
183
+ return;
184
+ }
185
+ var last_output = ' ';
186
+ if (output.length) {
187
+ last_output = output[output.length - 1];
188
+ }
189
+ if (last_output !== ' ' && last_output !== '\n' && last_output !== indent_string) { // prevent occassional duplicate space
190
+ output.push(' ');
191
+ }
192
+ }
193
+
194
+
195
+ function print_token() {
196
+ just_added_newline = false;
197
+ flags.eat_next_space = false;
198
+ output.push(token_text);
199
+ }
200
+
201
+ function indent() {
202
+ flags.indentation_level += 1;
203
+ }
204
+
205
+
206
+ function remove_indent() {
207
+ if (output.length && output[output.length - 1] === indent_string) {
208
+ output.pop();
209
+ }
210
+ }
211
+
212
+ function set_mode(mode) {
213
+ if (flags) {
214
+ flag_store.push(flags);
215
+ }
216
+ flags = {
217
+ previous_mode: flags ? flags.mode : 'BLOCK',
218
+ mode: mode,
219
+ var_line: false,
220
+ var_line_tainted: false,
221
+ var_line_reindented: false,
222
+ in_html_comment: false,
223
+ if_line: false,
224
+ in_case_statement: false, // switch(..){ INSIDE HERE }
225
+ in_case: false, // we're on the exact line with "case 0:"
226
+ case_body: false, // the indented case-action block
227
+ eat_next_space: false,
228
+ indentation_baseline: -1,
229
+ indentation_level: (flags ? flags.indentation_level + (flags.case_body ? 1 : 0) + ((flags.var_line && flags.var_line_reindented) ? 1 : 0) : 0),
230
+ ternary_depth: 0
231
+ };
232
+ }
233
+
234
+ function is_array(mode) {
235
+ return mode === '[EXPRESSION]' || mode === '[INDENTED-EXPRESSION]';
236
+ }
237
+
238
+ function is_expression(mode) {
239
+ return in_array(mode, ['[EXPRESSION]', '(EXPRESSION)', '(FOR-EXPRESSION)', '(COND-EXPRESSION)']);
240
+ }
241
+
242
+ function restore_mode() {
243
+ do_block_just_closed = flags.mode === 'DO_BLOCK';
244
+ if (flag_store.length > 0) {
245
+ var mode = flags.mode;
246
+ flags = flag_store.pop();
247
+ flags.previous_mode = mode;
248
+ }
249
+ }
250
+
251
+ function all_lines_start_with(lines, c) {
252
+ for (var i = 0; i < lines.length; i++) {
253
+ var line = trim(lines[i]);
254
+ if (line.charAt(0) !== c) {
255
+ return false;
256
+ }
257
+ }
258
+ return true;
259
+ }
260
+
261
+ function is_special_word(word) {
262
+ return in_array(word, ['case', 'return', 'do', 'if', 'throw', 'else']);
263
+ }
264
+
265
+ function in_array(what, arr) {
266
+ for (var i = 0; i < arr.length; i += 1) {
267
+ if (arr[i] === what) {
268
+ return true;
269
+ }
270
+ }
271
+ return false;
272
+ }
273
+
274
+ function look_up(exclude) {
275
+ var local_pos = parser_pos;
276
+ var c = input.charAt(local_pos);
277
+ while (in_array(c, whitespace) && c !== exclude) {
278
+ local_pos++;
279
+ if (local_pos >= input_length) {
280
+ return 0;
281
+ }
282
+ c = input.charAt(local_pos);
283
+ }
284
+ return c;
285
+ }
286
+
287
+ function get_next_token() {
288
+ var i;
289
+ var resulting_string;
290
+
291
+ n_newlines = 0;
292
+
293
+ if (parser_pos >= input_length) {
294
+ return ['', 'TK_EOF'];
295
+ }
296
+
297
+ wanted_newline = false;
298
+
299
+ var c = input.charAt(parser_pos);
300
+ parser_pos += 1;
301
+
302
+
303
+ var keep_whitespace = opt_keep_array_indentation && is_array(flags.mode);
304
+
305
+ if (keep_whitespace) {
306
+
307
+ //
308
+ // slight mess to allow nice preservation of array indentation and reindent that correctly
309
+ // first time when we get to the arrays:
310
+ // var a = [
311
+ // ....'something'
312
+ // we make note of whitespace_count = 4 into flags.indentation_baseline
313
+ // so we know that 4 whitespaces in original source match indent_level of reindented source
314
+ //
315
+ // and afterwards, when we get to
316
+ // 'something,
317
+ // .......'something else'
318
+ // we know that this should be indented to indent_level + (7 - indentation_baseline) spaces
319
+ //
320
+ var whitespace_count = 0;
321
+
322
+ while (in_array(c, whitespace)) {
323
+
324
+ if (c === "\n") {
325
+ trim_output();
326
+ output.push("\n");
327
+ just_added_newline = true;
328
+ whitespace_count = 0;
329
+ } else {
330
+ if (c === '\t') {
331
+ whitespace_count += 4;
332
+ } else if (c === '\r') {
333
+ // nothing
334
+ } else {
335
+ whitespace_count += 1;
336
+ }
337
+ }
338
+
339
+ if (parser_pos >= input_length) {
340
+ return ['', 'TK_EOF'];
341
+ }
342
+
343
+ c = input.charAt(parser_pos);
344
+ parser_pos += 1;
345
+
346
+ }
347
+ if (flags.indentation_baseline === -1) {
348
+ flags.indentation_baseline = whitespace_count;
349
+ }
350
+
351
+ if (just_added_newline) {
352
+ for (i = 0; i < flags.indentation_level + 1; i += 1) {
353
+ output.push(indent_string);
354
+ }
355
+ if (flags.indentation_baseline !== -1) {
356
+ for (i = 0; i < whitespace_count - flags.indentation_baseline; i++) {
357
+ output.push(' ');
358
+ }
359
+ }
360
+ }
361
+
362
+ } else {
363
+ while (in_array(c, whitespace)) {
364
+
365
+ if (c === "\n") {
366
+ n_newlines += ((opt_max_preserve_newlines) ? (n_newlines <= opt_max_preserve_newlines) ? 1 : 0 : 1);
367
+ }
368
+
369
+
370
+ if (parser_pos >= input_length) {
371
+ return ['', 'TK_EOF'];
372
+ }
373
+
374
+ c = input.charAt(parser_pos);
375
+ parser_pos += 1;
376
+
377
+ }
378
+
379
+ if (opt_preserve_newlines) {
380
+ if (n_newlines > 1) {
381
+ for (i = 0; i < n_newlines; i += 1) {
382
+ print_newline(i === 0);
383
+ just_added_newline = true;
384
+ }
385
+ }
386
+ }
387
+ wanted_newline = n_newlines > 0;
388
+ }
389
+
390
+
391
+ if (in_array(c, wordchar)) {
392
+ if (parser_pos < input_length) {
393
+ while (in_array(input.charAt(parser_pos), wordchar)) {
394
+ c += input.charAt(parser_pos);
395
+ parser_pos += 1;
396
+ if (parser_pos === input_length) {
397
+ break;
398
+ }
399
+ }
400
+ }
401
+
402
+ // small and surprisingly unugly hack for 1E-10 representation
403
+ if (parser_pos !== input_length && c.match(/^[0-9]+[Ee]$/) && (input.charAt(parser_pos) === '-' || input.charAt(parser_pos) === '+')) {
404
+
405
+ var sign = input.charAt(parser_pos);
406
+ parser_pos += 1;
407
+
408
+ var t = get_next_token();
409
+ c += sign + t[0];
410
+ return [c, 'TK_WORD'];
411
+ }
412
+
413
+ if (c === 'in') { // hack for 'in' operator
414
+ return [c, 'TK_OPERATOR'];
415
+ }
416
+ if (wanted_newline && last_type !== 'TK_OPERATOR'
417
+ && last_type !== 'TK_EQUALS'
418
+ && !flags.if_line && (opt_preserve_newlines || last_text !== 'var')) {
419
+ print_newline();
420
+ }
421
+ return [c, 'TK_WORD'];
422
+ }
423
+
424
+ if (c === '(' || c === '[') {
425
+ return [c, 'TK_START_EXPR'];
426
+ }
427
+
428
+ if (c === ')' || c === ']') {
429
+ return [c, 'TK_END_EXPR'];
430
+ }
431
+
432
+ if (c === '{') {
433
+ return [c, 'TK_START_BLOCK'];
434
+ }
435
+
436
+ if (c === '}') {
437
+ return [c, 'TK_END_BLOCK'];
438
+ }
439
+
440
+ if (c === ';') {
441
+ return [c, 'TK_SEMICOLON'];
442
+ }
443
+
444
+ if (c === '/') {
445
+ var comment = '';
446
+ // peek for comment /* ... */
447
+ var inline_comment = true;
448
+ if (input.charAt(parser_pos) === '*') {
449
+ parser_pos += 1;
450
+ if (parser_pos < input_length) {
451
+ while (parser_pos < input_length &&
452
+ ! (input.charAt(parser_pos) === '*' && input.charAt(parser_pos + 1) && input.charAt(parser_pos + 1) === '/')) {
453
+ c = input.charAt(parser_pos);
454
+ comment += c;
455
+ if (c === "\n" || c === "\r") {
456
+ inline_comment = false;
457
+ }
458
+ parser_pos += 1;
459
+ if (parser_pos >= input_length) {
460
+ break;
461
+ }
462
+ }
463
+ }
464
+ parser_pos += 2;
465
+ if (inline_comment && n_newlines === 0) {
466
+ return ['/*' + comment + '*/', 'TK_INLINE_COMMENT'];
467
+ } else {
468
+ return ['/*' + comment + '*/', 'TK_BLOCK_COMMENT'];
469
+ }
470
+ }
471
+ // peek for comment // ...
472
+ if (input.charAt(parser_pos) === '/') {
473
+ comment = c;
474
+ while (input.charAt(parser_pos) !== '\r' && input.charAt(parser_pos) !== '\n') {
475
+ comment += input.charAt(parser_pos);
476
+ parser_pos += 1;
477
+ if (parser_pos >= input_length) {
478
+ break;
479
+ }
480
+ }
481
+ if (wanted_newline) {
482
+ print_newline();
483
+ }
484
+ return [comment, 'TK_COMMENT'];
485
+ }
486
+
487
+ }
488
+
489
+ if (c === "'" || // string
490
+ c === '"' || // string
491
+ (c === '/' &&
492
+ ((last_type === 'TK_WORD' && is_special_word(last_text)) ||
493
+ (last_text === ')' && in_array(flags.previous_mode, ['(COND-EXPRESSION)', '(FOR-EXPRESSION)'])) ||
494
+ (last_type === 'TK_COMMA' || last_type === 'TK_COMMENT' || last_type === 'TK_START_EXPR' || last_type === 'TK_START_BLOCK' || last_type === 'TK_END_BLOCK' || last_type === 'TK_OPERATOR' || last_type === 'TK_EQUALS' || last_type === 'TK_EOF' || last_type === 'TK_SEMICOLON')))) { // regexp
495
+ var sep = c;
496
+ var esc = false;
497
+ var esc1 = 0;
498
+ var esc2 = 0;
499
+ resulting_string = c;
500
+
501
+ if (parser_pos < input_length) {
502
+ if (sep === '/') {
503
+ //
504
+ // handle regexp separately...
505
+ //
506
+ var in_char_class = false;
507
+ while (esc || in_char_class || input.charAt(parser_pos) !== sep) {
508
+ resulting_string += input.charAt(parser_pos);
509
+ if (!esc) {
510
+ esc = input.charAt(parser_pos) === '\\';
511
+ if (input.charAt(parser_pos) === '[') {
512
+ in_char_class = true;
513
+ } else if (input.charAt(parser_pos) === ']') {
514
+ in_char_class = false;
515
+ }
516
+ } else {
517
+ esc = false;
518
+ }
519
+ parser_pos += 1;
520
+ if (parser_pos >= input_length) {
521
+ // incomplete string/rexp when end-of-file reached.
522
+ // bail out with what had been received so far.
523
+ return [resulting_string, 'TK_STRING'];
524
+ }
525
+ }
526
+
527
+ } else {
528
+ //
529
+ // and handle string also separately
530
+ //
531
+ while (esc || input.charAt(parser_pos) !== sep) {
532
+ resulting_string += input.charAt(parser_pos);
533
+ if (esc1 && esc1 >= esc2) {
534
+ esc1 = parseInt(resulting_string.substr(-esc2), 16);
535
+ if (esc1 && esc1 >= 0x20 && esc1 <= 0x7e) {
536
+ esc1 = String.fromCharCode(esc1);
537
+ resulting_string = resulting_string.substr(0, resulting_string.length - esc2 - 2) + (((esc1 === sep) || (esc1 === '\\')) ? '\\' : '') + esc1;
538
+ }
539
+ esc1 = 0;
540
+ }
541
+ if (esc1) {
542
+ esc1++;
543
+ } else if (!esc) {
544
+ esc = input.charAt(parser_pos) === '\\';
545
+ } else {
546
+ esc = false;
547
+ if (opt_unescape_strings) {
548
+ if (input.charAt(parser_pos) === 'x') {
549
+ esc1++;
550
+ esc2 = 2;
551
+ } else if (input.charAt(parser_pos) === 'u') {
552
+ esc1++;
553
+ esc2 = 4;
554
+ }
555
+ }
556
+ }
557
+ parser_pos += 1;
558
+ if (parser_pos >= input_length) {
559
+ // incomplete string/rexp when end-of-file reached.
560
+ // bail out with what had been received so far.
561
+ return [resulting_string, 'TK_STRING'];
562
+ }
563
+ }
564
+ }
565
+
566
+
567
+
568
+ }
569
+
570
+ parser_pos += 1;
571
+
572
+ resulting_string += sep;
573
+
574
+ if (sep === '/') {
575
+ // regexps may have modifiers /regexp/MOD , so fetch those, too
576
+ while (parser_pos < input_length && in_array(input.charAt(parser_pos), wordchar)) {
577
+ resulting_string += input.charAt(parser_pos);
578
+ parser_pos += 1;
579
+ }
580
+ }
581
+ return [resulting_string, 'TK_STRING'];
582
+ }
583
+
584
+ if (c === '#') {
585
+
586
+
587
+ if (output.length === 0 && input.charAt(parser_pos) === '!') {
588
+ // shebang
589
+ resulting_string = c;
590
+ while (parser_pos < input_length && c !== '\n') {
591
+ c = input.charAt(parser_pos);
592
+ resulting_string += c;
593
+ parser_pos += 1;
594
+ }
595
+ output.push(trim(resulting_string) + '\n');
596
+ print_newline();
597
+ return get_next_token();
598
+ }
599
+
600
+
601
+
602
+ // Spidermonkey-specific sharp variables for circular references
603
+ // https://developer.mozilla.org/En/Sharp_variables_in_JavaScript
604
+ // http://mxr.mozilla.org/mozilla-central/source/js/src/jsscan.cpp around line 1935
605
+ var sharp = '#';
606
+ if (parser_pos < input_length && in_array(input.charAt(parser_pos), digits)) {
607
+ do {
608
+ c = input.charAt(parser_pos);
609
+ sharp += c;
610
+ parser_pos += 1;
611
+ } while (parser_pos < input_length && c !== '#' && c !== '=');
612
+ if (c === '#') {
613
+ //
614
+ } else if (input.charAt(parser_pos) === '[' && input.charAt(parser_pos + 1) === ']') {
615
+ sharp += '[]';
616
+ parser_pos += 2;
617
+ } else if (input.charAt(parser_pos) === '{' && input.charAt(parser_pos + 1) === '}') {
618
+ sharp += '{}';
619
+ parser_pos += 2;
620
+ }
621
+ return [sharp, 'TK_WORD'];
622
+ }
623
+ }
624
+
625
+ if (c === '<' && input.substring(parser_pos - 1, parser_pos + 3) === '<!--') {
626
+ parser_pos += 3;
627
+ c = '<!--';
628
+ while (input.charAt(parser_pos) !== '\n' && parser_pos < input_length) {
629
+ c += input.charAt(parser_pos);
630
+ parser_pos++;
631
+ }
632
+ flags.in_html_comment = true;
633
+ return [c, 'TK_COMMENT'];
634
+ }
635
+
636
+ if (c === '-' && flags.in_html_comment && input.substring(parser_pos - 1, parser_pos + 2) === '-->') {
637
+ flags.in_html_comment = false;
638
+ parser_pos += 2;
639
+ if (wanted_newline) {
640
+ print_newline();
641
+ }
642
+ return ['-->', 'TK_COMMENT'];
643
+ }
644
+
645
+ if (in_array(c, punct)) {
646
+ while (parser_pos < input_length && in_array(c + input.charAt(parser_pos), punct)) {
647
+ c += input.charAt(parser_pos);
648
+ parser_pos += 1;
649
+ if (parser_pos >= input_length) {
650
+ break;
651
+ }
652
+ }
653
+
654
+ if (c === ',') {
655
+ return [c, 'TK_COMMA'];
656
+ } else if (c === '=') {
657
+ return [c, 'TK_EQUALS'];
658
+ } else {
659
+ return [c, 'TK_OPERATOR'];
660
+ }
661
+ }
662
+
663
+ return [c, 'TK_UNKNOWN'];
664
+ }
665
+
666
+ //----------------------------------
667
+ indent_string = '';
668
+ while (opt_indent_size > 0) {
669
+ indent_string += opt_indent_char;
670
+ opt_indent_size -= 1;
671
+ }
672
+
673
+ while (js_source_text && (js_source_text.charAt(0) === ' ' || js_source_text.charAt(0) === '\t')) {
674
+ preindent_string += js_source_text.charAt(0);
675
+ js_source_text = js_source_text.substring(1);
676
+ }
677
+ input = js_source_text;
678
+
679
+ last_word = ''; // last 'TK_WORD' passed
680
+ last_type = 'TK_START_EXPR'; // last token type
681
+ last_text = ''; // last token text
682
+ last_last_text = ''; // pre-last token text
683
+ output = [];
684
+
685
+ do_block_just_closed = false;
686
+
687
+ whitespace = "\n\r\t ".split('');
688
+ wordchar = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_$'.split('');
689
+ digits = '0123456789'.split('');
690
+
691
+ punct = '+ - * / % & ++ -- = += -= *= /= %= == === != !== > < >= <= >> << >>> >>>= >>= <<= && &= | || ! !! , : ? ^ ^= |= ::';
692
+ punct += ' <%= <% %> <?= <? ?>'; // try to be a good boy and try not to break the markup language identifiers
693
+ punct = punct.split(' ');
694
+
695
+ // words which should always start on new line.
696
+ line_starters = 'continue,try,throw,return,var,if,switch,case,default,for,while,break,function'.split(',');
697
+
698
+ // states showing if we are currently in expression (i.e. "if" case) - 'EXPRESSION', or in usual block (like, procedure), 'BLOCK'.
699
+ // some formatting depends on that.
700
+ flag_store = [];
701
+ set_mode('BLOCK');
702
+
703
+ parser_pos = 0;
704
+ while (true) {
705
+ var t = get_next_token();
706
+ token_text = t[0];
707
+ token_type = t[1];
708
+ if (token_type === 'TK_EOF') {
709
+ break;
710
+ }
711
+
712
+ switch (token_type) {
713
+
714
+ case 'TK_START_EXPR':
715
+
716
+ if (token_text === '[') {
717
+
718
+ if (last_type === 'TK_WORD' || last_text === ')') {
719
+ // this is array index specifier, break immediately
720
+ // a[x], fn()[x]
721
+ if (in_array(last_text, line_starters)) {
722
+ print_single_space();
723
+ }
724
+ set_mode('(EXPRESSION)');
725
+ print_token();
726
+ break;
727
+ }
728
+
729
+ if (flags.mode === '[EXPRESSION]' || flags.mode === '[INDENTED-EXPRESSION]') {
730
+ if (last_last_text === ']' && last_text === ',') {
731
+ // ], [ goes to new line
732
+ if (flags.mode === '[EXPRESSION]') {
733
+ flags.mode = '[INDENTED-EXPRESSION]';
734
+ if (!opt_keep_array_indentation) {
735
+ indent();
736
+ }
737
+ }
738
+ set_mode('[EXPRESSION]');
739
+ if (!opt_keep_array_indentation) {
740
+ print_newline();
741
+ }
742
+ } else if (last_text === '[') {
743
+ if (flags.mode === '[EXPRESSION]') {
744
+ flags.mode = '[INDENTED-EXPRESSION]';
745
+ if (!opt_keep_array_indentation) {
746
+ indent();
747
+ }
748
+ }
749
+ set_mode('[EXPRESSION]');
750
+
751
+ if (!opt_keep_array_indentation) {
752
+ print_newline();
753
+ }
754
+ } else {
755
+ set_mode('[EXPRESSION]');
756
+ }
757
+ } else {
758
+ set_mode('[EXPRESSION]');
759
+ }
760
+
761
+
762
+
763
+ } else {
764
+ if (last_word === 'for') {
765
+ set_mode('(FOR-EXPRESSION)');
766
+ } else if (in_array(last_word, ['if', 'while'])) {
767
+ set_mode('(COND-EXPRESSION)');
768
+ } else {
769
+ set_mode('(EXPRESSION)');
770
+ }
771
+ }
772
+
773
+ if (last_text === ';' || last_type === 'TK_START_BLOCK') {
774
+ print_newline();
775
+ } else if (last_type === 'TK_END_EXPR' || last_type === 'TK_START_EXPR' || last_type === 'TK_END_BLOCK' || last_text === '.') {
776
+ if (wanted_newline) {
777
+ print_newline();
778
+ }
779
+ // do nothing on (( and )( and ][ and ]( and .(
780
+ } else if (last_type !== 'TK_WORD' && last_type !== 'TK_OPERATOR') {
781
+ print_single_space();
782
+ } else if (last_word === 'function' || last_word === 'typeof') {
783
+ // function() vs function ()
784
+ if (opt_jslint_happy) {
785
+ print_single_space();
786
+ }
787
+ } else if (in_array(last_text, line_starters) || last_text === 'catch') {
788
+ if (opt_space_before_conditional) {
789
+ print_single_space();
790
+ }
791
+ }
792
+ print_token();
793
+
794
+ break;
795
+
796
+ case 'TK_END_EXPR':
797
+ if (token_text === ']') {
798
+ if (opt_keep_array_indentation) {
799
+ if (last_text === '}') {
800
+ // trim_output();
801
+ // print_newline(true);
802
+ remove_indent();
803
+ print_token();
804
+ restore_mode();
805
+ break;
806
+ }
807
+ } else {
808
+ if (flags.mode === '[INDENTED-EXPRESSION]') {
809
+ if (last_text === ']') {
810
+ restore_mode();
811
+ print_newline();
812
+ print_token();
813
+ break;
814
+ }
815
+ }
816
+ }
817
+ }
818
+ restore_mode();
819
+ print_token();
820
+ break;
821
+
822
+ case 'TK_START_BLOCK':
823
+
824
+ if (last_word === 'do') {
825
+ set_mode('DO_BLOCK');
826
+ } else {
827
+ set_mode('BLOCK');
828
+ }
829
+ if (opt_brace_style === "expand" || opt_brace_style === "expand-strict") {
830
+ var empty_braces = false;
831
+ if (opt_brace_style === "expand-strict") {
832
+ empty_braces = (look_up() === '}');
833
+ if (!empty_braces) {
834
+ print_newline(true);
835
+ }
836
+ } else {
837
+ if (last_type !== 'TK_OPERATOR') {
838
+ if (last_text === '=' || (is_special_word(last_text) && last_text !== 'else')) {
839
+ print_single_space();
840
+ } else {
841
+ print_newline(true);
842
+ }
843
+ }
844
+ }
845
+ print_token();
846
+ if (!empty_braces) {
847
+ indent();
848
+ }
849
+ } else {
850
+ if (last_type !== 'TK_OPERATOR' && last_type !== 'TK_START_EXPR') {
851
+ if (last_type === 'TK_START_BLOCK') {
852
+ print_newline();
853
+ } else {
854
+ print_single_space();
855
+ }
856
+ } else {
857
+ // if TK_OPERATOR or TK_START_EXPR
858
+ if (is_array(flags.previous_mode) && last_text === ',') {
859
+ if (last_last_text === '}') {
860
+ // }, { in array context
861
+ print_single_space();
862
+ } else {
863
+ print_newline(); // [a, b, c, {
864
+ }
865
+ }
866
+ }
867
+ indent();
868
+ print_token();
869
+ }
870
+
871
+ break;
872
+
873
+ case 'TK_END_BLOCK':
874
+ restore_mode();
875
+ if (opt_brace_style === "expand" || opt_brace_style === "expand-strict") {
876
+ if (last_text !== '{') {
877
+ print_newline();
878
+ }
879
+ print_token();
880
+ } else {
881
+ if (last_type === 'TK_START_BLOCK') {
882
+ // nothing
883
+ if (just_added_newline) {
884
+ remove_indent();
885
+ } else {
886
+ // {}
887
+ trim_output();
888
+ }
889
+ } else {
890
+ if (is_array(flags.mode) && opt_keep_array_indentation) {
891
+ // we REALLY need a newline here, but newliner would skip that
892
+ opt_keep_array_indentation = false;
893
+ print_newline();
894
+ opt_keep_array_indentation = true;
895
+
896
+ } else {
897
+ print_newline();
898
+ }
899
+ }
900
+ print_token();
901
+ }
902
+ break;
903
+
904
+ case 'TK_WORD':
905
+
906
+ // no, it's not you. even I have problems understanding how this works
907
+ // and what does what.
908
+ if (do_block_just_closed) {
909
+ // do {} ## while ()
910
+ print_single_space();
911
+ print_token();
912
+ print_single_space();
913
+ do_block_just_closed = false;
914
+ break;
915
+ }
916
+
917
+ prefix = 'NONE';
918
+
919
+ if (token_text === 'function') {
920
+ if (flags.var_line && last_type !== 'TK_EQUALS' ) {
921
+ flags.var_line_reindented = true;
922
+ }
923
+ if ((just_added_newline || last_text === ';') && last_text !== '{'
924
+ && last_type !== 'TK_BLOCK_COMMENT' && last_type !== 'TK_COMMENT') {
925
+ // make sure there is a nice clean space of at least one blank line
926
+ // before a new function definition
927
+ n_newlines = just_added_newline ? n_newlines : 0;
928
+ if (!opt_preserve_newlines) {
929
+ n_newlines = 1;
930
+ }
931
+
932
+ for (var i = 0; i < 2 - n_newlines; i++) {
933
+ print_newline(false);
934
+ }
935
+ }
936
+ if (last_type === 'TK_WORD') {
937
+ if (last_text === 'get' || last_text === 'set' || last_text === 'new' || last_text === 'return') {
938
+ print_single_space();
939
+ } else {
940
+ print_newline();
941
+ }
942
+ } else if (last_type === 'TK_OPERATOR' || last_text === '=') {
943
+ // foo = function
944
+ print_single_space();
945
+ } else if (is_expression(flags.mode)) {
946
+ //ää print nothing
947
+ } else {
948
+ print_newline();
949
+ }
950
+
951
+ print_token();
952
+ last_word = token_text;
953
+ break;
954
+ }
955
+
956
+ if (token_text === 'case' || (token_text === 'default' && flags.in_case_statement)) {
957
+ if (last_text === ':' || flags.case_body) {
958
+ // switch cases following one another
959
+ remove_indent();
960
+ } else {
961
+ // case statement starts in the same line where switch
962
+ if (!opt_indent_case) {
963
+ flags.indentation_level--;
964
+ }
965
+ print_newline();
966
+ if (!opt_indent_case) {
967
+ flags.indentation_level++;
968
+ }
969
+ }
970
+ print_token();
971
+ flags.in_case = true;
972
+ flags.in_case_statement = true;
973
+ flags.case_body = false;
974
+ break;
975
+ }
976
+
977
+ if (last_type === 'TK_END_BLOCK') {
978
+
979
+ if (!in_array(token_text.toLowerCase(), ['else', 'catch', 'finally'])) {
980
+ prefix = 'NEWLINE';
981
+ } else {
982
+ if (opt_brace_style === "expand" || opt_brace_style === "end-expand" || opt_brace_style === "expand-strict") {
983
+ prefix = 'NEWLINE';
984
+ } else {
985
+ prefix = 'SPACE';
986
+ print_single_space();
987
+ }
988
+ }
989
+ } else if (last_type === 'TK_SEMICOLON' && (flags.mode === 'BLOCK' || flags.mode === 'DO_BLOCK')) {
990
+ prefix = 'NEWLINE';
991
+ } else if (last_type === 'TK_SEMICOLON' && is_expression(flags.mode)) {
992
+ prefix = 'SPACE';
993
+ } else if (last_type === 'TK_STRING') {
994
+ prefix = 'NEWLINE';
995
+ } else if (last_type === 'TK_WORD') {
996
+ if (last_text === 'else') {
997
+ // eat newlines between ...else *** some_op...
998
+ // won't preserve extra newlines in this place (if any), but don't care that much
999
+ trim_output(true);
1000
+ }
1001
+ prefix = 'SPACE';
1002
+ } else if (last_type === 'TK_START_BLOCK') {
1003
+ prefix = 'NEWLINE';
1004
+ } else if (last_type === 'TK_END_EXPR') {
1005
+ print_single_space();
1006
+ prefix = 'NEWLINE';
1007
+ }
1008
+
1009
+ if (in_array(token_text, line_starters) && last_text !== ')') {
1010
+ if (last_text === 'else') {
1011
+ prefix = 'SPACE';
1012
+ } else {
1013
+ prefix = 'NEWLINE';
1014
+ }
1015
+
1016
+ }
1017
+
1018
+ if (flags.if_line && last_type === 'TK_END_EXPR') {
1019
+ flags.if_line = false;
1020
+ }
1021
+ if (in_array(token_text.toLowerCase(), ['else', 'catch', 'finally'])) {
1022
+ if (last_type !== 'TK_END_BLOCK' || opt_brace_style === "expand" || opt_brace_style === "end-expand" || opt_brace_style === "expand-strict") {
1023
+ print_newline();
1024
+ } else {
1025
+ trim_output(true);
1026
+ print_single_space();
1027
+ }
1028
+ } else if (prefix === 'NEWLINE') {
1029
+ if (is_special_word(last_text)) {
1030
+ // no newline between 'return nnn'
1031
+ print_single_space();
1032
+ } else if (last_type !== 'TK_END_EXPR') {
1033
+ if ((last_type !== 'TK_START_EXPR' || token_text !== 'var') && last_text !== ':') {
1034
+ // no need to force newline on 'var': for (var x = 0...)
1035
+ if (token_text === 'if' && last_word === 'else' && last_text !== '{') {
1036
+ // no newline for } else if {
1037
+ print_single_space();
1038
+ } else {
1039
+ flags.var_line = false;
1040
+ flags.var_line_reindented = false;
1041
+ print_newline();
1042
+ }
1043
+ }
1044
+ } else if (in_array(token_text, line_starters) && last_text !== ')') {
1045
+ flags.var_line = false;
1046
+ flags.var_line_reindented = false;
1047
+ print_newline();
1048
+ }
1049
+ } else if (is_array(flags.mode) && last_text === ',' && last_last_text === '}') {
1050
+ print_newline(); // }, in lists get a newline treatment
1051
+ } else if (prefix === 'SPACE') {
1052
+ print_single_space();
1053
+ }
1054
+ print_token();
1055
+ last_word = token_text;
1056
+
1057
+ if (token_text === 'var') {
1058
+ flags.var_line = true;
1059
+ flags.var_line_reindented = false;
1060
+ flags.var_line_tainted = false;
1061
+ }
1062
+
1063
+ if (token_text === 'if') {
1064
+ flags.if_line = true;
1065
+ }
1066
+ if (token_text === 'else') {
1067
+ flags.if_line = false;
1068
+ }
1069
+
1070
+ break;
1071
+
1072
+ case 'TK_SEMICOLON':
1073
+
1074
+ print_token();
1075
+ flags.var_line = false;
1076
+ flags.var_line_reindented = false;
1077
+ if (flags.mode === 'OBJECT') {
1078
+ // OBJECT mode is weird and doesn't get reset too well.
1079
+ flags.mode = 'BLOCK';
1080
+ }
1081
+ break;
1082
+
1083
+ case 'TK_STRING':
1084
+
1085
+ if (last_type === 'TK_END_EXPR' && in_array(flags.previous_mode, ['(COND-EXPRESSION)', '(FOR-EXPRESSION)'])) {
1086
+ print_single_space();
1087
+ } else if (last_type === 'TK_COMMENT' || last_type === 'TK_STRING' || last_type === 'TK_START_BLOCK' || last_type === 'TK_END_BLOCK' || last_type === 'TK_SEMICOLON') {
1088
+ print_newline();
1089
+ } else if (last_type === 'TK_WORD') {
1090
+ print_single_space();
1091
+ }
1092
+ print_token();
1093
+ break;
1094
+
1095
+ case 'TK_EQUALS':
1096
+ if (flags.var_line) {
1097
+ // just got an '=' in a var-line, different formatting/line-breaking, etc will now be done
1098
+ flags.var_line_tainted = true;
1099
+ }
1100
+ print_single_space();
1101
+ print_token();
1102
+ print_single_space();
1103
+ break;
1104
+
1105
+ case 'TK_COMMA':
1106
+ if (flags.var_line) {
1107
+ if (is_expression(flags.mode) || last_type === 'TK_END_BLOCK' ) {
1108
+ // do not break on comma, for(var a = 1, b = 2)
1109
+ flags.var_line_tainted = false;
1110
+ }
1111
+ if (flags.var_line_tainted) {
1112
+ print_token();
1113
+ flags.var_line_reindented = true;
1114
+ flags.var_line_tainted = false;
1115
+ print_newline();
1116
+ break;
1117
+ } else {
1118
+ flags.var_line_tainted = false;
1119
+ }
1120
+
1121
+ print_token();
1122
+ print_single_space();
1123
+ break;
1124
+ }
1125
+
1126
+ if (last_type === 'TK_COMMENT') {
1127
+ print_newline();
1128
+ }
1129
+
1130
+ if (last_type === 'TK_END_BLOCK' && flags.mode !== "(EXPRESSION)") {
1131
+ print_token();
1132
+ if (flags.mode === 'OBJECT' && last_text === '}') {
1133
+ print_newline();
1134
+ } else {
1135
+ print_single_space();
1136
+ }
1137
+ } else {
1138
+ if (flags.mode === 'OBJECT') {
1139
+ print_token();
1140
+ print_newline();
1141
+ } else {
1142
+ // EXPR or DO_BLOCK
1143
+ print_token();
1144
+ print_single_space();
1145
+ }
1146
+ }
1147
+ break;
1148
+
1149
+
1150
+ case 'TK_OPERATOR':
1151
+
1152
+ var space_before = true;
1153
+ var space_after = true;
1154
+
1155
+ if (is_special_word(last_text)) {
1156
+ // "return" had a special handling in TK_WORD. Now we need to return the favor
1157
+ print_single_space();
1158
+ print_token();
1159
+ break;
1160
+ }
1161
+
1162
+ // hack for actionscript's import .*;
1163
+ if (token_text === '*' && last_type === 'TK_UNKNOWN' && !last_last_text.match(/^\d+$/)) {
1164
+ print_token();
1165
+ break;
1166
+ }
1167
+
1168
+ if (token_text === ':' && flags.in_case) {
1169
+ if (opt_indent_case) {
1170
+ flags.case_body = true;
1171
+ }
1172
+ print_token(); // colon really asks for separate treatment
1173
+ print_newline();
1174
+ flags.in_case = false;
1175
+ break;
1176
+ }
1177
+
1178
+ if (token_text === '::') {
1179
+ // no spaces around exotic namespacing syntax operator
1180
+ print_token();
1181
+ break;
1182
+ }
1183
+
1184
+ if (in_array(token_text, ['--', '++', '!']) || (in_array(token_text, ['-', '+']) && (in_array(last_type, ['TK_START_BLOCK', 'TK_START_EXPR', 'TK_EQUALS', 'TK_OPERATOR']) || in_array(last_text, line_starters)))) {
1185
+ // unary operators (and binary +/- pretending to be unary) special cases
1186
+
1187
+ space_before = false;
1188
+ space_after = false;
1189
+
1190
+ if (last_text === ';' && is_expression(flags.mode)) {
1191
+ // for (;; ++i)
1192
+ // ^^^
1193
+ space_before = true;
1194
+ }
1195
+ if (last_type === 'TK_WORD' && in_array(last_text, line_starters)) {
1196
+ space_before = true;
1197
+ }
1198
+
1199
+ if (flags.mode === 'BLOCK' && (last_text === '{' || last_text === ';')) {
1200
+ // { foo; --i }
1201
+ // foo(); --bar;
1202
+ print_newline();
1203
+ }
1204
+ } else if (token_text === '.') {
1205
+ // decimal digits or object.property
1206
+ space_before = false;
1207
+
1208
+ } else if (token_text === ':') {
1209
+ if (flags.ternary_depth === 0) {
1210
+ if (flags.mode === 'BLOCK') {
1211
+ flags.mode = 'OBJECT';
1212
+ }
1213
+ space_before = false;
1214
+ } else {
1215
+ flags.ternary_depth -= 1;
1216
+ }
1217
+ } else if (token_text === '?') {
1218
+ flags.ternary_depth += 1;
1219
+ }
1220
+ if (space_before) {
1221
+ print_single_space();
1222
+ }
1223
+
1224
+ print_token();
1225
+
1226
+ if (space_after) {
1227
+ print_single_space();
1228
+ }
1229
+
1230
+ break;
1231
+
1232
+ case 'TK_BLOCK_COMMENT':
1233
+
1234
+ var lines = split_newlines(token_text);
1235
+ var j; // iterator for this case
1236
+
1237
+ if (all_lines_start_with(lines.slice(1), '*')) {
1238
+ // javadoc: reformat and reindent
1239
+ print_newline();
1240
+ output.push(lines[0]);
1241
+ for (j = 1; j < lines.length; j++) {
1242
+ print_newline();
1243
+ output.push(' ');
1244
+ output.push(trim(lines[j]));
1245
+ }
1246
+
1247
+ } else {
1248
+
1249
+ // simple block comment: leave intact
1250
+ if (lines.length > 1) {
1251
+ // multiline comment block starts with a new line
1252
+ print_newline();
1253
+ } else {
1254
+ // single-line /* comment */ stays where it is
1255
+ if (last_type === 'TK_END_BLOCK') {
1256
+ print_newline();
1257
+ } else {
1258
+ print_single_space();
1259
+ }
1260
+
1261
+ }
1262
+
1263
+ for (j = 0; j < lines.length; j++) {
1264
+ output.push(lines[j]);
1265
+ output.push("\n");
1266
+ }
1267
+
1268
+ }
1269
+ if (look_up('\n') !== '\n') {
1270
+ print_newline();
1271
+ }
1272
+ break;
1273
+
1274
+ case 'TK_INLINE_COMMENT':
1275
+ print_single_space();
1276
+ print_token();
1277
+ if (is_expression(flags.mode)) {
1278
+ print_single_space();
1279
+ } else {
1280
+ force_newline();
1281
+ }
1282
+ break;
1283
+
1284
+ case 'TK_COMMENT':
1285
+
1286
+ if (last_text === ',' && !wanted_newline) {
1287
+ trim_output(true);
1288
+ }
1289
+ if (last_type !== 'TK_COMMENT') {
1290
+ if (wanted_newline) {
1291
+ print_newline();
1292
+ } else {
1293
+ print_single_space();
1294
+ }
1295
+ }
1296
+ print_token();
1297
+ print_newline();
1298
+ break;
1299
+
1300
+ case 'TK_UNKNOWN':
1301
+ if (is_special_word(last_text)) {
1302
+ print_single_space();
1303
+ }
1304
+ print_token();
1305
+ break;
1306
+ }
1307
+
1308
+ last_last_text = last_text;
1309
+ last_type = token_type;
1310
+ last_text = token_text;
1311
+ }
1312
+
1313
+ var sweet_code = preindent_string + output.join('').replace(/[\r\n ]+$/, '');
1314
+ return sweet_code;
1315
+
1316
+ }
1317
+
1318
+ // Add support for CommonJS. Just put this file somewhere on your require.paths
1319
+ // and you will be able to `var js_beautify = require("beautify").js_beautify`.
1320
+ if (typeof exports !== "undefined") {
1321
+ exports.js_beautify = js_beautify;
1322
+ }