@danielx/civet 0.4.15 → 0.4.17

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
@@ -99,33 +99,39 @@ Things Kept from CoffeeScript
99
99
  - Multiple `,` separated `case`/`when` expressions
100
100
  - `else` -> `default` in `switch`
101
101
  - Array slices `list[0...2]` -> `list.slice(0, 2)`
102
+ - Slice assignment `numbers[3..6] = [-3, -4, -5, -6]` -> `numbers.splice(3, 4, ...[-3, -4, -5, -6])`
102
103
  - Implicit returns
103
104
  - Simplified number method calls `1.toFixed()` -> `1..toFixed()`
105
+ - `if`/`switch` expressions
106
+ - Destructuring object assignment doesn't require being wrapped in parens at the statement level `{a, b} = c` -> `({a, b} = c)`
104
107
  - JSX 😿
105
108
 
106
109
  Things Removed from CoffeeScript
107
110
  ---
108
111
 
109
- - `on/yes/off/no` (use `true/false`, or `"civet coffeeCompat"` to add them back)
110
- - `isnt` (use `!==`)
111
- - `not` (use `!`)
112
+ - Implicit `var` declarations (use `civet coffeeCompat` or `"civet autoVar"`)
113
+ - `on/yes/off/no` (use `true/false`, `"civet coffeeCompat"`, or `"civet coffeeBooleans"` to add them back)
114
+ - `isnt` (use `!==`, `"civet coffeeCompat"`, or `"civet coffeeIsnt"`)
115
+ - `not` (use `!`, `"civet coffeeCompat"`, or `"civet coffeeNot"`)
116
+ - `not instanceof` (use `!(a instanceof b)`)
117
+ - `not in`
118
+ - `not of`
112
119
  - `do` keyword (replaced with JS `do`, invoke using existing `(-> ...)()` syntax)
113
120
  - `for from` (use JS `for of`)
121
+ - `for own of` (use JS `for in` and check manually, switch to `Map#keys/values/entries`, or use `Object.create(null)`)
114
122
  - `and=`, `or=` (don't mix and match words and symbols)
115
123
  - `a ? b` (use `a ?? b`, though it doesn't check for undeclared variables)
116
124
  - Iteration expression results
117
125
  - Backtick embedded JS (replaced by template literals)
118
126
  - Will likely add later
119
- - `switch` expressions
120
- - `if` expressions
121
- - Implicit `var` declarations (in compat mode only)
127
+ - Optional assignment `x?.y = 3` -> `x != null ? x.y = 3 : undefined`
122
128
  - Might add later
123
129
  - Braceless inline objects `x = coolStory: true`
124
130
  - Comprensions
125
131
  - `///` Heregexp
126
- - Slice assignment `numbers[3..6] = [-3, -4, -5, -6]` (use `numbers.splice(3, 4, -3, -4, -5, -6)`)
127
132
  - Ranges `[0...10]`
128
133
  - Rest parameter in any assignment position
134
+ - Multiple slice assignment `otherNumbers[0...] = numbers[3..6] = [-3, -4, -5, -6]`
129
135
 
130
136
  Things Changed from CoffeeScript
131
137
  ---
@@ -139,7 +145,6 @@ Things Changed from CoffeeScript
139
145
  - `x?()` -> `x?.()` instead of `if (typeof x === 'function') { x() }`
140
146
  - Backtick embedded JS has been replaced with JS template literals.
141
147
  - No longer allowing multiple postfix `if/unless` on the same line (use `&&` or `and` to combine conditions).
142
- - No `else` block on `unless` (negate condition and use `if`)
143
148
  - `#{}` interpolation in `""` strings only when `"civet coffeeCompat"` or `"civet coffeeInterpolation"`
144
149
  - Expanded chained comparisons to work on more operators `a in b instanceof C` -> `a in b && b instanceof C`
145
150
  - Postfix iteration/conditionals always wrap the statement [#5431](https://github.com/jashkenas/coffeescript/issues/5431)
@@ -190,12 +195,12 @@ Things Added that CoffeeScript didn't
190
195
  - Private identifiers `#id`
191
196
  - Convenience for ES6+ Features
192
197
  - Const assignment shorthand `a := b` -> `const a = b`; `{a, b} := c` -> `const {a, b} = c`
193
- - `<` as `extends` shorthand
194
198
  - `@#id` -> `this.#id` shorthand for private identifiers
195
199
  - `import` shorthand `x from ./x` -> `import x from "./x"`
196
- - `\`\`\`` Block Template Strings remove leading indentation for clarity
200
+ - Triple backtick Template Strings remove leading indentation for clarity
197
201
  - Class constructor shorthand `@( ... )`
198
202
  - ClassStaticBlock `@ { ... }`
203
+ - `<` as `extends` shorthand
199
204
  - Postfix loop `run() loop` -> `while(true) run()`
200
205
  - Shebang line is kept unmodified in output
201
206
  ```civet
@@ -212,12 +217,13 @@ Things Changed from ES6
212
217
  behave more differently than they already do is bad. Passing an anonymous function to an
213
218
  application without parens is also convenient.
214
219
  - `for(i of x) ...` defaults to const declaration -> `for(const i of x) ...`
215
- - Disallow comma operator in conditionals. `if x, y`
216
- - Comma operator in case/when becomes multiple conditions.
220
+ - Disallow comma operator in conditionals and many other places. `if x, y` is not allowed.
221
+ - Comma operator in `case`/`when` instead becomes multiple conditions.
217
222
  - 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
223
  of numbers with `1..toString()` use `1.toString()` instead. When exponent follows a dot it is treated as a property access since an exponent
219
224
  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
225
  - Additional reserved words `and`, `or`, `loop`, `until`, `unless`
226
+ - No whitespace between unary operators and operands. Mandatory whitespace between condition and ternary `?` ex. `x ? a : b` since `x?` is the unary existential operator.
221
227
 
222
228
  CoffeeScript Compatibility
223
229
  ---
@@ -229,6 +235,7 @@ coffeeBooleans (yes/no/on/off)
229
235
  coffeeComment (# single line comments)
230
236
  coffeeEq (`==` -> `===`, `!=` -> `!==`)
231
237
  coffeeInterpolation (`"a string with {myVar}"`)
238
+ coffeeIsnt (`isnt` -> `!==`)
232
239
  ```
233
240
 
234
241
  You can use these with `"civet coffeeCompat"` to opt in to all or use them bit by bit with `"civet coffeeComment coffeeEq coffeeInterpolation"`.