@danielx/civet 0.4.13 → 0.4.15

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
@@ -92,12 +92,13 @@ 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
99
99
  - Multiple `,` separated `case`/`when` expressions
100
100
  - `else` -> `default` in `switch`
101
+ - Array slices `list[0...2]` -> `list.slice(0, 2)`
101
102
  - Implicit returns
102
103
  - Simplified number method calls `1.toFixed()` -> `1..toFixed()`
103
104
  - JSX 😿
@@ -105,20 +106,23 @@ Things Kept from CoffeeScript
105
106
  Things Removed from CoffeeScript
106
107
  ---
107
108
 
108
- - `on/yes/off/no` (use `true/false`, `"civet coffeeCompat"`)
109
+ - `on/yes/off/no` (use `true/false`, or `"civet coffeeCompat"` to add them back)
109
110
  - `isnt` (use `!==`)
110
111
  - `not` (use `!`)
111
112
  - `do` keyword (replaced with JS `do`, invoke using existing `(-> ...)()` syntax)
112
113
  - `for from` (use JS `for of`)
113
114
  - `and=`, `or=` (don't mix and match words and symbols)
115
+ - `a ? b` (use `a ?? b`, though it doesn't check for undeclared variables)
114
116
  - Iteration expression results
115
- - Implicit declarations
116
- - Postfix `while/until`
117
- - `///` Heregexp
118
- - Backtick Embedded JS (replaced by template literals)
117
+ - Backtick embedded JS (replaced by template literals)
118
+ - Will likely add later
119
+ - `switch` expressions
120
+ - `if` expressions
121
+ - Implicit `var` declarations (in compat mode only)
119
122
  - Might add later
120
- - Comprensions (a case could be made for keeping them)
121
- - Array slices `list[0...2]` (use `list.slice(0, 2)`)
123
+ - Braceless inline objects `x = coolStory: true`
124
+ - Comprensions
125
+ - `///` Heregexp
122
126
  - Slice assignment `numbers[3..6] = [-3, -4, -5, -6]` (use `numbers.splice(3, 4, -3, -4, -5, -6)`)
123
127
  - Ranges `[0...10]`
124
128
  - Rest parameter in any assignment position
@@ -132,11 +136,14 @@ Things Changed from CoffeeScript
132
136
  - `a...` is now `...a` just like JS
133
137
  - `x?.y` now compiles to `x?.y` rather than the `if typeof x !== 'undefined' && x !== null` if check
134
138
  - Existential `x?` -> `(x != null)` no longer checks for undeclared variables.
135
- - Embedded JS `\`\`` has been replaced with JS template literals.
136
- - No longer allowing multiple postfix `if/unless` on the same line.
139
+ - `x?()` -> `x?.()` instead of `if (typeof x === 'function') { x() }`
140
+ - Backtick embedded JS has been replaced with JS template literals.
141
+ - No longer allowing multiple postfix `if/unless` on the same line (use `&&` or `and` to combine conditions).
137
142
  - No `else` block on `unless` (negate condition and use `if`)
138
- - `#{}` interpolation in `""` strings only when `"civet coffeeCompat"`
143
+ - `#{}` interpolation in `""` strings only when `"civet coffeeCompat"` or `"civet coffeeInterpolation"`
139
144
  - Expanded chained comparisons to work on more operators `a in b instanceof C` -> `a in b && b instanceof C`
145
+ - Postfix iteration/conditionals always wrap the statement [#5431](https://github.com/jashkenas/coffeescript/issues/5431)
146
+ `try x() if y` -> `if (y) try x()`
140
147
  - Civet tries to keep the transpiled output verbatim as much as possible.
141
148
  In Coffee `(x)` -> `x;` but in Civet `(x)` -> `(x);`.
142
149
  Also in Coffee
@@ -189,6 +196,7 @@ Things Added that CoffeeScript didn't
189
196
  - `\`\`\`` Block Template Strings remove leading indentation for clarity
190
197
  - Class constructor shorthand `@( ... )`
191
198
  - ClassStaticBlock `@ { ... }`
199
+ - Postfix loop `run() loop` -> `while(true) run()`
192
200
  - Shebang line is kept unmodified in output
193
201
  ```civet
194
202
  #!./node_modules/.bin/ts-node
@@ -204,10 +212,12 @@ Things Changed from ES6
204
212
  behave more differently than they already do is bad. Passing an anonymous function to an
205
213
  application without parens is also convenient.
206
214
  - `for(i of x) ...` defaults to const declaration -> `for(const i of x) ...`
207
- - Disallow comma operator in conditionals.
215
+ - Disallow comma operator in conditionals. `if x, y`
208
216
  - Comma operator in case/when becomes multiple conditions.
209
- - When exponent follows a dot it is treated as a property access since we simplified `1.toString()` -> `1..toString()` and an exponent
217
+ - 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
218
+ of numbers with `1..toString()` use `1.toString()` instead. When exponent follows a dot it is treated as a property access since an exponent
210
219
  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`.
220
+ - Additional reserved words `and`, `or`, `loop`, `until`, `unless`
211
221
 
212
222
  CoffeeScript Compatibility
213
223
  ---