@danielx/civet 0.4.16 → 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,28 +99,32 @@ 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]`
102
+ - Slice assignment `numbers[3..6] = [-3, -4, -5, -6]` -> `numbers.splice(3, 4, ...[-3, -4, -5, -6])`
103
103
  - Implicit returns
104
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)`
105
107
  - JSX 😿
106
108
 
107
109
  Things Removed from CoffeeScript
108
110
  ---
109
111
 
110
- - `on/yes/off/no` (use `true/false`, or `"civet coffeeCompat"` to add them back)
111
- - `isnt` (use `!==`)
112
- - `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`
113
119
  - `do` keyword (replaced with JS `do`, invoke using existing `(-> ...)()` syntax)
114
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)`)
115
122
  - `and=`, `or=` (don't mix and match words and symbols)
116
123
  - `a ? b` (use `a ?? b`, though it doesn't check for undeclared variables)
117
124
  - Iteration expression results
118
125
  - Backtick embedded JS (replaced by template literals)
119
126
  - Will likely add later
120
127
  - Optional assignment `x?.y = 3` -> `x != null ? x.y = 3 : undefined`
121
- - `switch` expressions
122
- - `if` expressions
123
- - Implicit `var` declarations (in compat mode only)
124
128
  - Might add later
125
129
  - Braceless inline objects `x = coolStory: true`
126
130
  - Comprensions
@@ -141,7 +145,6 @@ Things Changed from CoffeeScript
141
145
  - `x?()` -> `x?.()` instead of `if (typeof x === 'function') { x() }`
142
146
  - Backtick embedded JS has been replaced with JS template literals.
143
147
  - No longer allowing multiple postfix `if/unless` on the same line (use `&&` or `and` to combine conditions).
144
- - No `else` block on `unless` (negate condition and use `if`)
145
148
  - `#{}` interpolation in `""` strings only when `"civet coffeeCompat"` or `"civet coffeeInterpolation"`
146
149
  - Expanded chained comparisons to work on more operators `a in b instanceof C` -> `a in b && b instanceof C`
147
150
  - Postfix iteration/conditionals always wrap the statement [#5431](https://github.com/jashkenas/coffeescript/issues/5431)
@@ -192,12 +195,12 @@ Things Added that CoffeeScript didn't
192
195
  - Private identifiers `#id`
193
196
  - Convenience for ES6+ Features
194
197
  - Const assignment shorthand `a := b` -> `const a = b`; `{a, b} := c` -> `const {a, b} = c`
195
- - `<` as `extends` shorthand
196
198
  - `@#id` -> `this.#id` shorthand for private identifiers
197
199
  - `import` shorthand `x from ./x` -> `import x from "./x"`
198
- - `\`\`\`` Block Template Strings remove leading indentation for clarity
200
+ - Triple backtick Template Strings remove leading indentation for clarity
199
201
  - Class constructor shorthand `@( ... )`
200
202
  - ClassStaticBlock `@ { ... }`
203
+ - `<` as `extends` shorthand
201
204
  - Postfix loop `run() loop` -> `while(true) run()`
202
205
  - Shebang line is kept unmodified in output
203
206
  ```civet
@@ -214,12 +217,13 @@ Things Changed from ES6
214
217
  behave more differently than they already do is bad. Passing an anonymous function to an
215
218
  application without parens is also convenient.
216
219
  - `for(i of x) ...` defaults to const declaration -> `for(const i of x) ...`
217
- - Disallow comma operator in conditionals. `if x, y`
218
- - 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.
219
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
220
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
221
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`.
222
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.
223
227
 
224
228
  CoffeeScript Compatibility
225
229
  ---
@@ -231,6 +235,7 @@ coffeeBooleans (yes/no/on/off)
231
235
  coffeeComment (# single line comments)
232
236
  coffeeEq (`==` -> `===`, `!=` -> `!==`)
233
237
  coffeeInterpolation (`"a string with {myVar}"`)
238
+ coffeeIsnt (`isnt` -> `!==`)
234
239
  ```
235
240
 
236
241
  You can use these with `"civet coffeeCompat"` to opt in to all or use them bit by bit with `"civet coffeeComment coffeeEq coffeeInterpolation"`.