@danielx/civet 0.5.22 → 0.5.24

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
@@ -8,6 +8,7 @@ Civet
8
8
 
9
9
  The CoffeeScript of TypeScript. Much closer to ES2015+ (for better or worse).
10
10
 
11
+ - [Documentation](https://civet.dev/)
11
12
  - [Online Civet Playground](https://civet-web.vercel.app/)
12
13
  - [Civet VSCode Extension](https://marketplace.visualstudio.com/items?itemName=DanielX.civet)
13
14
  - [Discord Server](https://discord.gg/xkrW9GebBc)
@@ -27,6 +28,8 @@ npm install -g @danielx/civet
27
28
  civet
28
29
  # Compile civet source file to typescript
29
30
  civet < source.civet > output.ts
31
+ # Execute a simple civet script (no imports)
32
+ civet source.civet ...args...
30
33
  # Execute a civet source file in node using ts-node
31
34
  node --loader ts-node/esm --loader @danielx/civet/esm source.civet
32
35
  ```
@@ -64,6 +67,7 @@ Things Kept from CoffeeScript
64
67
  - `is` → `===`
65
68
  - `or`, `or=` → `||`, `||=`
66
69
  - `and`, `and=` → `&&`, `&&=`
70
+ - `a %% b` → `(a % b + b) % b`
67
71
  - `loop` → `while(true)`
68
72
  - `unless exp` → `if(!exp)`
69
73
  - `until condition` → `while(!condition)`
@@ -115,7 +119,6 @@ Civet.
115
119
 
116
120
  - Implicit `var` declarations (use `"civet coffeeCompat"` or `"civet autoVar"`)
117
121
  - `on/yes/off/no` (use `true/false`, `"civet coffeeCompat"`, or `"civet coffeeBooleans"` to add them back)
118
- - `isnt` (use `!==`, `"civet coffeeCompat"`, or `"civet coffeeIsnt"`)
119
122
  - `not` (use `!`, `"civet coffeeCompat"`, or `"civet coffeeNot"`)
120
123
  - `not instanceof` (use `!(a instanceof b)`, `"civet coffeeCompat"`, or `"civet coffeeNot"`)
121
124
  - `not of` use (`"civet coffeeCompat"`, or `"civet coffeeNot"`)
@@ -128,7 +131,6 @@ Civet.
128
131
  - `a of b` (use `a in b` as in JS, or `"civet coffeeCompat"`, or `"civet coffeeOf"`)
129
132
  - Backtick embedded JS (replaced by template literals)
130
133
  - Will add later
131
- - `a %% b` → `(a % b + b) % b`
132
134
  - Conditional assignment `a?[x] = 3` → `a ? a[x] = 3 : undefined`
133
135
  - Multiple slice assignment `otherNumbers[0...] = numbers[3..6] = [-3, -4, -5, -6]`
134
136
 
@@ -137,8 +139,15 @@ Things Changed from CoffeeScript
137
139
 
138
140
  - `==` → `==` rather than `===` (unless you specify `"civet coffeeCompat"` or `"civet coffeeEq"`)
139
141
  - `!=` → `!=` rather than `!==` (unless you specify `"civet coffeeCompat"` or `"civet coffeeEq"`)
142
+ - `is not` → `!==`
143
+ (unless you specify `"civet coffeeCompat"` or `"civet coffeeNot"`),
144
+ instead of `isnt`
145
+ (unless you specify `"civet coffeeCompat"` or `"civet coffeeIsnt"`)
140
146
  - `for in` and `for of` are no longer swapped and become their JS equivalents (unless you specify `"civet coffeeCompat"` or `"civet CoffeeOf"`)
141
- - `a in b` now remains `a in b` rather than becoming `b.indexOf(a) >= 0` (unless you specify `"civet coffeeCompat"` or `"coffeeOf"`)
147
+ - `a is in b` `b.indexOf(a) >= 0` and
148
+ `a is not in b` → `b.indexOf(a) < 0` instead of `a in b` and `a not in b`;
149
+ `a in b` remains `a in b` as in JS, and `a not in b` → `!(a in b)`
150
+ (unless you specify `"civet coffeeCompat"` or `"civet coffeeOf"`)
142
151
  - `x?.y` now compiles to `x?.y` rather than the `if typeof x !== 'undefined' && x !== null` if check
143
152
  - Existential `x?` → `(x != null)` no longer checks for undeclared variables.
144
153
  - `x?()` → `x?.()` instead of `if (typeof x === 'function') { x() }`
@@ -267,8 +276,8 @@ Things Changed from ES6
267
276
  ---
268
277
 
269
278
  - Implicit returns, even for multi-statement functions
270
- (avoid by adding a trailing `;`, an explicit `return`, or
271
- via the directive `"civet -implicitReturns"`)
279
+ (avoid by specifying a `void` return type, adding a trailing `;` or
280
+ explicit `return`, or via the directive `"civet -implicitReturns"`)
272
281
  - Disallow no parens on single argument arrow function. `x => ...` must become `(x) => ...`
273
282
  The reasoning is `x -> ...` => `x(function() ...)` in CoffeeScript and having `->` and `=>`
274
283
  behave more differently than they already do is bad. Passing an anonymous function to an