js-beautify 1.10.2 → 1.13.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -75,7 +75,7 @@ var dot_pattern = /[^\d\.]/;
75
75
 
76
76
  var positionable_operators = (
77
77
  ">>> === !== " +
78
- "<< && >= ** != == <= >> || " +
78
+ "<< && >= ** != == <= >> || ?? |> " +
79
79
  "< / - + > : & % ? ^ | *").split(' ');
80
80
 
81
81
  // IMPORTANT: this must be sorted longest to shortest or tokenizing many not work.
@@ -83,10 +83,12 @@ var positionable_operators = (
83
83
  var punct =
84
84
  ">>>= " +
85
85
  "... >>= <<= === >>> !== **= " +
86
- "=> ^= :: /= << <= == && -= >= >> != -- += ** || ++ %= &= *= |= " +
86
+ "=> ^= :: /= << <= == && -= >= >> != -- += ** || ?? ++ %= &= *= |= |> " +
87
87
  "= ! ? > < : / ^ - + * & % ~ |";
88
88
 
89
89
  punct = punct.replace(/[-[\]{}()*+?.,\\^$|#]/g, "\\$&");
90
+ // ?. but not if followed by a number
91
+ punct = '\\?\\.(?!\\d) ' + punct;
90
92
  punct = punct.replace(/ /g, '|');
91
93
 
92
94
  var punct_pattern = new RegExp(punct);
@@ -163,13 +165,13 @@ Tokenizer.prototype._get_next_token = function(previous_token, open_token) { //
163
165
  return this._create_token(TOKEN.EOF, '');
164
166
  }
165
167
 
168
+ token = token || this._read_non_javascript(c);
166
169
  token = token || this._read_string(c);
167
170
  token = token || this._read_word(previous_token);
168
171
  token = token || this._read_singles(c);
169
172
  token = token || this._read_comment(c);
170
173
  token = token || this._read_regexp(c, previous_token);
171
174
  token = token || this._read_xml(c, previous_token);
172
- token = token || this._read_non_javascript(c);
173
175
  token = token || this._read_punctuation();
174
176
  token = token || this._create_token(TOKEN.UNKNOWN, this._input.next());
175
177
 
@@ -228,6 +230,8 @@ Tokenizer.prototype._read_punctuation = function() {
228
230
  if (resulting_string !== '') {
229
231
  if (resulting_string === '=') {
230
232
  return this._create_token(TOKEN.EQUALS, resulting_string);
233
+ } else if (resulting_string === '?.') {
234
+ return this._create_token(TOKEN.DOT, resulting_string);
231
235
  } else {
232
236
  return this._create_token(TOKEN.OPERATOR, resulting_string);
233
237
  }
@@ -100,6 +100,14 @@ var P_A_C_K_E_R = {
100
100
  t.expect(pk1, unpk1);
101
101
  t.expect(pk2, unpk2);
102
102
  t.expect(pk3, unpk3);
103
+ t.expect("function test (){alert ('This is a test!')}; " +
104
+ "eval(function(p,a,c,k,e,r){e=String;if(!''.replace(/^/,String))" +
105
+ "{while(c--)r[c]=k[c]||c;k=[function(e){return r[e]}];e=function" +
106
+ "(){return'\\w+'};c=1};while(c--)if(k[c])p=p.replace(new RegExp(" +
107
+ "'\\b'+e(c)+'\\b','g'),k[c]);return p}('0 2=\\\'{Íâ–+›ï;ã†Ù¥#\\\'',3,3," +
108
+ "'var||a'.split('|'),0,{}))",
109
+ "function test (){alert ('This is a test!')}; var a='{Íâ–+›ï;ã†Ù¥#'");
110
+
103
111
 
104
112
  var filler = '\nfiller\n';
105
113
  t.expect(filler + pk1 + "\n" + pk_broken + filler + pk2 + filler, filler + unpk1 + "\n" + pk_broken + filler + unpk2 + filler);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "js-beautify",
3
- "version": "1.10.2",
3
+ "version": "1.13.0",
4
4
  "description": "beautifier.io for node",
5
5
  "main": "js/index.js",
6
6
  "bin": {
@@ -48,19 +48,20 @@
48
48
  "config-chain": "^1.1.12",
49
49
  "editorconfig": "^0.15.3",
50
50
  "glob": "^7.1.3",
51
- "mkdirp": "~0.5.1",
52
- "nopt": "~4.0.1"
51
+ "mkdirp": "^1.0.4",
52
+ "nopt": "^5.0.0"
53
53
  },
54
54
  "devDependencies": {
55
55
  "benchmark": "^2.1.4",
56
- "codemirror": "^5.48.2",
57
- "jquery": "^3.4.1",
58
- "jshint": "^2.10.2",
59
- "mocha": "^6.1.4",
60
- "mustache": "^3.0.1",
61
- "node-static": "^0.7.11",
56
+ "codemirror": "^5.56.0",
57
+ "jquery": "^3.5.1",
58
+ "jshint": "^2.12.0",
59
+ "minimist": ">=1.2.5",
60
+ "mocha": "^8.1.1",
61
+ "mustache": "^4.0.1",
62
+ "serve": "^11.3.2",
62
63
  "requirejs": "^2.3.6",
63
- "webpack": "^4.36.1",
64
- "webpack-cli": "^3.3.5"
64
+ "webpack": "^4.44.1",
65
+ "webpack-cli": "^3.3.12"
65
66
  }
66
67
  }