@danielx/civet 0.4.19-pre.9 → 0.4.21

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2022 Daniel X Moore and other contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -53,6 +53,8 @@ Things Kept from CoffeeScript
53
53
  - `is` -> `===`
54
54
  - `or` -> `||`
55
55
  - `and` -> `&&`
56
+ - `or=` -> `||=`
57
+ - `and=` -> `&&=`
56
58
  - `loop` -> `while(true)`
57
59
  - `unless exp` -> `if(!exp)`
58
60
  - `until condition` -> `while(!condition)`
@@ -88,6 +90,11 @@ Things Kept from CoffeeScript
88
90
  - Simplified number method calls `1.toFixed()` -> `1..toFixed()`
89
91
  - `if`/`switch`/`for`/`loop`/`while`/`throw` expressions
90
92
  - Destructuring object assignment doesn't require being wrapped in parens at the statement level `{a, b} = c` -> `({a, b} = c)`
93
+ - Prefix or postfix rest/splats `[...a]`, `x = [a...]`
94
+ - RestProperty in any position `{a, ...b, c} = d` -> `{a, c, ...b} = d`
95
+ - RestElement/RestParameter in any position `(first, ...midle, last) ->` -> `function(first, ...middle) { let [last] = middle.splice(-1)}`
96
+ - `///` Heregexp
97
+ - With some [changes](#things-changed-from-coffeescript).
91
98
  - JSX 😿
92
99
 
93
100
  Things Removed from CoffeeScript
@@ -108,7 +115,6 @@ Civet.
108
115
  - `for from` (use JS `for of`, `"civet coffeeCompat"`, or `"civet coffeeForLoops"`)
109
116
  - `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"`)
110
117
  - `for ... when <condition>` (use `continue if exp` inside loop, `"civet coffeeCompat"`, or `"civet coffeeForLoops"`)
111
- - `and=`, `or=` (don't mix and match words and symbols)
112
118
  - `a ? b` (use `a ?? b`, though it doesn't check for undeclared variables, `"civet coffeeCompat"`, or `"civet coffeeBinaryExistential"` enables this at the cost of losing JS ternary operator)
113
119
  - `a of b` (use `a in b` matching JS, or `"civet coffeeCompat"`, or `"civet coffeeOf"`)
114
120
  - Iteration expression results
@@ -117,7 +123,6 @@ Civet.
117
123
  - Optional assignment `x?.y = 3` -> `x != null ? x.y = 3 : undefined`
118
124
  - Conditional assignment `a?[x] = 3` -> `a ? a[x] = 3 : undefined`
119
125
  - Might add later
120
- - `///` Heregexp
121
126
  - Rest parameter in any assignment position
122
127
  - Multiple slice assignment `otherNumbers[0...] = numbers[3..6] = [-3, -4, -5, -6]`
123
128
 
@@ -127,7 +132,6 @@ Things Changed from CoffeeScript
127
132
  - `==` -> `==` rather than `===` (can be kept with `"civet coffeeCompat"` or `"civet coffeeEq"`)
128
133
  - `!=` -> `!=` rather than `!==` (can be kept with `"civet coffeeCompat"` or `"civet coffeeEq"`)
129
134
  - `for in` and `for of` are no longer swapped and become their JS equivalents.
130
- - `a...` is now `...a` just like JS
131
135
  - `a in b` is now `a in b` rather than `b.indexOf(a) >= 0`
132
136
  - `x?.y` now compiles to `x?.y` rather than the `if typeof x !== 'undefined' && x !== null` if check
133
137
  - Existential `x?` -> `(x != null)` no longer checks for undeclared variables.
@@ -150,6 +154,15 @@ Things Changed from CoffeeScript
150
154
  x + 3
151
155
  ```
152
156
  remains as is.
157
+ - Heregex
158
+ - Allows both kinds of substitutions `#{..}`, `${..}`.
159
+ - Also allows both kinds of single line comments `//`, `#`.
160
+ - Keeps non-newline whitespace inside of character classes.
161
+ - Doesn't require escaping `#` after space inside of character classes.
162
+ - `#` is always the start of a comment outside of character classes regardless of leading space (CoffeeScript treats
163
+ `\s+#` as comment starts inside and outside of character classes).
164
+ - Might later add a compat flag to get more CoffeeScript compatibility.
165
+ - Might also later add a compat flag to only use ES interpolations and comments inside Heregexes.
153
166
 
154
167
  Things Added that CoffeeScript didn't
155
168
  ---
@@ -228,21 +241,22 @@ CoffeeScript Compatibility
228
241
 
229
242
  Civet provides a compatability prologue directive that aims to be 97+% compatible with existing CoffeeScript2 code (still a work in progress).
230
243
 
231
- ```
232
- autoVar (declare implicit vars based on assignment to undeclared identifiers)
233
- coffeeBooleans (yes/no/on/off)
234
- coffeeComment (# single line comments)
235
- coffeeDo ( `do ->`, disables ES6 do/while)
236
- coffeeEq (`==` -> `===`, `!=` -> `!==`)
237
- coffeeForLoops (for in, of, from loops behave like they do in CoffeeScript)
238
- coffeeInterpolation (`"a string with #{myVar}"`)
239
- coffeeIsnt (`isnt` -> `!==`)
240
- coffeeNot (`not` -> "!") (currently doesn't support `not instanceof`, `not of`)
241
- coffeeOf (`a of b` -> `a in b`, `a in b` -> `b.indexOf(a) >= 0`, `a not in b` -> `b.indexOf(a) < 0`)
242
- ```
244
+ | Configuration | What it enables |
245
+ |---------------------|---------------------------------------------------------------------|
246
+ | autoVar | declare implicit vars based on assignment to undeclared identifiers |
247
+ | coffeeBooleans | `yes`, `no`, `on`, `off` |
248
+ | coffeeComment | `# single line comments` |
249
+ | coffeeDo | `do ->`, disables ES6 do/while |
250
+ | coffeeEq | `==` -> `===`, `!=` -> `!==` |
251
+ | coffeeForLoops | for in, of, from loops behave like they do in CoffeeScript |
252
+ | coffeeInterpolation | `"a string with #{myVar}"` |
253
+ | coffeeIsnt | `isnt` -> `!==` |
254
+ | coffeeNot | `not` -> `!`, `a not instanceof b` -> `!(a instanceof b)`; `not of` is not yet supported |
255
+ | coffeeOf | `a of b` -> `a in b`, `a in b` -> `b.indexOf(a) >= 0`, `a not in b` -> `b.indexOf(a) < 0` |
256
+
243
257
 
244
258
  You can use these with `"civet coffeeCompat"` to opt in to all or use them bit by bit with `"civet coffeeComment coffeeEq coffeeInterpolation"`.
245
- Another posibility is to slowly remove them to provide a way to migrate files a little at a time `"civet coffeeCompat -coffeeBooleans -coffeeComment -coffeeEq"`.
259
+ Another possibility is to slowly remove them to provide a way to migrate files a little at a time `"civet coffeeCompat -coffeeBooleans -coffeeComment -coffeeEq"`.
246
260
  Both camel case and hyphens work when specifying options `"civet coffee-compat"`. More options will be added over time until 97+% compatibility is achieved.
247
261
 
248
262
  Using Civet in your Node.js Environment