@danielx/civet 0.4.19-pre.0 → 0.4.19-pre.2

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
@@ -79,6 +79,7 @@ Things Kept from CoffeeScript
79
79
  - `when` inside `switch` automatically breaks
80
80
  - Multiple `,` separated `case`/`when` expressions
81
81
  - `else` -> `default` in `switch`
82
+ - Range literals `[0...10]`, `[a..b]`, `[x - 2 .. x + 2]`
82
83
  - Array slices `list[0...2]` -> `list.slice(0, 2)`
83
84
  - Slice assignment `numbers[3..6] = [-3, -4, -5, -6]` -> `numbers.splice(3, 4, ...[-3, -4, -5, -6])`
84
85
  - Implicit returns
@@ -90,6 +91,10 @@ Things Kept from CoffeeScript
90
91
  Things Removed from CoffeeScript
91
92
  ---
92
93
 
94
+ Most of these can be enabled by adding a [`"civet coffeeCompat"` directive prologue](#coffeescript-compatibility) to the top of your file.
95
+ The goal is to provide a very high level of compatibility with existing CoffeeScript code while offering a fine grained migration path to modern
96
+ Civet.
97
+
93
98
  - Implicit `var` declarations (use `civet coffeeCompat` or `"civet autoVar"`)
94
99
  - `on/yes/off/no` (use `true/false`, `"civet coffeeCompat"`, or `"civet coffeeBooleans"` to add them back)
95
100
  - `isnt` (use `!==`, `"civet coffeeCompat"`, or `"civet coffeeIsnt"`)
@@ -98,7 +103,7 @@ Things Removed from CoffeeScript
98
103
  - `not in`
99
104
  - `not of`
100
105
  - NOTE: CoffeeScript `not` precedence is dubious. `not a < b` should be equivalent to `!(a < b)` but it is in fact `!a < b`
101
- - `do` keyword (replaced with JS `do`, invoke using existing `(-> ...)()` syntax)
106
+ - `do` keyword (replaced with JS `do`, invoke using existing `(-> ...)()` syntax, `"civet coffeeCompat"`, or `"civet coffeeDo"`)
102
107
  - `for from` (use JS `for of`, `"civet coffeeCompat"`, or `"civet coffeeForLoops"`)
103
108
  - `for own of` (use JS `for in` and check manually, switch to `Map#keys/values/entries`, or use `Object.create(null)`, or `"civet coffeeCompat"`, or `"civet coffeeForLoops"`)
104
109
  - `for ... when <condition>` (use `continue if exp` inside loop, `"civet coffeeCompat"`, or `"civet coffeeForLoops"`)
@@ -114,15 +119,14 @@ Things Removed from CoffeeScript
114
119
  - Might add later
115
120
  - Braceless inline objects `x = coolStory: true`
116
121
  - `///` Heregexp
117
- - Ranges `[0...10]`
118
122
  - Rest parameter in any assignment position
119
123
  - Multiple slice assignment `otherNumbers[0...] = numbers[3..6] = [-3, -4, -5, -6]`
120
124
 
121
125
  Things Changed from CoffeeScript
122
126
  ---
123
127
 
124
- - `==` -> `==` rather than `===` (can be kept with `"civet coffeeCompat"`)
125
- - `!=` -> `!=` rather than `!==` (can be kept with `"civet coffeeCompat"`)
128
+ - `==` -> `==` rather than `===` (can be kept with `"civet coffeeCompat"` or `"civet coffeeEq"`)
129
+ - `!=` -> `!=` rather than `!==` (can be kept with `"civet coffeeCompat"` or `"civet coffeeEq"`)
126
130
  - `for in` and `for of` are no longer swapped and become their JS equivalents.
127
131
  - `a...` is now `...a` just like JS
128
132
  - `a in b` is now `a in b` rather than `b.indexOf(a) >= 0`
@@ -193,7 +197,9 @@ Things Added that CoffeeScript didn't
193
197
  - function call `x.map &.callback a, b` -> `x.map($ => $.callback(a, b))`
194
198
  - unary operators `x.map !!&`, -> `x.map($ => !!$)`
195
199
  - binary operators `x.map &+1` -> `x.map($ => $+1)`
196
- - Postfix loop `run() loop` -> `while(true) run()`
200
+ - CoffeeScript improvements
201
+ - Postfix loop `run() loop` -> `while(true) run()`
202
+ - Character range literals `["a".."z"]`, `['f'..'a']`, `['0'..'9']`
197
203
  - Shebang line is kept unmodified in output
198
204
  ```civet
199
205
  #!./node_modules/.bin/ts-node
@@ -224,11 +230,16 @@ CoffeeScript Compatibility
224
230
  Civet provides a compatability prologue directive that aims to be 97+% compatible with existing CoffeeScript2 code (still a work in progress).
225
231
 
226
232
  ```
233
+ autoVar (declare implicit vars based on assignment to undeclared identifiers)
227
234
  coffeeBooleans (yes/no/on/off)
228
235
  coffeeComment (# single line comments)
236
+ coffeeDo ( `do ->`, disables ES6 do/while)
229
237
  coffeeEq (`==` -> `===`, `!=` -> `!==`)
238
+ coffeeForLoops (for in, of, from loops behavie like they do in CoffeeScript 2)
230
239
  coffeeInterpolation (`"a string with {myVar}"`)
231
240
  coffeeIsnt (`isnt` -> `!==`)
241
+ coffeeNot (`not` -> "!") (currently doesn't support `not instanceof`, `not in`, `not of`)
242
+ coffeeOf (`a of b` -> `a in b`)
232
243
  ```
233
244
 
234
245
  You can use these with `"civet coffeeCompat"` to opt in to all or use them bit by bit with `"civet coffeeComment coffeeEq coffeeInterpolation"`.