|
3 | 3 | import * as $$Array from "rescript/lib/es6/Array.js";
|
4 | 4 |
|
5 | 5 | function decodeUser(json) {
|
6 |
| - if (json === null) { |
7 |
| - return; |
8 |
| - } |
9 | 6 | if (!(typeof json === "object" && !Array.isArray(json))) {
|
10 | 7 | return;
|
11 | 8 | }
|
12 |
| - let match = json.id; |
13 |
| - if (match === undefined) { |
14 |
| - return; |
15 |
| - } |
16 |
| - if (match === null) { |
17 |
| - return; |
18 |
| - } |
19 |
| - if (typeof match !== "string") { |
20 |
| - return; |
21 |
| - } |
22 |
| - let match$1 = json.name; |
23 |
| - if (match$1 === undefined) { |
24 |
| - return; |
25 |
| - } |
26 |
| - if (match$1 === null) { |
27 |
| - return; |
28 |
| - } |
29 |
| - if (typeof match$1 !== "string") { |
| 9 | + let id = json.id; |
| 10 | + if (typeof id !== "string") { |
30 | 11 | return;
|
31 | 12 | }
|
32 |
| - let match$2 = json.age; |
33 |
| - if (match$2 === undefined) { |
| 13 | + let name = json.name; |
| 14 | + if (typeof name !== "string") { |
34 | 15 | return;
|
35 | 16 | }
|
36 |
| - if (match$2 === null) { |
37 |
| - return; |
38 |
| - } |
39 |
| - if (typeof match$2 !== "number") { |
| 17 | + let age = json.age; |
| 18 | + if (typeof age !== "number") { |
40 | 19 | return;
|
41 | 20 | }
|
42 | 21 | let email = json.email;
|
43 | 22 | let tmp;
|
44 | 23 | tmp = typeof email === "string" ? email : undefined;
|
45 | 24 | return {
|
46 |
| - id: match, |
47 |
| - name: match$1, |
48 |
| - age: match$2 | 0, |
| 25 | + id: id, |
| 26 | + name: name, |
| 27 | + age: age | 0, |
49 | 28 | email: tmp
|
50 | 29 | };
|
51 | 30 | }
|
52 | 31 |
|
53 | 32 | function decodeGroup(json) {
|
54 |
| - if (json === null) { |
55 |
| - return; |
56 |
| - } |
57 | 33 | if (!(typeof json === "object" && !Array.isArray(json))) {
|
58 | 34 | return;
|
59 | 35 | }
|
60 |
| - let match = json.id; |
61 |
| - if (match === undefined) { |
62 |
| - return; |
63 |
| - } |
64 |
| - if (match === null) { |
65 |
| - return; |
66 |
| - } |
67 |
| - if (typeof match !== "string") { |
68 |
| - return; |
69 |
| - } |
70 |
| - let match$1 = json.name; |
71 |
| - if (match$1 === undefined) { |
72 |
| - return; |
73 |
| - } |
74 |
| - if (match$1 === null) { |
| 36 | + let id = json.id; |
| 37 | + if (typeof id !== "string") { |
75 | 38 | return;
|
76 | 39 | }
|
77 |
| - if (typeof match$1 !== "string") { |
| 40 | + let name = json.name; |
| 41 | + if (typeof name !== "string") { |
78 | 42 | return;
|
79 | 43 | }
|
80 |
| - let match$2 = json.users; |
81 |
| - if (match$2 !== undefined && !(match$2 === null || !Array.isArray(match$2))) { |
| 44 | + let users = json.users; |
| 45 | + if (Array.isArray(users)) { |
82 | 46 | return {
|
83 |
| - id: match, |
84 |
| - name: match$1, |
85 |
| - users: $$Array.filterMap(match$2, decodeUser) |
| 47 | + id: id, |
| 48 | + name: name, |
| 49 | + users: $$Array.filterMap(users, decodeUser) |
86 | 50 | };
|
87 | 51 | }
|
88 | 52 |
|
|
0 commit comments