@macroforge/mcp-server 0.1.65 → 0.1.72
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 +7 -4
- package/dist/index.js +3 -3
- package/dist/index.js.map +1 -1
- package/dist/tools/docs-loader.d.ts.map +1 -1
- package/dist/tools/docs-loader.js +1 -1
- package/dist/tools/docs-loader.js.map +1 -1
- package/dist/tools/index.d.ts.map +1 -1
- package/dist/tools/index.js +84 -85
- package/dist/tools/index.js.map +1 -1
- package/docs/BOOK.md +8 -33
- package/docs/api/api-overview.md +4 -4
- package/docs/api/expand-sync.md +3 -2
- package/docs/api/native-plugin.md +5 -2
- package/docs/api/position-mapper.md +7 -4
- package/docs/api/transform-sync.md +7 -5
- package/docs/builtin-macros/deserialize/all-options.md +7 -21
- package/docs/builtin-macros/deserialize/combining-with-serialize.md +7 -5
- package/docs/builtin-macros/deserialize/enum-support.md +8 -6
- package/docs/builtin-macros/deserialize/error-handling.md +10 -9
- package/docs/builtin-macros/deserialize/interface-support.md +9 -4
- package/docs/builtin-macros/deserialize/runtime-validation.md +10 -21
- package/docs/builtin-macros/deserialize/serde-options.md +19 -31
- package/docs/builtin-macros/deserialize/type-alias-support.md +7 -6
- package/docs/builtin-macros/macros-overview/detailed-documentation.md +9 -9
- package/docs/builtin-macros/macros-overview/enum-support.md +3 -2
- package/docs/builtin-macros/macros-overview/interface-support.md +3 -2
- package/docs/builtin-macros/macros-overview/overview.md +13 -12
- package/docs/builtin-macros/macros-overview/type-alias-support.md +3 -2
- package/docs/builtin-macros/macros-overview.md +27 -23
- package/docs/builtin-macros/partial-eq/example.md +188 -232
- package/docs/builtin-macros/partial-eq/overview.md +18 -18
- package/docs/builtin-macros/serialize/example.md +11 -3
- package/docs/builtin-macros/serialize/overview.md +12 -11
- package/docs/builtin-macros/serialize/type-specific-serialization.md +12 -12
- package/docs/concepts/architecture.md +23 -22
- package/docs/concepts/derive-system/built-in-vs-custom-macros.md +4 -3
- package/docs/concepts/derive-system/overview.md +27 -24
- package/docs/concepts/derive-system.md +31 -27
- package/docs/concepts/how-macros-work.md +23 -21
- package/docs/custom-macros/custom-overview.md +9 -8
- package/docs/custom-macros/rust-setup.md +11 -10
- package/docs/custom-macros/ts-macro-derive/accessing-field-data.md +2 -1
- package/docs/custom-macros/ts-macro-derive/adding-imports.md +2 -1
- package/docs/custom-macros/ts-macro-derive/attribute-options.md +1 -1
- package/docs/custom-macros/ts-macro-derive/complete-example.md +1 -1
- package/docs/custom-macros/ts-macro-derive/deriveinput-structure.md +1 -1
- package/docs/custom-macros/ts-macro-derive/function-signature.md +1 -1
- package/docs/custom-macros/ts-macro-derive/overview.md +3 -2
- package/docs/custom-macros/ts-macro-derive/parsing-input.md +1 -1
- package/docs/custom-macros/ts-macro-derive/returning-errors.md +1 -1
- package/docs/custom-macros/ts-macro-derive.md +7 -4
- package/docs/custom-macros/ts-quote/backtick-template-literals.md +5 -3
- package/docs/custom-macros/ts-quote/comments-and.md +3 -2
- package/docs/custom-macros/ts-quote/complete-example-json-derive-macro.md +12 -11
- package/docs/custom-macros/ts-quote/conditionals-ifif.md +1 -1
- package/docs/custom-macros/ts-quote/identifier-concatenation-content.md +5 -3
- package/docs/custom-macros/ts-quote/interpolation-expr.md +18 -11
- package/docs/custom-macros/ts-quote/iteration-for.md +1 -1
- package/docs/custom-macros/ts-quote/local-constants-let.md +1 -1
- package/docs/custom-macros/ts-quote/match-expressions-match.md +1 -1
- package/docs/custom-macros/ts-quote/overview.md +4 -2
- package/docs/custom-macros/ts-quote/pattern-matching-if-let.md +2 -2
- package/docs/custom-macros/ts-quote/pattern-matching-iflet.md +1 -1
- package/docs/custom-macros/ts-quote/quick-reference.md +24 -23
- package/docs/custom-macros/ts-quote/side-effects-do.md +6 -5
- package/docs/custom-macros/ts-quote/string-interpolation-text-expr.md +3 -3
- package/docs/custom-macros/ts-quote/string-interpolation-textexpr.md +1 -1
- package/docs/custom-macros/ts-quote/tsstream-injection-typescript.md +3 -2
- package/docs/custom-macros/ts-quote/while-loops-while.md +1 -1
- package/docs/custom-macros/ts-quote.md +30 -19
- package/docs/getting-started/first-macro.md +5 -4
- package/docs/getting-started/installation.md +20 -17
- package/docs/integration/cli.md +11 -5
- package/docs/integration/configuration.md +7 -9
- package/docs/integration/integration-overview.md +5 -5
- package/docs/integration/mcp-server.md +17 -8
- package/docs/integration/svelte-preprocessor.md +18 -14
- package/docs/integration/typescript-plugin.md +14 -12
- package/docs/integration/vite-plugin.md +13 -11
- package/docs/language-servers/ls-overview.md +18 -12
- package/docs/language-servers/svelte-ls.md +9 -11
- package/docs/language-servers/svelte.md +18 -17
- package/docs/language-servers/zed-extensions.md +14 -11
- package/docs/language-servers/zed.md +19 -13
- package/docs/roadmap/roadmap.md +8 -6
- package/package.json +5 -5
|
@@ -1,20 +1,21 @@
|
|
|
1
1
|
# Built-in Macros
|
|
2
2
|
|
|
3
|
-
Macroforge comes with built-in derive macros that cover the most common code generation needs. All
|
|
3
|
+
Macroforge comes with built-in derive macros that cover the most common code generation needs. All
|
|
4
|
+
macros work with classes, interfaces, enums, and type aliases.
|
|
4
5
|
|
|
5
6
|
## Overview
|
|
6
7
|
|
|
7
|
-
| Macro | Generates
|
|
8
|
-
| --------------------------------------------------- |
|
|
9
|
-
| [`Debug`](../docs/builtin-macros/debug) | `toString(): string`
|
|
10
|
-
| [`Clone`](../docs/builtin-macros/clone) | `clone(): T`
|
|
11
|
-
| [`Default`](../docs/builtin-macros/default) | `static default(): T`
|
|
12
|
-
| [`Hash`](../docs/builtin-macros/hash) | `hashCode(): number`
|
|
13
|
-
| [`PartialEq`](../docs/builtin-macros/partial-eq) | `equals(other: T): boolean`
|
|
14
|
-
| [`Ord`](../docs/builtin-macros/ord) | `compare(other: T): number`
|
|
8
|
+
| Macro | Generates | Description |
|
|
9
|
+
| --------------------------------------------------- | ---------------------------------------------- | --------------------------------------- |
|
|
10
|
+
| [`Debug`](../docs/builtin-macros/debug) | `toString(): string` | Human-readable string representation |
|
|
11
|
+
| [`Clone`](../docs/builtin-macros/clone) | `clone(): T` | Creates a deep copy of the object |
|
|
12
|
+
| [`Default`](../docs/builtin-macros/default) | `static default(): T` | Creates an instance with default values |
|
|
13
|
+
| [`Hash`](../docs/builtin-macros/hash) | `hashCode(): number` | Generates a hash code for the object |
|
|
14
|
+
| [`PartialEq`](../docs/builtin-macros/partial-eq) | `equals(other: T): boolean` | Value equality comparison |
|
|
15
|
+
| [`Ord`](../docs/builtin-macros/ord) | `compare(other: T): number` | Total ordering comparison (-1, 0, 1) |
|
|
15
16
|
| [`PartialOrd`](../docs/builtin-macros/partial-ord) | `partialCompare(other: T): number | null` | Partial ordering comparison |
|
|
16
|
-
| [`Serialize`](../docs/builtin-macros/serialize) | `toJSON(): Record<string, unknown>`
|
|
17
|
-
| [`Deserialize`](../docs/builtin-macros/deserialize) | `static fromJSON(data: unknown): T`
|
|
17
|
+
| [`Serialize`](../docs/builtin-macros/serialize) | `toJSON(): Record<string, unknown>` | JSON serialization with type handling |
|
|
18
|
+
| [`Deserialize`](../docs/builtin-macros/deserialize) | `static fromJSON(data: unknown): T` | JSON deserialization with validation |
|
|
18
19
|
|
|
19
20
|
## Using Built-in Macros
|
|
20
21
|
|
|
@@ -33,4 +34,4 @@ class User {
|
|
|
33
34
|
this.age = age;
|
|
34
35
|
}
|
|
35
36
|
}
|
|
36
|
-
```
|
|
37
|
+
```
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
## Type Alias Support
|
|
2
2
|
|
|
3
|
-
All built-in macros work with type aliases. For object type aliases, field-aware methods are
|
|
3
|
+
All built-in macros work with type aliases. For object type aliases, field-aware methods are
|
|
4
|
+
generated in a namespace:
|
|
4
5
|
|
|
5
6
|
TypeScript
|
|
6
7
|
|
|
@@ -59,4 +60,4 @@ console.log(copy.name); // "Alice"
|
|
|
59
60
|
|
|
60
61
|
// Eq
|
|
61
62
|
console.log(user.equals(copy)); // true
|
|
62
|
-
```
|
|
63
|
+
```
|
|
@@ -1,20 +1,21 @@
|
|
|
1
1
|
# Built-in Macros
|
|
2
2
|
|
|
3
|
-
Macroforge comes with built-in derive macros that cover the most common code generation needs. All
|
|
3
|
+
Macroforge comes with built-in derive macros that cover the most common code generation needs. All
|
|
4
|
+
macros work with classes, interfaces, enums, and type aliases.
|
|
4
5
|
|
|
5
6
|
## Overview
|
|
6
7
|
|
|
7
|
-
| Macro | Generates
|
|
8
|
-
| --------------------------------------------------- |
|
|
9
|
-
| [`Debug`](../docs/builtin-macros/debug) | `toString(): string`
|
|
10
|
-
| [`Clone`](../docs/builtin-macros/clone) | `clone(): T`
|
|
11
|
-
| [`Default`](../docs/builtin-macros/default) | `static default(): T`
|
|
12
|
-
| [`Hash`](../docs/builtin-macros/hash) | `hashCode(): number`
|
|
13
|
-
| [`PartialEq`](../docs/builtin-macros/partial-eq) | `equals(other: T): boolean`
|
|
14
|
-
| [`Ord`](../docs/builtin-macros/ord) | `compare(other: T): number`
|
|
8
|
+
| Macro | Generates | Description |
|
|
9
|
+
| --------------------------------------------------- | ---------------------------------------------- | --------------------------------------- |
|
|
10
|
+
| [`Debug`](../docs/builtin-macros/debug) | `toString(): string` | Human-readable string representation |
|
|
11
|
+
| [`Clone`](../docs/builtin-macros/clone) | `clone(): T` | Creates a deep copy of the object |
|
|
12
|
+
| [`Default`](../docs/builtin-macros/default) | `static default(): T` | Creates an instance with default values |
|
|
13
|
+
| [`Hash`](../docs/builtin-macros/hash) | `hashCode(): number` | Generates a hash code for the object |
|
|
14
|
+
| [`PartialEq`](../docs/builtin-macros/partial-eq) | `equals(other: T): boolean` | Value equality comparison |
|
|
15
|
+
| [`Ord`](../docs/builtin-macros/ord) | `compare(other: T): number` | Total ordering comparison (-1, 0, 1) |
|
|
15
16
|
| [`PartialOrd`](../docs/builtin-macros/partial-ord) | `partialCompare(other: T): number | null` | Partial ordering comparison |
|
|
16
|
-
| [`Serialize`](../docs/builtin-macros/serialize) | `toJSON(): Record<string, unknown>`
|
|
17
|
-
| [`Deserialize`](../docs/builtin-macros/deserialize) | `static fromJSON(data: unknown): T`
|
|
17
|
+
| [`Serialize`](../docs/builtin-macros/serialize) | `toJSON(): Record<string, unknown>` | JSON serialization with type handling |
|
|
18
|
+
| [`Deserialize`](../docs/builtin-macros/deserialize) | `static fromJSON(data: unknown): T` | JSON deserialization with validation |
|
|
18
19
|
|
|
19
20
|
## Using Built-in Macros
|
|
20
21
|
|
|
@@ -37,7 +38,8 @@ class User {
|
|
|
37
38
|
|
|
38
39
|
## Interface Support
|
|
39
40
|
|
|
40
|
-
All built-in macros work with interfaces. For interfaces, methods are generated as functions in a
|
|
41
|
+
All built-in macros work with interfaces. For interfaces, methods are generated as functions in a
|
|
42
|
+
namespace with the same name, using `self` as the first parameter:
|
|
41
43
|
|
|
42
44
|
TypeScript
|
|
43
45
|
|
|
@@ -66,7 +68,8 @@ console.log(Point.equals(point, copy)); // true
|
|
|
66
68
|
|
|
67
69
|
## Enum Support
|
|
68
70
|
|
|
69
|
-
All built-in macros work with enums. For enums, methods are generated as functions in a namespace
|
|
71
|
+
All built-in macros work with enums. For enums, methods are generated as functions in a namespace
|
|
72
|
+
with the same name:
|
|
70
73
|
|
|
71
74
|
TypeScript
|
|
72
75
|
|
|
@@ -97,7 +100,8 @@ const parsed = Status.fromJSON("active"); // Status.Active
|
|
|
97
100
|
|
|
98
101
|
## Type Alias Support
|
|
99
102
|
|
|
100
|
-
All built-in macros work with type aliases. For object type aliases, field-aware methods are
|
|
103
|
+
All built-in macros work with type aliases. For object type aliases, field-aware methods are
|
|
104
|
+
generated in a namespace:
|
|
101
105
|
|
|
102
106
|
TypeScript
|
|
103
107
|
|
|
@@ -162,12 +166,12 @@ console.log(user.equals(copy)); // true
|
|
|
162
166
|
|
|
163
167
|
Each macro has its own options and behaviors:
|
|
164
168
|
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
169
|
+
- [**Debug**](../docs/builtin-macros/debug) - Customizable field renaming and skipping
|
|
170
|
+
- [**Clone**](../docs/builtin-macros/clone) - Deep copying for all field types
|
|
171
|
+
- [**Default**](../docs/builtin-macros/default) - Default value generation with field attributes
|
|
172
|
+
- [**Hash**](../docs/builtin-macros/hash) - Hash code generation for use in maps and sets
|
|
173
|
+
- [**PartialEq**](../docs/builtin-macros/partial-eq) - Value-based equality comparison
|
|
174
|
+
- [**Ord**](../docs/builtin-macros/ord) - Total ordering for sorting
|
|
175
|
+
- [**PartialOrd**](../docs/builtin-macros/partial-ord) - Partial ordering comparison
|
|
176
|
+
- [**Serialize**](../docs/builtin-macros/serialize) - JSON serialization with serde-style options
|
|
177
|
+
- [**Deserialize**](../docs/builtin-macros/deserialize) - JSON deserialization with validation
|
|
@@ -30,27 +30,23 @@ class User {
|
|
|
30
30
|
|
|
31
31
|
hashCode(): number {
|
|
32
32
|
let hash = 17;
|
|
33
|
-
hash =
|
|
34
|
-
(
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
: this.cachedScore
|
|
51
|
-
.toString()
|
|
52
|
-
.split('')
|
|
53
|
-
.reduce((h, c) => (h * 31 + c.charCodeAt(0)) | 0, 0))) |
|
|
33
|
+
hash = (hash * 31 +
|
|
34
|
+
(Number.isInteger(this.id) ? this.id | 0 : this.id
|
|
35
|
+
.toString()
|
|
36
|
+
.split('')
|
|
37
|
+
.reduce((h, c) => (h * 31 + c.charCodeAt(0)) | 0, 0))) |
|
|
38
|
+
0;
|
|
39
|
+
hash = (hash * 31 +
|
|
40
|
+
(this.name ?? '').split('').reduce(
|
|
41
|
+
(h, c) => (h * 31 + c.charCodeAt(0)) | 0,
|
|
42
|
+
0
|
|
43
|
+
)) |
|
|
44
|
+
0;
|
|
45
|
+
hash = (hash * 31 +
|
|
46
|
+
(Number.isInteger(this.cachedScore) ? this.cachedScore | 0 : this.cachedScore
|
|
47
|
+
.toString()
|
|
48
|
+
.split('')
|
|
49
|
+
.reduce((h, c) => (h * 31 + c.charCodeAt(0)) | 0, 0))) |
|
|
54
50
|
0;
|
|
55
51
|
return hash;
|
|
56
52
|
}
|
|
@@ -77,27 +73,23 @@ class User {
|
|
|
77
73
|
|
|
78
74
|
hashCode(): number {
|
|
79
75
|
let hash = 17;
|
|
80
|
-
hash =
|
|
81
|
-
(
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
: this.cachedScore
|
|
98
|
-
.toString()
|
|
99
|
-
.split('')
|
|
100
|
-
.reduce((h, c) => (h * 31 + c.charCodeAt(0)) | 0, 0))) |
|
|
76
|
+
hash = (hash * 31 +
|
|
77
|
+
(Number.isInteger(this.id) ? this.id | 0 : this.id
|
|
78
|
+
.toString()
|
|
79
|
+
.split('')
|
|
80
|
+
.reduce((h, c) => (h * 31 + c.charCodeAt(0)) | 0, 0))) |
|
|
81
|
+
0;
|
|
82
|
+
hash = (hash * 31 +
|
|
83
|
+
(this.name ?? '').split('').reduce(
|
|
84
|
+
(h, c) => (h * 31 + c.charCodeAt(0)) | 0,
|
|
85
|
+
0
|
|
86
|
+
)) |
|
|
87
|
+
0;
|
|
88
|
+
hash = (hash * 31 +
|
|
89
|
+
(Number.isInteger(this.cachedScore) ? this.cachedScore | 0 : this.cachedScore
|
|
90
|
+
.toString()
|
|
91
|
+
.split('')
|
|
92
|
+
.reduce((h, c) => (h * 31 + c.charCodeAt(0)) | 0, 0))) |
|
|
101
93
|
0;
|
|
102
94
|
return hash;
|
|
103
95
|
}
|
|
@@ -122,27 +114,23 @@ class User {
|
|
|
122
114
|
|
|
123
115
|
hashCode(): number {
|
|
124
116
|
let hash = 17;
|
|
125
|
-
hash =
|
|
126
|
-
(
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
: this.cachedScore
|
|
143
|
-
.toString()
|
|
144
|
-
.split('')
|
|
145
|
-
.reduce((h, c) => (h * 31 + c.charCodeAt(0)) | 0, 0))) |
|
|
117
|
+
hash = (hash * 31 +
|
|
118
|
+
(Number.isInteger(this.id) ? this.id | 0 : this.id
|
|
119
|
+
.toString()
|
|
120
|
+
.split('')
|
|
121
|
+
.reduce((h, c) => (h * 31 + c.charCodeAt(0)) | 0, 0))) |
|
|
122
|
+
0;
|
|
123
|
+
hash = (hash * 31 +
|
|
124
|
+
(this.name ?? '').split('').reduce(
|
|
125
|
+
(h, c) => (h * 31 + c.charCodeAt(0)) | 0,
|
|
126
|
+
0
|
|
127
|
+
)) |
|
|
128
|
+
0;
|
|
129
|
+
hash = (hash * 31 +
|
|
130
|
+
(Number.isInteger(this.cachedScore) ? this.cachedScore | 0 : this.cachedScore
|
|
131
|
+
.toString()
|
|
132
|
+
.split('')
|
|
133
|
+
.reduce((h, c) => (h * 31 + c.charCodeAt(0)) | 0, 0))) |
|
|
146
134
|
0;
|
|
147
135
|
return hash;
|
|
148
136
|
}
|
|
@@ -169,27 +157,23 @@ class User {
|
|
|
169
157
|
|
|
170
158
|
hashCode(): number {
|
|
171
159
|
let hash = 17;
|
|
172
|
-
hash =
|
|
173
|
-
(
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
: this.cachedScore
|
|
190
|
-
.toString()
|
|
191
|
-
.split('')
|
|
192
|
-
.reduce((h, c) => (h * 31 + c.charCodeAt(0)) | 0, 0))) |
|
|
160
|
+
hash = (hash * 31 +
|
|
161
|
+
(Number.isInteger(this.id) ? this.id | 0 : this.id
|
|
162
|
+
.toString()
|
|
163
|
+
.split('')
|
|
164
|
+
.reduce((h, c) => (h * 31 + c.charCodeAt(0)) | 0, 0))) |
|
|
165
|
+
0;
|
|
166
|
+
hash = (hash * 31 +
|
|
167
|
+
(this.name ?? '').split('').reduce(
|
|
168
|
+
(h, c) => (h * 31 + c.charCodeAt(0)) | 0,
|
|
169
|
+
0
|
|
170
|
+
)) |
|
|
171
|
+
0;
|
|
172
|
+
hash = (hash * 31 +
|
|
173
|
+
(Number.isInteger(this.cachedScore) ? this.cachedScore | 0 : this.cachedScore
|
|
174
|
+
.toString()
|
|
175
|
+
.split('')
|
|
176
|
+
.reduce((h, c) => (h * 31 + c.charCodeAt(0)) | 0, 0))) |
|
|
193
177
|
0;
|
|
194
178
|
return hash;
|
|
195
179
|
}
|
|
@@ -214,27 +198,23 @@ class User {
|
|
|
214
198
|
|
|
215
199
|
hashCode(): number {
|
|
216
200
|
let hash = 17;
|
|
217
|
-
hash =
|
|
218
|
-
(
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
: this.cachedScore
|
|
235
|
-
.toString()
|
|
236
|
-
.split('')
|
|
237
|
-
.reduce((h, c) => (h * 31 + c.charCodeAt(0)) | 0, 0))) |
|
|
201
|
+
hash = (hash * 31 +
|
|
202
|
+
(Number.isInteger(this.id) ? this.id | 0 : this.id
|
|
203
|
+
.toString()
|
|
204
|
+
.split('')
|
|
205
|
+
.reduce((h, c) => (h * 31 + c.charCodeAt(0)) | 0, 0))) |
|
|
206
|
+
0;
|
|
207
|
+
hash = (hash * 31 +
|
|
208
|
+
(this.name ?? '').split('').reduce(
|
|
209
|
+
(h, c) => (h * 31 + c.charCodeAt(0)) | 0,
|
|
210
|
+
0
|
|
211
|
+
)) |
|
|
212
|
+
0;
|
|
213
|
+
hash = (hash * 31 +
|
|
214
|
+
(Number.isInteger(this.cachedScore) ? this.cachedScore | 0 : this.cachedScore
|
|
215
|
+
.toString()
|
|
216
|
+
.split('')
|
|
217
|
+
.reduce((h, c) => (h * 31 + c.charCodeAt(0)) | 0, 0))) |
|
|
238
218
|
0;
|
|
239
219
|
return hash;
|
|
240
220
|
}
|
|
@@ -261,27 +241,23 @@ class User {
|
|
|
261
241
|
|
|
262
242
|
hashCode(): number {
|
|
263
243
|
let hash = 17;
|
|
264
|
-
hash =
|
|
265
|
-
(
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
: this.cachedScore
|
|
282
|
-
.toString()
|
|
283
|
-
.split('')
|
|
284
|
-
.reduce((h, c) => (h * 31 + c.charCodeAt(0)) | 0, 0))) |
|
|
244
|
+
hash = (hash * 31 +
|
|
245
|
+
(Number.isInteger(this.id) ? this.id | 0 : this.id
|
|
246
|
+
.toString()
|
|
247
|
+
.split('')
|
|
248
|
+
.reduce((h, c) => (h * 31 + c.charCodeAt(0)) | 0, 0))) |
|
|
249
|
+
0;
|
|
250
|
+
hash = (hash * 31 +
|
|
251
|
+
(this.name ?? '').split('').reduce(
|
|
252
|
+
(h, c) => (h * 31 + c.charCodeAt(0)) | 0,
|
|
253
|
+
0
|
|
254
|
+
)) |
|
|
255
|
+
0;
|
|
256
|
+
hash = (hash * 31 +
|
|
257
|
+
(Number.isInteger(this.cachedScore) ? this.cachedScore | 0 : this.cachedScore
|
|
258
|
+
.toString()
|
|
259
|
+
.split('')
|
|
260
|
+
.reduce((h, c) => (h * 31 + c.charCodeAt(0)) | 0, 0))) |
|
|
285
261
|
0;
|
|
286
262
|
return hash;
|
|
287
263
|
}
|
|
@@ -306,27 +282,23 @@ class User {
|
|
|
306
282
|
|
|
307
283
|
hashCode(): number {
|
|
308
284
|
let hash = 17;
|
|
309
|
-
hash =
|
|
310
|
-
(
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
: this.cachedScore
|
|
327
|
-
.toString()
|
|
328
|
-
.split('')
|
|
329
|
-
.reduce((h, c) => (h * 31 + c.charCodeAt(0)) | 0, 0))) |
|
|
285
|
+
hash = (hash * 31 +
|
|
286
|
+
(Number.isInteger(this.id) ? this.id | 0 : this.id
|
|
287
|
+
.toString()
|
|
288
|
+
.split('')
|
|
289
|
+
.reduce((h, c) => (h * 31 + c.charCodeAt(0)) | 0, 0))) |
|
|
290
|
+
0;
|
|
291
|
+
hash = (hash * 31 +
|
|
292
|
+
(this.name ?? '').split('').reduce(
|
|
293
|
+
(h, c) => (h * 31 + c.charCodeAt(0)) | 0,
|
|
294
|
+
0
|
|
295
|
+
)) |
|
|
296
|
+
0;
|
|
297
|
+
hash = (hash * 31 +
|
|
298
|
+
(Number.isInteger(this.cachedScore) ? this.cachedScore | 0 : this.cachedScore
|
|
299
|
+
.toString()
|
|
300
|
+
.split('')
|
|
301
|
+
.reduce((h, c) => (h * 31 + c.charCodeAt(0)) | 0, 0))) |
|
|
330
302
|
0;
|
|
331
303
|
return hash;
|
|
332
304
|
}
|
|
@@ -353,27 +325,23 @@ class User {
|
|
|
353
325
|
|
|
354
326
|
hashCode(): number {
|
|
355
327
|
let hash = 17;
|
|
356
|
-
hash =
|
|
357
|
-
(
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
: this.cachedScore
|
|
374
|
-
.toString()
|
|
375
|
-
.split('')
|
|
376
|
-
.reduce((h, c) => (h * 31 + c.charCodeAt(0)) | 0, 0))) |
|
|
328
|
+
hash = (hash * 31 +
|
|
329
|
+
(Number.isInteger(this.id) ? this.id | 0 : this.id
|
|
330
|
+
.toString()
|
|
331
|
+
.split('')
|
|
332
|
+
.reduce((h, c) => (h * 31 + c.charCodeAt(0)) | 0, 0))) |
|
|
333
|
+
0;
|
|
334
|
+
hash = (hash * 31 +
|
|
335
|
+
(this.name ?? '').split('').reduce(
|
|
336
|
+
(h, c) => (h * 31 + c.charCodeAt(0)) | 0,
|
|
337
|
+
0
|
|
338
|
+
)) |
|
|
339
|
+
0;
|
|
340
|
+
hash = (hash * 31 +
|
|
341
|
+
(Number.isInteger(this.cachedScore) ? this.cachedScore | 0 : this.cachedScore
|
|
342
|
+
.toString()
|
|
343
|
+
.split('')
|
|
344
|
+
.reduce((h, c) => (h * 31 + c.charCodeAt(0)) | 0, 0))) |
|
|
377
345
|
0;
|
|
378
346
|
return hash;
|
|
379
347
|
}
|
|
@@ -398,27 +366,23 @@ class User {
|
|
|
398
366
|
|
|
399
367
|
hashCode(): number {
|
|
400
368
|
let hash = 17;
|
|
401
|
-
hash =
|
|
402
|
-
(
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
: this.cachedScore
|
|
419
|
-
.toString()
|
|
420
|
-
.split('')
|
|
421
|
-
.reduce((h, c) => (h * 31 + c.charCodeAt(0)) | 0, 0))) |
|
|
369
|
+
hash = (hash * 31 +
|
|
370
|
+
(Number.isInteger(this.id) ? this.id | 0 : this.id
|
|
371
|
+
.toString()
|
|
372
|
+
.split('')
|
|
373
|
+
.reduce((h, c) => (h * 31 + c.charCodeAt(0)) | 0, 0))) |
|
|
374
|
+
0;
|
|
375
|
+
hash = (hash * 31 +
|
|
376
|
+
(this.name ?? '').split('').reduce(
|
|
377
|
+
(h, c) => (h * 31 + c.charCodeAt(0)) | 0,
|
|
378
|
+
0
|
|
379
|
+
)) |
|
|
380
|
+
0;
|
|
381
|
+
hash = (hash * 31 +
|
|
382
|
+
(Number.isInteger(this.cachedScore) ? this.cachedScore | 0 : this.cachedScore
|
|
383
|
+
.toString()
|
|
384
|
+
.split('')
|
|
385
|
+
.reduce((h, c) => (h * 31 + c.charCodeAt(0)) | 0, 0))) |
|
|
422
386
|
0;
|
|
423
387
|
return hash;
|
|
424
388
|
}
|
|
@@ -445,27 +409,23 @@ class User {
|
|
|
445
409
|
|
|
446
410
|
hashCode(): number {
|
|
447
411
|
let hash = 17;
|
|
448
|
-
hash =
|
|
449
|
-
(
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
: this.cachedScore
|
|
466
|
-
.toString()
|
|
467
|
-
.split('')
|
|
468
|
-
.reduce((h, c) => (h * 31 + c.charCodeAt(0)) | 0, 0))) |
|
|
412
|
+
hash = (hash * 31 +
|
|
413
|
+
(Number.isInteger(this.id) ? this.id | 0 : this.id
|
|
414
|
+
.toString()
|
|
415
|
+
.split('')
|
|
416
|
+
.reduce((h, c) => (h * 31 + c.charCodeAt(0)) | 0, 0))) |
|
|
417
|
+
0;
|
|
418
|
+
hash = (hash * 31 +
|
|
419
|
+
(this.name ?? '').split('').reduce(
|
|
420
|
+
(h, c) => (h * 31 + c.charCodeAt(0)) | 0,
|
|
421
|
+
0
|
|
422
|
+
)) |
|
|
423
|
+
0;
|
|
424
|
+
hash = (hash * 31 +
|
|
425
|
+
(Number.isInteger(this.cachedScore) ? this.cachedScore | 0 : this.cachedScore
|
|
426
|
+
.toString()
|
|
427
|
+
.split('')
|
|
428
|
+
.reduce((h, c) => (h * 31 + c.charCodeAt(0)) | 0, 0))) |
|
|
469
429
|
0;
|
|
470
430
|
return hash;
|
|
471
431
|
}
|
|
@@ -490,27 +450,23 @@ class User {
|
|
|
490
450
|
|
|
491
451
|
hashCode(): number {
|
|
492
452
|
let hash = 17;
|
|
493
|
-
hash =
|
|
494
|
-
(
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
: this.cachedScore
|
|
511
|
-
.toString()
|
|
512
|
-
.split('')
|
|
513
|
-
.reduce((h, c) => (h * 31 + c.charCodeAt(0)) | 0, 0))) |
|
|
453
|
+
hash = (hash * 31 +
|
|
454
|
+
(Number.isInteger(this.id) ? this.id | 0 : this.id
|
|
455
|
+
.toString()
|
|
456
|
+
.split('')
|
|
457
|
+
.reduce((h, c) => (h * 31 + c.charCodeAt(0)) | 0, 0))) |
|
|
458
|
+
0;
|
|
459
|
+
hash = (hash * 31 +
|
|
460
|
+
(this.name ?? '').split('').reduce(
|
|
461
|
+
(h, c) => (h * 31 + c.charCodeAt(0)) | 0,
|
|
462
|
+
0
|
|
463
|
+
)) |
|
|
464
|
+
0;
|
|
465
|
+
hash = (hash * 31 +
|
|
466
|
+
(Number.isInteger(this.cachedScore) ? this.cachedScore | 0 : this.cachedScore
|
|
467
|
+
.toString()
|
|
468
|
+
.split('')
|
|
469
|
+
.reduce((h, c) => (h * 31 + c.charCodeAt(0)) | 0, 0))) |
|
|
514
470
|
0;
|
|
515
471
|
return hash;
|
|
516
472
|
}
|
|
@@ -523,4 +479,4 @@ When implementing `PartialEq`, consider also implementing `Hash`:
|
|
|
523
479
|
|
|
524
480
|
- **Reflexivity**: `a.equals(a)` is always true
|
|
525
481
|
- **Symmetry**: `a.equals(b)` implies `b.equals(a)`
|
|
526
|
-
- **Hash consistency**: Equal objects must have equal hash codes
|
|
482
|
+
- **Hash consistency**: Equal objects must have equal hash codes
|