babel-schmooze-sprockets 0.1.2 → 0.1.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (122) hide show
  1. checksums.yaml +4 -4
  2. data/bin/console +14 -0
  3. data/bin/export-external-helpers +3 -0
  4. data/bin/setup +6 -0
  5. data/bin/update-npm-deps +8 -0
  6. data/examples/myapp/Gemfile +4 -5
  7. data/examples/myapp/Gemfile.lock +69 -93
  8. data/examples/myapp/app/assets/javascripts/code/hello.es6 +5 -1
  9. data/examples/myapp/app/views/layouts/application.html.erb +1 -0
  10. data/examples/myapp/app/views/site/home.html.erb +0 -1
  11. data/lib/babel-schmooze-sprockets/babel_processor.rb +6 -4
  12. data/lib/babel-schmooze-sprockets/engine.rb +1 -4
  13. data/lib/babel-schmooze-sprockets/version.rb +1 -1
  14. data/node_modules/amdefine/package.json +8 -1
  15. data/node_modules/babel-core/node_modules/babel-runtime/package.json +9 -5
  16. data/node_modules/babel-core/node_modules/babel-traverse/.npmignore +3 -0
  17. data/node_modules/babel-core/node_modules/babel-traverse/README.md +1 -0
  18. data/node_modules/babel-core/node_modules/babel-traverse/lib/cache.js +20 -0
  19. data/node_modules/babel-core/node_modules/babel-traverse/lib/context.js +219 -0
  20. data/node_modules/babel-core/node_modules/babel-traverse/lib/hub.js +19 -0
  21. data/node_modules/babel-core/node_modules/babel-traverse/lib/index.js +250 -0
  22. data/node_modules/babel-core/node_modules/babel-traverse/lib/path/ancestry.js +317 -0
  23. data/node_modules/babel-core/node_modules/babel-traverse/lib/path/comments.js +55 -0
  24. data/node_modules/babel-core/node_modules/babel-traverse/lib/path/context.js +297 -0
  25. data/node_modules/babel-core/node_modules/babel-traverse/lib/path/conversion.js +48 -0
  26. data/node_modules/babel-core/node_modules/babel-traverse/lib/path/evaluation.js +406 -0
  27. data/node_modules/babel-core/node_modules/babel-traverse/lib/path/family.js +168 -0
  28. data/node_modules/babel-core/node_modules/babel-traverse/lib/path/index.js +245 -0
  29. data/node_modules/babel-core/node_modules/babel-traverse/lib/path/inference/index.js +151 -0
  30. data/node_modules/babel-core/node_modules/babel-traverse/lib/path/inference/inferer-reference.js +225 -0
  31. data/node_modules/babel-core/node_modules/babel-traverse/lib/path/inference/inferers.js +198 -0
  32. data/node_modules/babel-core/node_modules/babel-traverse/lib/path/introspection.js +518 -0
  33. data/node_modules/babel-core/node_modules/babel-traverse/lib/path/lib/hoister.js +166 -0
  34. data/node_modules/babel-core/node_modules/babel-traverse/lib/path/lib/removal-hooks.js +64 -0
  35. data/node_modules/babel-core/node_modules/babel-traverse/lib/path/lib/virtual-types.js +141 -0
  36. data/node_modules/babel-core/node_modules/babel-traverse/lib/path/modification.js +293 -0
  37. data/node_modules/babel-core/node_modules/babel-traverse/lib/path/removal.js +72 -0
  38. data/node_modules/babel-core/node_modules/babel-traverse/lib/path/replacement.js +302 -0
  39. data/node_modules/babel-core/node_modules/babel-traverse/lib/scope/binding.js +105 -0
  40. data/node_modules/babel-core/node_modules/babel-traverse/lib/scope/index.js +1222 -0
  41. data/node_modules/babel-core/node_modules/babel-traverse/lib/scope/lib/renamer.js +154 -0
  42. data/node_modules/babel-core/node_modules/babel-traverse/lib/visitors.js +360 -0
  43. data/node_modules/babel-core/node_modules/babel-traverse/package.json +107 -0
  44. data/node_modules/babel-core/node_modules/core-js/package.json +20 -2
  45. data/node_modules/babel-core/package.json +31 -24
  46. data/node_modules/babel-generator/lib/buffer.js +69 -70
  47. data/node_modules/babel-generator/lib/generators/base.js +16 -12
  48. data/node_modules/babel-generator/lib/generators/classes.js +28 -19
  49. data/node_modules/babel-generator/lib/generators/expressions.js +76 -99
  50. data/node_modules/babel-generator/lib/generators/flow.js +178 -119
  51. data/node_modules/babel-generator/lib/generators/jsx.js +38 -29
  52. data/node_modules/babel-generator/lib/generators/methods.js +34 -25
  53. data/node_modules/babel-generator/lib/generators/modules.js +67 -40
  54. data/node_modules/babel-generator/lib/generators/statements.js +93 -76
  55. data/node_modules/babel-generator/lib/generators/template-literals.js +12 -11
  56. data/node_modules/babel-generator/lib/generators/types.js +56 -49
  57. data/node_modules/babel-generator/lib/index.js +52 -39
  58. data/node_modules/babel-generator/lib/node/index.js +12 -18
  59. data/node_modules/babel-generator/lib/node/parentheses.js +23 -27
  60. data/node_modules/babel-generator/lib/node/whitespace.js +20 -26
  61. data/node_modules/babel-generator/lib/position.js +5 -5
  62. data/node_modules/babel-generator/lib/printer.js +52 -81
  63. data/node_modules/babel-generator/lib/source-map.js +9 -11
  64. data/node_modules/babel-generator/lib/whitespace.js +13 -13
  65. data/node_modules/babel-generator/node_modules/babel-runtime/package.json +19 -6
  66. data/node_modules/babel-generator/node_modules/babel-types/.npmignore +3 -0
  67. data/node_modules/babel-generator/node_modules/babel-types/README.md +1141 -0
  68. data/node_modules/babel-generator/node_modules/babel-types/lib/constants.js +40 -0
  69. data/node_modules/babel-generator/node_modules/babel-types/lib/converters.js +378 -0
  70. data/node_modules/babel-generator/node_modules/babel-types/lib/definitions/core.js +704 -0
  71. data/node_modules/babel-generator/node_modules/babel-types/lib/definitions/es2015.js +354 -0
  72. data/node_modules/babel-generator/node_modules/babel-types/lib/definitions/experimental.js +85 -0
  73. data/node_modules/babel-generator/node_modules/babel-types/lib/definitions/flow.js +319 -0
  74. data/node_modules/babel-generator/node_modules/babel-types/lib/definitions/index.js +247 -0
  75. data/node_modules/babel-generator/node_modules/babel-types/lib/definitions/init.js +15 -0
  76. data/node_modules/babel-generator/node_modules/babel-types/lib/definitions/jsx.js +137 -0
  77. data/node_modules/babel-generator/node_modules/babel-types/lib/definitions/misc.js +21 -0
  78. data/node_modules/babel-generator/node_modules/babel-types/lib/flow.js +129 -0
  79. data/node_modules/babel-generator/node_modules/babel-types/lib/index.js +848 -0
  80. data/node_modules/babel-generator/node_modules/babel-types/lib/react.js +83 -0
  81. data/node_modules/babel-generator/node_modules/babel-types/lib/retrievers.js +123 -0
  82. data/node_modules/babel-generator/node_modules/babel-types/lib/validators.js +276 -0
  83. data/node_modules/babel-generator/node_modules/babel-types/package.json +103 -0
  84. data/node_modules/babel-generator/node_modules/core-js/package.json +10 -5
  85. data/node_modules/babel-generator/package.json +19 -16
  86. data/node_modules/babel-helpers/node_modules/babel-runtime/package.json +19 -3
  87. data/node_modules/babel-helpers/node_modules/core-js/package.json +20 -4
  88. data/node_modules/babel-helpers/package.json +8 -1
  89. data/node_modules/babel-register/node_modules/babel-runtime/package.json +19 -3
  90. data/node_modules/babel-register/node_modules/core-js/package.json +20 -4
  91. data/node_modules/babel-register/package.json +8 -1
  92. data/node_modules/balanced-match/package.json +8 -1
  93. data/node_modules/brace-expansion/package.json +19 -12
  94. data/node_modules/concat-map/package.json +9 -2
  95. data/node_modules/convert-source-map/package.json +8 -1
  96. data/node_modules/detect-indent/package.json +8 -1
  97. data/node_modules/get-stdin/package.json +8 -1
  98. data/node_modules/home-or-tmp/package.json +9 -2
  99. data/node_modules/is-finite/package.json +8 -2
  100. data/node_modules/json5/package.json +8 -1
  101. data/node_modules/minimatch/README.md +2 -9
  102. data/node_modules/minimatch/minimatch.js +15 -3
  103. data/node_modules/minimatch/package.json +29 -21
  104. data/node_modules/minimist/package.json +8 -1
  105. data/node_modules/mkdirp/node_modules/minimist/package.json +8 -1
  106. data/node_modules/mkdirp/package.json +8 -1
  107. data/node_modules/number-is-nan/package.json +8 -1
  108. data/node_modules/os-tmpdir/package.json +8 -1
  109. data/node_modules/path-exists/package.json +8 -1
  110. data/node_modules/path-is-absolute/package.json +8 -1
  111. data/node_modules/repeating/package.json +15 -11
  112. data/node_modules/shebang-regex/package.json +8 -1
  113. data/node_modules/slash/package.json +8 -1
  114. data/node_modules/source-map-support/node_modules/source-map/package.json +8 -1
  115. data/node_modules/source-map-support/package.json +8 -1
  116. data/node_modules/source-map/package.json +8 -1
  117. data/node_modules/user-home/package.json +8 -1
  118. data/package.json +1 -1
  119. metadata +54 -6
  120. data/node_modules/brace-expansion/.npmignore +0 -3
  121. data/node_modules/brace-expansion/example.js +0 -8
  122. data/node_modules/minimatch/browser.js +0 -1159
@@ -0,0 +1,107 @@
1
+ {
2
+ "_args": [
3
+ [
4
+ {
5
+ "name": "babel-traverse",
6
+ "raw": "babel-traverse@^6.10.4",
7
+ "rawSpec": "^6.10.4",
8
+ "scope": null,
9
+ "spec": ">=6.10.4 <7.0.0",
10
+ "type": "range"
11
+ },
12
+ "/Users/fnando/Projects/babel-schmooze-sprockets/node_modules/babel-core"
13
+ ]
14
+ ],
15
+ "_from": "babel-traverse@>=6.10.4 <7.0.0",
16
+ "_id": "babel-traverse@6.10.4",
17
+ "_inCache": true,
18
+ "_installable": true,
19
+ "_location": "/babel-core/babel-traverse",
20
+ "_nodeVersion": "5.9.0",
21
+ "_npmOperationalInternal": {
22
+ "host": "packages-16-east.internal.npmjs.com",
23
+ "tmp": "tmp/babel-traverse-6.10.4.tgz_1466527417697_0.9045669895131141"
24
+ },
25
+ "_npmUser": {
26
+ "email": "loganfsmyth@gmail.com",
27
+ "name": "loganfsmyth"
28
+ },
29
+ "_npmVersion": "3.9.3",
30
+ "_phantomChildren": {},
31
+ "_requested": {
32
+ "name": "babel-traverse",
33
+ "raw": "babel-traverse@^6.10.4",
34
+ "rawSpec": "^6.10.4",
35
+ "scope": null,
36
+ "spec": ">=6.10.4 <7.0.0",
37
+ "type": "range"
38
+ },
39
+ "_requiredBy": [
40
+ "/babel-core"
41
+ ],
42
+ "_resolved": "https://registry.npmjs.org/babel-traverse/-/babel-traverse-6.10.4.tgz",
43
+ "_shasum": "dbcf41ff1f32eb614859cead4871160f1f120d78",
44
+ "_shrinkwrap": null,
45
+ "_spec": "babel-traverse@^6.10.4",
46
+ "_where": "/Users/fnando/Projects/babel-schmooze-sprockets/node_modules/babel-core",
47
+ "author": {
48
+ "email": "sebmck@gmail.com",
49
+ "name": "Sebastian McKenzie"
50
+ },
51
+ "dependencies": {
52
+ "babel-code-frame": "^6.8.0",
53
+ "babel-messages": "^6.8.0",
54
+ "babel-runtime": "^6.9.0",
55
+ "babel-types": "^6.9.0",
56
+ "babylon": "^6.7.0",
57
+ "debug": "^2.2.0",
58
+ "globals": "^8.3.0",
59
+ "invariant": "^2.2.0",
60
+ "lodash": "^4.2.0"
61
+ },
62
+ "description": "",
63
+ "devDependencies": {},
64
+ "directories": {},
65
+ "dist": {
66
+ "shasum": "dbcf41ff1f32eb614859cead4871160f1f120d78",
67
+ "tarball": "https://registry.npmjs.org/babel-traverse/-/babel-traverse-6.10.4.tgz"
68
+ },
69
+ "homepage": "https://babeljs.io/",
70
+ "license": "MIT",
71
+ "main": "lib/index.js",
72
+ "maintainers": [
73
+ {
74
+ "email": "amjad.masad@gmail.com",
75
+ "name": "amasad"
76
+ },
77
+ {
78
+ "email": "hi@henryzoo.com",
79
+ "name": "hzoo"
80
+ },
81
+ {
82
+ "email": "npm-public@jessemccarthy.net",
83
+ "name": "jmm"
84
+ },
85
+ {
86
+ "email": "loganfsmyth@gmail.com",
87
+ "name": "loganfsmyth"
88
+ },
89
+ {
90
+ "email": "sebmck@gmail.com",
91
+ "name": "sebmck"
92
+ },
93
+ {
94
+ "email": "me@thejameskyle.com",
95
+ "name": "thejameskyle"
96
+ }
97
+ ],
98
+ "name": "babel-traverse",
99
+ "optionalDependencies": {},
100
+ "readme": "ERROR: No README data found!",
101
+ "repository": {
102
+ "type": "git",
103
+ "url": "https://github.com/babel/babel/tree/master/packages/babel-traverse"
104
+ },
105
+ "scripts": {},
106
+ "version": "6.10.4"
107
+ }
@@ -1,11 +1,29 @@
1
1
  {
2
2
  "_args": [
3
3
  [
4
- "core-js@^2.4.0",
4
+ {
5
+ "name": "core-js",
6
+ "raw": "core-js@^2.4.0",
7
+ "rawSpec": "^2.4.0",
8
+ "scope": null,
9
+ "spec": ">=2.4.0 <3.0.0",
10
+ "type": "range"
11
+ },
12
+ "/Users/fnando/Projects/babel-schmooze-sprockets/node_modules/babel-generator/node_modules/babel-runtime"
13
+ ],
14
+ [
15
+ {
16
+ "name": "core-js",
17
+ "raw": "core-js@^2.4.0",
18
+ "rawSpec": "^2.4.0",
19
+ "scope": null,
20
+ "spec": ">=2.4.0 <3.0.0",
21
+ "type": "range"
22
+ },
5
23
  "/Users/fnando/Projects/babel-schmooze-sprockets/node_modules/babel-core/node_modules/babel-runtime"
6
24
  ]
7
25
  ],
8
- "_from": "core-js@>=2.4.0 <3.0.0",
26
+ "_from": "core-js@^2.4.0",
9
27
  "_id": "core-js@2.4.0",
10
28
  "_inCache": true,
11
29
  "_installable": true,
@@ -1,42 +1,49 @@
1
1
  {
2
2
  "_args": [
3
3
  [
4
- "babel-core@6.9.1",
4
+ {
5
+ "name": "babel-core",
6
+ "raw": "babel-core@6.10.4",
7
+ "rawSpec": "6.10.4",
8
+ "scope": null,
9
+ "spec": "6.10.4",
10
+ "type": "version"
11
+ },
5
12
  "/Users/fnando/Projects/babel-schmooze-sprockets"
6
13
  ]
7
14
  ],
8
- "_from": "babel-core@6.9.1",
9
- "_id": "babel-core@6.9.1",
15
+ "_from": "babel-core@6.10.4",
16
+ "_id": "babel-core@6.10.4",
10
17
  "_inCache": true,
11
18
  "_installable": true,
12
19
  "_location": "/babel-core",
13
- "_nodeVersion": "5.1.0",
20
+ "_nodeVersion": "5.9.0",
14
21
  "_npmOperationalInternal": {
15
22
  "host": "packages-12-west.internal.npmjs.com",
16
- "tmp": "tmp/babel-core-6.9.1.tgz_1464551408093_0.2568425089120865"
23
+ "tmp": "tmp/babel-core-6.10.4.tgz_1466527417705_0.10249125026166439"
17
24
  },
18
25
  "_npmUser": {
19
- "email": "hi@henryzoo.com",
20
- "name": "hzoo"
26
+ "email": "loganfsmyth@gmail.com",
27
+ "name": "loganfsmyth"
21
28
  },
22
- "_npmVersion": "3.8.6",
29
+ "_npmVersion": "3.9.3",
23
30
  "_phantomChildren": {
31
+ "babel-code-frame": "6.8.0",
32
+ "babel-messages": "6.8.0",
33
+ "babel-types": "6.9.1",
24
34
  "babylon": "6.7.0",
25
- "chalk": "1.1.3",
26
35
  "debug": "2.2.0",
27
- "esutils": "2.0.2",
28
36
  "globals": "8.18.0",
29
37
  "invariant": "2.2.1",
30
- "js-tokens": "1.0.3",
31
- "regenerator-runtime": "0.9.5",
32
- "to-fast-properties": "1.0.2"
38
+ "lodash": "4.13.1",
39
+ "regenerator-runtime": "0.9.5"
33
40
  },
34
41
  "_requested": {
35
42
  "name": "babel-core",
36
- "raw": "babel-core@6.9.1",
37
- "rawSpec": "6.9.1",
43
+ "raw": "babel-core@6.10.4",
44
+ "rawSpec": "6.10.4",
38
45
  "scope": null,
39
- "spec": "6.9.1",
46
+ "spec": "6.10.4",
40
47
  "type": "version"
41
48
  },
42
49
  "_requiredBy": [
@@ -44,10 +51,10 @@
44
51
  "/babel-plugin-transform-regenerator",
45
52
  "/babel-register"
46
53
  ],
47
- "_resolved": "https://registry.npmjs.org/babel-core/-/babel-core-6.9.1.tgz",
48
- "_shasum": "48d471eebf4de469e0a942fe456dcc94b18be80d",
54
+ "_resolved": "https://registry.npmjs.org/babel-core/-/babel-core-6.10.4.tgz",
55
+ "_shasum": "283f2212bb03d4e5cd7498b9886efbf6fc2e238e",
49
56
  "_shrinkwrap": null,
50
- "_spec": "babel-core@6.9.1",
57
+ "_spec": "babel-core@6.10.4",
51
58
  "_where": "/Users/fnando/Projects/babel-schmooze-sprockets",
52
59
  "author": {
53
60
  "email": "sebmck@gmail.com",
@@ -61,14 +68,14 @@
61
68
  "babel-register": "^6.9.0",
62
69
  "babel-runtime": "^6.9.1",
63
70
  "babel-template": "^6.9.0",
64
- "babel-traverse": "^6.9.0",
71
+ "babel-traverse": "^6.10.4",
65
72
  "babel-types": "^6.9.1",
66
73
  "babylon": "^6.7.0",
67
74
  "convert-source-map": "^1.1.0",
68
75
  "debug": "^2.1.1",
69
76
  "json5": "^0.4.0",
70
77
  "lodash": "^4.2.0",
71
- "minimatch": "^2.0.3",
78
+ "minimatch": "^3.0.2",
72
79
  "path-exists": "^1.0.0",
73
80
  "path-is-absolute": "^1.0.0",
74
81
  "private": "^0.1.6",
@@ -84,8 +91,8 @@
84
91
  },
85
92
  "directories": {},
86
93
  "dist": {
87
- "shasum": "48d471eebf4de469e0a942fe456dcc94b18be80d",
88
- "tarball": "https://registry.npmjs.org/babel-core/-/babel-core-6.9.1.tgz"
94
+ "shasum": "283f2212bb03d4e5cd7498b9886efbf6fc2e238e",
95
+ "tarball": "https://registry.npmjs.org/babel-core/-/babel-core-6.10.4.tgz"
89
96
  },
90
97
  "homepage": "https://babeljs.io/",
91
98
  "keywords": [
@@ -139,5 +146,5 @@
139
146
  "bench": "make bench",
140
147
  "test": "make test"
141
148
  },
142
- "version": "6.9.1"
149
+ "version": "6.10.4"
143
150
  }
@@ -1,4 +1,4 @@
1
- /*istanbul ignore next*/"use strict";
1
+ "use strict";
2
2
 
3
3
  exports.__esModule = true;
4
4
 
@@ -6,14 +6,12 @@ var _classCallCheck2 = require("babel-runtime/helpers/classCallCheck");
6
6
 
7
7
  var _classCallCheck3 = _interopRequireDefault(_classCallCheck2);
8
8
 
9
- var /*istanbul ignore next*/_repeat = require("lodash/repeat");
9
+ var _repeat = require("lodash/repeat");
10
10
 
11
- /*istanbul ignore next*/
12
11
  var _repeat2 = _interopRequireDefault(_repeat);
13
12
 
14
- var /*istanbul ignore next*/_trimEnd = require("lodash/trimEnd");
13
+ var _trimEnd = require("lodash/trimEnd");
15
14
 
16
- /*istanbul ignore next*/
17
15
  var _trimEnd2 = _interopRequireDefault(_trimEnd);
18
16
 
19
17
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
@@ -23,8 +21,8 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
23
21
  */
24
22
 
25
23
  var Buffer = function () {
26
- function /*istanbul ignore next*/Buffer(position, format) {
27
- /*istanbul ignore next*/(0, _classCallCheck3.default)(this, Buffer);
24
+ function Buffer(position, format) {
25
+ (0, _classCallCheck3.default)(this, Buffer);
28
26
 
29
27
  this.printedCommentStarts = {};
30
28
  this.parenPushNewlineState = null;
@@ -44,6 +42,7 @@ var Buffer = function () {
44
42
  column: null,
45
43
  filename: null
46
44
  };
45
+ this._endsWithWord = false;
47
46
  }
48
47
 
49
48
  /**
@@ -54,7 +53,7 @@ var Buffer = function () {
54
53
  // catch up to this nodes newline if we're behind
55
54
  if (node.loc && this.format.retainLines && this.buf) {
56
55
  while (this.position.line < node.loc.start.line) {
57
- this._push("\n");
56
+ this.push("\n");
58
57
  }
59
58
  }
60
59
  };
@@ -64,8 +63,7 @@ var Buffer = function () {
64
63
  */
65
64
 
66
65
  Buffer.prototype.get = function get() {
67
- return (/*istanbul ignore next*/(0, _trimEnd2.default)(this.buf)
68
- );
66
+ return (0, _trimEnd2.default)(this.buf);
69
67
  };
70
68
 
71
69
  /**
@@ -76,8 +74,7 @@ var Buffer = function () {
76
74
  if (this.format.compact || this.format.concise) {
77
75
  return "";
78
76
  } else {
79
- return (/*istanbul ignore next*/(0, _repeat2.default)(this.format.indent.style, this._indent)
80
- );
77
+ return (0, _repeat2.default)(this.format.indent.style, this._indent);
81
78
  }
82
79
  };
83
80
 
@@ -110,15 +107,7 @@ var Buffer = function () {
110
107
  */
111
108
 
112
109
  Buffer.prototype.semicolon = function semicolon() {
113
- this.push(";");
114
- };
115
-
116
- /**
117
- * Ensure last character is a semicolon.
118
- */
119
-
120
- Buffer.prototype.ensureSemicolon = function ensureSemicolon() {
121
- if (!this.isLast(";")) this.semicolon();
110
+ this.token(";");
122
111
  };
123
112
 
124
113
  /**
@@ -130,7 +119,7 @@ var Buffer = function () {
130
119
  if (this.format.minified && !this._lastPrintedIsEmptyStatement) {
131
120
  this._removeLast(";");
132
121
  }
133
- this.push("}");
122
+ this.token("}");
134
123
  };
135
124
 
136
125
  /**
@@ -138,20 +127,48 @@ var Buffer = function () {
138
127
  */
139
128
 
140
129
  Buffer.prototype.keyword = function keyword(name) {
141
- this.push(name);
130
+ this.word(name);
142
131
  this.space();
143
132
  };
144
133
 
145
134
  /**
146
- * Add a space to the buffer unless it is compact (override with force).
135
+ * Add a space to the buffer unless it is compact.
136
+ */
137
+
138
+ Buffer.prototype.space = function space() {
139
+ if (this.format.compact) return;
140
+
141
+ if (this.buf && !this.endsWith(" ") && !this.endsWith("\n")) {
142
+ this.push(" ");
143
+ }
144
+ };
145
+
146
+ /**
147
+ * Writes a token that can't be safely parsed without taking whitespace into account.
147
148
  */
148
149
 
149
- Buffer.prototype.space = function space(force) {
150
- if (!force && this.format.compact) return;
150
+ Buffer.prototype.word = function word(str) {
151
+ if (this._endsWithWord) this.push(" ");
151
152
 
152
- if (force || this.buf && !this.isLast(" ") && !this.isLast("\n")) {
153
+ this.push(str);
154
+ this._endsWithWord = true;
155
+ };
156
+
157
+ /**
158
+ * Writes a simple token.
159
+ */
160
+
161
+ Buffer.prototype.token = function token(str) {
162
+ // space is mandatory to avoid outputting <!--
163
+ // http://javascript.spec.whatwg.org/#comment-syntax
164
+ if (str === "--" && this.last === "!" ||
165
+
166
+ // Need spaces for operators of the same kind to avoid: `a+++b`
167
+ str[0] === "+" && this.last === "+" || str[0] === "-" && this.last === "-") {
153
168
  this.push(" ");
154
169
  }
170
+
171
+ this.push(str);
155
172
  };
156
173
 
157
174
  /**
@@ -164,7 +181,7 @@ var Buffer = function () {
164
181
  };
165
182
 
166
183
  Buffer.prototype._removeLast = function _removeLast(cha) {
167
- if (!this._isLast(cha)) return;
184
+ if (!this.endsWith(cha)) return;
168
185
  this.buf = this.buf.slice(0, -1);
169
186
  this.last = this.buf[this.buf.length - 1];
170
187
  this.position.unshift(cha);
@@ -200,7 +217,7 @@ var Buffer = function () {
200
217
  if (state.printed) {
201
218
  this.dedent();
202
219
  this.newline();
203
- this.push(")");
220
+ this.token(")");
204
221
  }
205
222
  };
206
223
 
@@ -234,7 +251,9 @@ var Buffer = function () {
234
251
 
235
252
  this.removeLast(" ");
236
253
  this._removeSpacesAfterLastNewline();
237
- this._push( /*istanbul ignore next*/(0, _repeat2.default)("\n", i));
254
+ for (var j = 0; j < i; j++) {
255
+ this.push("\n");
256
+ }
238
257
  };
239
258
 
240
259
  /**
@@ -244,8 +263,10 @@ var Buffer = function () {
244
263
  Buffer.prototype._removeSpacesAfterLastNewline = function _removeSpacesAfterLastNewline() {
245
264
  var lastNewlineIndex = this.buf.lastIndexOf("\n");
246
265
  if (lastNewlineIndex >= 0 && this.get().length <= lastNewlineIndex) {
266
+ var toRemove = this.buf.slice(lastNewlineIndex + 1);
247
267
  this.buf = this.buf.substring(0, lastNewlineIndex + 1);
248
268
  this.last = "\n";
269
+ this.position.unshift(toRemove);
249
270
  }
250
271
  };
251
272
 
@@ -269,6 +290,8 @@ var Buffer = function () {
269
290
  */
270
291
 
271
292
  Buffer.prototype.withSource = function withSource(prop, loc, cb) {
293
+ if (!this.opts.sourceMaps) return cb();
294
+
272
295
  // Use the call stack to manage a stack of "source location" data.
273
296
  var originalLine = this._sourcePosition.line;
274
297
  var originalColumn = this._sourcePosition.column;
@@ -287,26 +310,12 @@ var Buffer = function () {
287
310
  * Push a string to the buffer, maintaining indentation and newlines.
288
311
  */
289
312
 
290
- Buffer.prototype.push = function push(str, noIndent) {
291
- if (!this.format.compact && this._indent && !noIndent && str !== "\n") {
292
- // we have an indent level and we aren't pushing a newline
293
- var indent = this.getIndent();
294
-
295
- // replace all newlines with newlines with the indentation
296
- str = str.replace(/\n/g, /*istanbul ignore next*/"\n" + indent);
297
-
313
+ Buffer.prototype.push = function push(str) {
314
+ if (!this.format.compact && this._indent && str[0] !== "\n") {
298
315
  // we've got a newline before us so prepend on the indentation
299
- if (this.isLast("\n")) this._push(indent);
316
+ if (this.endsWith("\n")) str = this.getIndent() + str;
300
317
  }
301
318
 
302
- this._push(str);
303
- };
304
-
305
- /**
306
- * Push a string to the buffer.
307
- */
308
-
309
- Buffer.prototype._push = function _push(str) {
310
319
  // see startTerminatorless() instance method
311
320
  var parenPushNewlineState = this.parenPushNewlineState;
312
321
  if (parenPushNewlineState) {
@@ -320,7 +329,7 @@ var Buffer = function () {
320
329
 
321
330
  if (cha === "\n" || cha === "/") {
322
331
  // we're going to break this terminator expression so we need to add a parentheses
323
- this._push("(");
332
+ str = "(" + str;
324
333
  this.indent();
325
334
  parenPushNewlineState.printed = true;
326
335
  }
@@ -330,12 +339,15 @@ var Buffer = function () {
330
339
  }
331
340
 
332
341
  // If there the line is ending, adding a new mapping marker is redundant
333
- if (str[0] !== "\n") this.map.mark(this._sourcePosition);
342
+ if (this.opts.sourceMaps && str[0] !== "\n") this.map.mark(this._sourcePosition);
334
343
 
335
344
  //
336
345
  this.position.push(str);
337
346
  this.buf += str;
338
347
  this.last = str[str.length - 1];
348
+
349
+ // Clear any state-tracking flags that may have been set.
350
+ this._endsWithWord = false;
339
351
  };
340
352
 
341
353
  /**
@@ -343,6 +355,12 @@ var Buffer = function () {
343
355
  */
344
356
 
345
357
  Buffer.prototype.endsWith = function endsWith(str) {
358
+ var _this = this;
359
+
360
+ if (Array.isArray(str)) return str.some(function (s) {
361
+ return _this.endsWith(s);
362
+ });
363
+
346
364
  if (str.length === 1) {
347
365
  return this.last === str;
348
366
  } else {
@@ -350,27 +368,8 @@ var Buffer = function () {
350
368
  }
351
369
  };
352
370
 
353
- /**
354
- * Test if a character is last in the buffer.
355
- */
356
-
357
- Buffer.prototype.isLast = function isLast(cha) {
358
- if (this.format.compact) return false;
359
- return this._isLast(cha);
360
- };
361
-
362
- Buffer.prototype._isLast = function _isLast(cha) {
363
- var last = this.last;
364
-
365
- if (Array.isArray(cha)) {
366
- return cha.indexOf(last) >= 0;
367
- } else {
368
- return cha === last;
369
- }
370
- };
371
-
372
371
  return Buffer;
373
372
  }();
374
373
 
375
- /*istanbul ignore next*/exports.default = Buffer;
376
- /*istanbul ignore next*/module.exports = exports["default"];
374
+ exports.default = Buffer;
375
+ module.exports = exports["default"];