@danielx/civet 0.4.17 → 0.4.19-pre.0

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
@@ -47,25 +47,6 @@ createCompilerHost := (options: CompilerOptions, moduleSearchLocations : string[
47
47
  fileCache[fileName]
48
48
  ```
49
49
 
50
- ESBuild Plugin
51
- ---
52
-
53
- ```coffee
54
- esbuild = require "esbuild"
55
- civetPlugin = require "@danielx/civet/esbuild-plugin"
56
-
57
- esbuild.build
58
- entryPoints: ['source/main.civet']
59
- bundle: true
60
- platform: 'node'
61
- outfile: 'dist/main.js'
62
- plugins: [
63
- civetPlugin
64
- ]
65
- .catch -> process.exit 1
66
-
67
- ```
68
-
69
50
  Things Kept from CoffeeScript
70
51
  ---
71
52
 
@@ -73,7 +54,7 @@ Things Kept from CoffeeScript
73
54
  - `or` -> `||`
74
55
  - `and` -> `&&`
75
56
  - `loop` -> `while(true)`
76
- - `unless` conditional (without the `else`)
57
+ - `unless exp` -> `if(!exp)`
77
58
  - `until condition` -> `while(!condition)`
78
59
  - Object literal syntax
79
60
  ```coffee
@@ -116,18 +97,22 @@ Things Removed from CoffeeScript
116
97
  - `not instanceof` (use `!(a instanceof b)`)
117
98
  - `not in`
118
99
  - `not of`
100
+ - NOTE: CoffeeScript `not` precedence is dubious. `not a < b` should be equivalent to `!(a < b)` but it is in fact `!a < b`
119
101
  - `do` keyword (replaced with JS `do`, invoke using existing `(-> ...)()` syntax)
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)`)
102
+ - `for from` (use JS `for of`, `"civet coffeeCompat"`, or `"civet coffeeForLoops"`)
103
+ - `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
+ - `for ... when <condition>` (use `continue if exp` inside loop, `"civet coffeeCompat"`, or `"civet coffeeForLoops"`)
122
105
  - `and=`, `or=` (don't mix and match words and symbols)
123
106
  - `a ? b` (use `a ?? b`, though it doesn't check for undeclared variables)
107
+ - `a of b` (use `a in b` matching JS, or `"civet coffeeCompat"`, or `"civet coffeeOf"`)
124
108
  - Iteration expression results
125
109
  - Backtick embedded JS (replaced by template literals)
126
110
  - Will likely add later
127
111
  - Optional assignment `x?.y = 3` -> `x != null ? x.y = 3 : undefined`
112
+ - Loop expressions (at least in compatibility mode)
113
+ - Conditional assignment `a?[x] = 3` -> `a ? a[x] = 3 : undefined`
128
114
  - Might add later
129
115
  - Braceless inline objects `x = coolStory: true`
130
- - Comprensions
131
116
  - `///` Heregexp
132
117
  - Ranges `[0...10]`
133
118
  - Rest parameter in any assignment position
@@ -140,6 +125,7 @@ Things Changed from CoffeeScript
140
125
  - `!=` -> `!=` rather than `!==` (can be kept with `"civet coffeeCompat"`)
141
126
  - `for in` and `for of` are no longer swapped and become their JS equivalents.
142
127
  - `a...` is now `...a` just like JS
128
+ - `a in b` is now `a in b` rather than `b.indexOf(a) >= 0`
143
129
  - `x?.y` now compiles to `x?.y` rather than the `if typeof x !== 'undefined' && x !== null` if check
144
130
  - Existential `x?` -> `(x != null)` no longer checks for undeclared variables.
145
131
  - `x?()` -> `x?.()` instead of `if (typeof x === 'function') { x() }`
@@ -201,6 +187,12 @@ Things Added that CoffeeScript didn't
201
187
  - Class constructor shorthand `@( ... )`
202
188
  - ClassStaticBlock `@ { ... }`
203
189
  - `<` as `extends` shorthand
190
+ - Short function block syntax like [Ruby symbol to proc](https://ruby-doc.org/core-3.1.2/Symbol.html#method-i-to_proc), [Crystal](https://crystal-lang.org/reference/1.6/syntax_and_semantics/blocks_and_procs.html#short-one-parameter-syntax), [Elm record access](https://elm-lang.org/docs/records#access)
191
+ - access `x.map &.name` -> `x.map(a => a.name)`
192
+ - nested access + slices `x.map &.profile?.name[0...3]` -> `x.map(a => a.profile?.name.slice(0, 3))`
193
+ - function call `x.map &.callback a, b` -> `x.map($ => $.callback(a, b))`
194
+ - unary operators `x.map !!&`, -> `x.map($ => !!$)`
195
+ - binary operators `x.map &+1` -> `x.map($ => $+1)`
204
196
  - Postfix loop `run() loop` -> `while(true) run()`
205
197
  - Shebang line is kept unmodified in output
206
198
  ```civet
@@ -224,6 +216,7 @@ of numbers with `1..toString()` use `1.toString()` instead. When exponent follow
224
216
  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`.
225
217
  - Additional reserved words `and`, `or`, `loop`, `until`, `unless`
226
218
  - No whitespace between unary operators and operands. Mandatory whitespace between condition and ternary `?` ex. `x ? a : b` since `x?` is the unary existential operator.
219
+ - No labels (yet...)
227
220
 
228
221
  CoffeeScript Compatibility
229
222
  ---