@danielx/civet 0.4.12 → 0.4.14
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.
- package/README.md +18 -10
- package/dist/browser.js +648 -493
- package/dist/esbuild-plugin.js +7 -1
- package/dist/esm.mjs +2 -2
- package/dist/main.js +648 -493
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -92,7 +92,7 @@ Things Kept from CoffeeScript
|
|
|
92
92
|
- Prototype shorthand `X::` -> `X.prototype`, `X::a` -> `X.prototype.a`
|
|
93
93
|
- Class static shorthand `@`
|
|
94
94
|
- Chained comparisons `a < b < c` -> `a < b && b < c`
|
|
95
|
-
- Postfix `if/unless`
|
|
95
|
+
- Postfix `if/unless/while/until/for`
|
|
96
96
|
- Block Strings `"""` / `'''`
|
|
97
97
|
- `#{exp}` interpolation in `"""` strings
|
|
98
98
|
- `when` inside `switch` automatically breaks
|
|
@@ -111,14 +111,17 @@ Things Removed from CoffeeScript
|
|
|
111
111
|
- `do` keyword (replaced with JS `do`, invoke using existing `(-> ...)()` syntax)
|
|
112
112
|
- `for from` (use JS `for of`)
|
|
113
113
|
- `and=`, `or=` (don't mix and match words and symbols)
|
|
114
|
+
- `a ? b` (use `a ?? b`, though it doesn't check for undeclared variables)
|
|
114
115
|
- Iteration expression results
|
|
115
|
-
-
|
|
116
|
-
-
|
|
117
|
-
-
|
|
118
|
-
-
|
|
116
|
+
- Backtick embedded JS (replaced by template literals)
|
|
117
|
+
- Will likely add later
|
|
118
|
+
- `switch` expressions
|
|
119
|
+
- `if` expressions
|
|
120
|
+
- Implicit declarations (in compat mode only)
|
|
119
121
|
- Might add later
|
|
120
|
-
- Comprensions
|
|
122
|
+
- Comprensions
|
|
121
123
|
- Array slices `list[0...2]` (use `list.slice(0, 2)`)
|
|
124
|
+
- `///` Heregexp
|
|
122
125
|
- Slice assignment `numbers[3..6] = [-3, -4, -5, -6]` (use `numbers.splice(3, 4, -3, -4, -5, -6)`)
|
|
123
126
|
- Ranges `[0...10]`
|
|
124
127
|
- Rest parameter in any assignment position
|
|
@@ -132,10 +135,11 @@ Things Changed from CoffeeScript
|
|
|
132
135
|
- `a...` is now `...a` just like JS
|
|
133
136
|
- `x?.y` now compiles to `x?.y` rather than the `if typeof x !== 'undefined' && x !== null` if check
|
|
134
137
|
- Existential `x?` -> `(x != null)` no longer checks for undeclared variables.
|
|
135
|
-
-
|
|
136
|
-
-
|
|
138
|
+
- `x?()` -> `x?.()` instead of `if (typeof x === 'function') { x() }`
|
|
139
|
+
- Backtick embedded JS has been replaced with JS template literals.
|
|
140
|
+
- No longer allowing multiple postfix `if/unless` on the same line (use `&&` or `and` to combine conditions).
|
|
137
141
|
- No `else` block on `unless` (negate condition and use `if`)
|
|
138
|
-
- `#{}` interpolation in `""` strings only when `"civet coffeeCompat"`
|
|
142
|
+
- `#{}` interpolation in `""` strings only when `"civet coffeeCompat"` or `"civet coffeeInterpolation"`
|
|
139
143
|
- Expanded chained comparisons to work on more operators `a in b instanceof C` -> `a in b && b instanceof C`
|
|
140
144
|
- Civet tries to keep the transpiled output verbatim as much as possible.
|
|
141
145
|
In Coffee `(x)` -> `x;` but in Civet `(x)` -> `(x);`.
|
|
@@ -189,6 +193,7 @@ Things Added that CoffeeScript didn't
|
|
|
189
193
|
- `\`\`\`` Block Template Strings remove leading indentation for clarity
|
|
190
194
|
- Class constructor shorthand `@( ... )`
|
|
191
195
|
- ClassStaticBlock `@ { ... }`
|
|
196
|
+
- Postfix loop `run() loop` -> `while(true) run()`
|
|
192
197
|
- Shebang line is kept unmodified in output
|
|
193
198
|
```civet
|
|
194
199
|
#!./node_modules/.bin/ts-node
|
|
@@ -198,14 +203,17 @@ Things Added that CoffeeScript didn't
|
|
|
198
203
|
Things Changed from ES6
|
|
199
204
|
---
|
|
200
205
|
|
|
206
|
+
- Implicit returns
|
|
201
207
|
- Disallow no parens on single argument arrow function. `x => ...` must become `(x) => ...`
|
|
202
208
|
The reasoning is `x -> ...` => `x(function() ...)` in CoffeeScript and having `->` and `=>`
|
|
203
209
|
behave more differently than they already do is bad. Passing an anonymous function to an
|
|
204
210
|
application without parens is also convenient.
|
|
205
|
-
-
|
|
211
|
+
- `for(i of x) ...` defaults to const declaration -> `for(const i of x) ...`
|
|
212
|
+
- Disallow comma operator in conditionals. `if x, y`
|
|
206
213
|
- Comma operator in case/when becomes multiple conditions.
|
|
207
214
|
- When exponent follows a dot it is treated as a property access since we simplified `1.toString()` -> `1..toString()` and an exponent
|
|
208
215
|
could be a valid property `1.e10` -> `1..e10`. The workaround is to add a trailing zero `1.0e10` or remove the dot before the exponent `1e10`.
|
|
216
|
+
- Additional reserved words `and`, `or`, `loop`, `until`, `unless`
|
|
209
217
|
|
|
210
218
|
CoffeeScript Compatibility
|
|
211
219
|
---
|