@danielx/civet 0.4.14 → 0.4.16

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 CHANGED
@@ -41,10 +41,10 @@ fileCache : Record<string, any> := {}
41
41
 
42
42
  createCompilerHost := (options: CompilerOptions, moduleSearchLocations : string[]) ->
43
43
  fileExists := (fileName: string) : boolean ->
44
- return fileCache[fileName]?
44
+ fileCache[fileName]?
45
45
 
46
46
  readFile := (fileName: string) ->
47
- return fileCache[fileName]
47
+ fileCache[fileName]
48
48
  ```
49
49
 
50
50
  ESBuild Plugin
@@ -98,6 +98,8 @@ Things Kept from CoffeeScript
98
98
  - `when` inside `switch` automatically breaks
99
99
  - Multiple `,` separated `case`/`when` expressions
100
100
  - `else` -> `default` in `switch`
101
+ - Array slices `list[0...2]` -> `list.slice(0, 2)`
102
+ - Slice assignment `numbers[3..6] = [-3, -4, -5, -6]`
101
103
  - Implicit returns
102
104
  - Simplified number method calls `1.toFixed()` -> `1..toFixed()`
103
105
  - JSX 😿
@@ -105,7 +107,7 @@ Things Kept from CoffeeScript
105
107
  Things Removed from CoffeeScript
106
108
  ---
107
109
 
108
- - `on/yes/off/no` (use `true/false`, `"civet coffeeCompat"`)
110
+ - `on/yes/off/no` (use `true/false`, or `"civet coffeeCompat"` to add them back)
109
111
  - `isnt` (use `!==`)
110
112
  - `not` (use `!`)
111
113
  - `do` keyword (replaced with JS `do`, invoke using existing `(-> ...)()` syntax)
@@ -115,16 +117,17 @@ Things Removed from CoffeeScript
115
117
  - Iteration expression results
116
118
  - Backtick embedded JS (replaced by template literals)
117
119
  - Will likely add later
120
+ - Optional assignment `x?.y = 3` -> `x != null ? x.y = 3 : undefined`
118
121
  - `switch` expressions
119
122
  - `if` expressions
120
- - Implicit declarations (in compat mode only)
123
+ - Implicit `var` declarations (in compat mode only)
121
124
  - Might add later
125
+ - Braceless inline objects `x = coolStory: true`
122
126
  - Comprensions
123
- - Array slices `list[0...2]` (use `list.slice(0, 2)`)
124
127
  - `///` Heregexp
125
- - Slice assignment `numbers[3..6] = [-3, -4, -5, -6]` (use `numbers.splice(3, 4, -3, -4, -5, -6)`)
126
128
  - Ranges `[0...10]`
127
129
  - Rest parameter in any assignment position
130
+ - Multiple slice assignment `otherNumbers[0...] = numbers[3..6] = [-3, -4, -5, -6]`
128
131
 
129
132
  Things Changed from CoffeeScript
130
133
  ---
@@ -141,6 +144,8 @@ Things Changed from CoffeeScript
141
144
  - No `else` block on `unless` (negate condition and use `if`)
142
145
  - `#{}` interpolation in `""` strings only when `"civet coffeeCompat"` or `"civet coffeeInterpolation"`
143
146
  - Expanded chained comparisons to work on more operators `a in b instanceof C` -> `a in b && b instanceof C`
147
+ - Postfix iteration/conditionals always wrap the statement [#5431](https://github.com/jashkenas/coffeescript/issues/5431)
148
+ `try x() if y` -> `if (y) try x()`
144
149
  - Civet tries to keep the transpiled output verbatim as much as possible.
145
150
  In Coffee `(x)` -> `x;` but in Civet `(x)` -> `(x);`.
146
151
  Also in Coffee
@@ -211,7 +216,8 @@ Things Changed from ES6
211
216
  - `for(i of x) ...` defaults to const declaration -> `for(const i of x) ...`
212
217
  - Disallow comma operator in conditionals. `if x, y`
213
218
  - Comma operator in case/when becomes multiple conditions.
214
- - When exponent follows a dot it is treated as a property access since we simplified `1.toString()` -> `1..toString()` and an exponent
219
+ - Numbers can't end with a dot (otherwise would be ambiguous with CoffeeScript slices `y[0..x]`). This also implies that you can't access properties
220
+ of numbers with `1..toString()` use `1.toString()` instead. When exponent follows a dot it is treated as a property access since an exponent
215
221
  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
222
  - Additional reserved words `and`, `or`, `loop`, `until`, `unless`
217
223