@danielx/civet 0.4.9 → 0.4.10

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
@@ -91,20 +91,21 @@ Things Kept from CoffeeScript
91
91
  - `@` `this` shorthand `@` -> `this`, `@id` -> `this.id`
92
92
  - Prototype shorthand `X::` -> `X.prototype`, `X::a` -> `X.prototype.a`
93
93
  - Class static shorthand `@`
94
+ - Chained comparisons `a < b < c` -> `a < b && b < c`
94
95
  - Postfix `if/unless`
95
96
  - Block Strings `"""` / `'''`
96
97
  - `#{exp}` interpolation in `"""` strings
98
+ - `when` inside `switch` automatically breaks
97
99
  - Multiple `,` separated `case`/`when` expressions
98
100
  - `else` -> `default` in `switch`
99
101
  - Implicit returns
102
+ - Simplified number method calls `1.toFixed()` -> `1..toFixed()`
100
103
  - JSX 😿
101
- - TODO
102
- - [ ] Chained comparisons
103
104
 
104
105
  Things Removed from CoffeeScript
105
106
  ---
106
107
 
107
- - `on/yes/off/no` (use `true/false`)
108
+ - `on/yes/off/no` (use `true/false`, `"civet coffeeCompat"`)
108
109
  - `isnt` (use `!==`)
109
110
  - `not` (use `!`)
110
111
  - `do` keyword (replaced with JS `do`, invoke using existing `(-> ...)()` syntax)
@@ -125,8 +126,8 @@ Things Removed from CoffeeScript
125
126
  Things Changed from CoffeeScript
126
127
  ---
127
128
 
128
- - `==` -> `==` rather than `===` (can be kept with `"use coffee-compat"`)
129
- - `!=` -> `!=` rather than `!==` (can be kept with `"use coffee-compat"`)
129
+ - `==` -> `==` rather than `===` (can be kept with `"civet coffeeCompat"`)
130
+ - `!=` -> `!=` rather than `!==` (can be kept with `"civet coffeeCompat"`)
130
131
  - `for in` and `for of` are no longer swapped and become their JS equivalents.
131
132
  - `a...` is now `...a` just like JS
132
133
  - `x?.y` now compiles to `x?.y` rather than the `if typeof x !== 'undefined' && x !== null` if check
@@ -134,7 +135,8 @@ Things Changed from CoffeeScript
134
135
  - Embedded JS `\`\`` has been replaced with JS template literals.
135
136
  - No longer allowing multiple postfix `if/unless` on the same line.
136
137
  - No `else` block on `unless` (negate condition and use `if`)
137
- - `#{}` interpolation in `""` strings only when `"use coffee-compat"`
138
+ - `#{}` interpolation in `""` strings only when `"civet coffeeCompat"`
139
+ - Expanded chained comparisons to work on more operators `a in b instanceof C` -> `a in b && b instanceof C`
138
140
  - Civet tries to keep the transpiled output verbatim as much as possible.
139
141
  In Coffee `(x)` -> `x;` but in Civet `(x)` -> `(x);`.
140
142
  Also in Coffee
@@ -202,6 +204,24 @@ Things Changed from ES6
202
204
  application without parens is also convenient.
203
205
  - Disallow comma operator in conditionals.
204
206
  - Comma operator in case/when becomes multiple conditions.
207
+ - When exponent follows a dot it is treated as a property access since we simplified `1.toString()` -> `1..toString()` and an exponent
208
+ 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`.
209
+
210
+ CoffeeScript Compatibility
211
+ ---
212
+
213
+ Civet provides a compatability prologue directive that aims to be 97+% compatible with existing CoffeeScript2 code (still a work in progress).
214
+
215
+ ```
216
+ coffeeBooleans (yes/no/on/off)
217
+ coffeeComment (# single line comments)
218
+ coffeeEq (`==` -> `===`, `!=` -> `!==`)
219
+ coffeeInterpolation (`"a string with {myVar}"`)
220
+ ```
221
+
222
+ You can use these with `"civet coffeeCompat"` to opt in to all or use them bit by bit with `"civet coffeeComment coffeeEq coffeeInterpolation"`.
223
+ Another posibility is to slowly remove them to provide a way to migrate files a little at a time `"civet coffeeCompat -coffeeBooleans -coffeeComment -coffeeEq"`.
224
+ Both camel case and hyphens work when specifying options `"civet coffee-compat"`. More options will be added over time until 97+% compatibility is achieved.
205
225
 
206
226
  Using Civet in your Node.js Environment
207
227
  ---