@danielx/civet 0.5.73 → 0.5.75

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
@@ -10,6 +10,7 @@ Civet
10
10
  The modern way to write TypeScript.
11
11
 
12
12
  - [Documentation](https://civet.dev/)
13
+ - [Design Philosophy](https://civet.dev/philosophy)
13
14
  - [Civet Playground](https://civet.dev/playground)
14
15
  - [Civet VSCode Extension](https://marketplace.visualstudio.com/items?itemName=DanielX.civet)
15
16
  - [Discord Server](https://discord.gg/xkrW9GebBc)
@@ -74,6 +75,11 @@ Civet is essentially a tasteful superset of TypeScript.
74
75
 
75
76
  ### Implementations of New and Proposed ES Features
76
77
 
78
+ See the [documentation](https://civet.dev/) for examples of these
79
+ and other features.
80
+
81
+ - Pattern matching (based on [TC39 proposal](https://github.com/tc39/proposal-pattern-matching))
82
+ - `switch` can match patterns like `[{type: "text", name}, ...rest]`
77
83
  - Pipe operator (based on [F# pipes](https://learn.microsoft.com/en-us/dotnet/fsharp/language-reference/symbol-and-operator-reference/#function-symbols-and-operators), [Hack pipes](https://docs.hhvm.com/hack/expressions-and-operators/pipe) and the [TC39 proposal](https://github.com/tc39/proposal-pipeline-operator))
78
84
  - `data |> Object.keys |> console.log` equivalent to
79
85
  `console.log(Object.keys(data))`
@@ -82,14 +88,19 @@ Civet is essentially a tasteful superset of TypeScript.
82
88
  - `|> await`, `|> yield`, and `|> return` (at end)
83
89
  for wrapping left-hand side with that operation
84
90
  - 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)
85
- - Access: `x.map &.name` → `x.map(a => a.name)`
91
+ - Access: `x.map &.name` or `x.map .name` → `x.map(a => a.name)`
86
92
  - Nested access + slices: `x.map &.profile?.name[0...3]` → `x.map(a => a.profile?.name.slice(0, 3))`
87
93
  - Function call: `x.map &.callback a, b` → `x.map($ => $.callback(a, b))`
88
94
  - Unary operators: `x.map !!&` → `x.map($ => !!$)`
89
95
  - Binary operators: `x.map &+1` → `x.map($ => $+1)`
90
- - Flagging shorthand based on [from LiveScript](https://livescript.net/#literals-objects):
91
- `{+debug, -live, !verbose}` → `{debug: true, live: false, verbose: false}`
92
-
96
+ - Object literal shorthand
97
+ - `{foo()}` → `{foo: foo()}`, `{props.foo}` `{foo: props.foo}`
98
+ - ``{`${x}${y}`: z}`` → ``{[`${x}${y}`]: z}``
99
+ - `data.{x,y}` or `data{x,y}` → `{x: data.x, y: data.y}`
100
+ - Flagging shorthand based on [from LiveScript](https://livescript.net/#literals-objects):
101
+ `{+debug, -live, !verbose}` → `{debug: true, live: false, verbose: false}`
102
+ - Custom infix operators from any two-argument function
103
+ - `do` expressions, `if` expressions, `for` expressions
93
104
 
94
105
  ### Convenience for ES6+ Features
95
106
 
@@ -194,7 +205,7 @@ could be a valid property `1.e10` → `1..e10`. The workaround is to add a trail
194
205
  - `when` inside switch automatically breaks and adds block scope.
195
206
  - `else` inside switch adds block scope.
196
207
  - No whitespace between unary operators and operands. Mandatory whitespace between condition and ternary `?` ex. `x ? a : b` since `x?` is the unary existential operator.
197
- - No labels (yet...)
208
+ - Labels written `:label` (except for special case `$:` for Svelte)
198
209
 
199
210
  ### Scripting Improvements
200
211
 
@@ -361,42 +372,6 @@ esbuild.build({
361
372
 
362
373
  It's super fast and works great!
363
374
 
364
- Philosophy
365
- ---
366
-
367
- Civet is a **large language that feels small**. Civet is large because it is mostly a **superset of TypeScript**,
368
- an already large language. Civet feels small because of the coherent design aesthetic: related
369
- features look and behave similarly, so when seeing a new feature you can have a good idea what it does,
370
- and your existing knowledge of JavaScript and other languages leads you in the right direction.
371
-
372
- Civet works with **existing tools**. We're not trying to replace the TypeScript type checker; we want to
373
- amplify its power. We're not trying to change ES semantics; we want to present them in a coherent and expressive
374
- way.
375
-
376
- **Less syntax** is preferred.
377
-
378
- **Context matters**. The same tokens can mean different things in different contexts. This shouldn't be arbitrary
379
- but based on pragmatic concerns. Things should be consistent where possible, especially conceptually.
380
-
381
- Civet builds on top of **history**. We've taken inspiration from languages like CoffeeScript, Elm, LiveScript, Flow,
382
- Haskell, Perl, Python, Ruby, Crystal, Bash, and others.
383
-
384
- Civet is **pragmatic**. Civet design is informed by 25+ years of JavaScript development. Frontend frameworks
385
- have come and gone but they all addressed issues that were important for their time. We focus heavily on
386
- addressing concerns that real developers feel every day. A key criteria for evaluating features is "how does it
387
- work in practice?".
388
-
389
- Civet **evolves**. As the official JS and TS specifications evolve into the future, Civet also evolves favoring **compatibility**.
390
- This may lead us to difficult choices where the future spec has evolved differently than we anticipated (pipe operators,
391
- do expressions, pattern matching). In those cases, Civet will adapt to match the latest spec while providing configuration
392
- options to allow migration bit by bit while keeping existing code working.
393
-
394
- Civet is **configurable**. There is no single "right way" for everyone at all times. Some of us have older CoffeeScript
395
- codebases that would benefit from added types. Others have massive TypeScript applications that could benefit from
396
- new language features and shorthand syntax. Civet provides a way to get the benefits bit by bit without a complete
397
- rewrite. This same configurability lets us experiment with language features to gain experience and improve them before
398
- locking them in. It also allows us to adapt to a changing future.
399
-
400
375
  Sponsorship
401
376
  ---
402
377
  If you are so inclined, you can sponsor Civet on [Open Collective](https://opencollective.com/civet).