File tree Expand file tree Collapse file tree 4 files changed +47
-19
lines changed Expand file tree Collapse file tree 4 files changed +47
-19
lines changed Original file line number Diff line number Diff line change 1
1
match x :
2
- | 1 : "lt one"
3
- | "hi" : "eq zero"
4
- | `there ${ 1 + 1 } ` : "eq two"
5
- | ~ f ( ) : "f(x) truthy"
6
- | . prop : "has prop"
7
- | .0 : "has first child"
2
+ | 1 or 0.1 or 0x11 or + 1 or - 1 :
3
+ it
4
+ | "hi" :
5
+ it
6
+ | `there ${ 1 + 1 } ` :
7
+ it
8
+ | / \s + / :
9
+ it
10
+ | Number or Boolean or String :
11
+ it
12
+ | Array or Object or Map or Foo :
13
+ it
14
+ | null or undefined :
15
+ it
16
+ | x or + x :
17
+ it
18
+ | not 1 or not x :
19
+ it
Original file line number Diff line number Diff line change 1
- if ( x === 1 ) {
2
- "lt one" ;
3
- } else if ( x === "hi" ) {
4
- "eq zero" ;
5
- } else if ( x === `there ${ 1 + 1 } ` ) {
6
- "eq two" ;
7
- } else if ( f ( x ) ) {
8
- "f(x) truthy" ;
9
- } else if ( x . prop ) {
10
- "has prop" ;
11
- } else if ( x [ 0 ] ) {
12
- "has first child" ;
13
- }
1
+ if ( x === 1 || x === 0.1 || x === 0x11 || x === + 1 || x === - 1 ) {
2
+ it ;
3
+ } else if ( x === "hi" ) {
4
+ it ;
5
+ } else if ( x === `there ${ 1 + 1 } ` ) {
6
+ it ;
7
+ } else if ( / \s + / . test ( x ) ) {
8
+ it ;
9
+ } else if ( typeof x === "number" || typeof x === "boolean" || typeof x === "string" ) {
10
+ it ;
11
+ } else if ( x instanceof Array || x instanceof Object || x instanceof Map || x instanceof Foo ) {
12
+ it ;
13
+ } else if ( x === null || x === undefined ) {
14
+ it ;
15
+ } else if ( x || + x ) {
16
+ it ;
17
+ } else if ( ! ( x === 1 ) || ! x ) {
18
+ it ;
19
+ }
Original file line number Diff line number Diff line change
1
+ match x :
2
+ | not 1 or not Number or not "hi" :
3
+ it
4
+ | not x or not 1 + 1 or not foo ( bar ) :
5
+ it
Original file line number Diff line number Diff line change
1
+ if ( ! ( x === 1 ) || ! ( typeof x === "number" ) || ! ( x === "hi" ) ) {
2
+ it ;
3
+ } else if ( ! x || ! 1 + 1 || ! foo ( bar ) ) {
4
+ it ;
5
+ }
You can’t perform that action at this time.
0 commit comments