mahjong-seatings-rs-node 1.2.0 → 2.0.1
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 +70 -50
- package/mahjong_seatings_rs.d.ts +22 -14
- package/mahjong_seatings_rs.js +307 -353
- package/mahjong_seatings_rs_bg.wasm +0 -0
- package/mahjong_seatings_rs_node.js +40 -27
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -9,59 +9,79 @@ wasm, node version.
|
|
|
9
9
|
- Invoke function as follows:
|
|
10
10
|
|
|
11
11
|
```typescript
|
|
12
|
-
const {
|
|
12
|
+
const {
|
|
13
|
+
make_seating_shuffled,
|
|
14
|
+
make_seating_interval,
|
|
15
|
+
make_seating_swiss,
|
|
16
|
+
} = require("mahjong-seatings-rs-node");
|
|
13
17
|
|
|
14
|
-
console.log(
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
[
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
18
|
+
console.log(
|
|
19
|
+
"Shuffled seating",
|
|
20
|
+
make_seating_shuffled({
|
|
21
|
+
playersMap: {
|
|
22
|
+
"1": 1500,
|
|
23
|
+
"2": 1500,
|
|
24
|
+
"3": 1500,
|
|
25
|
+
"4": 1500,
|
|
26
|
+
"5": 1500,
|
|
27
|
+
"6": 1500,
|
|
28
|
+
"7": 1500,
|
|
29
|
+
"8": 1500,
|
|
30
|
+
},
|
|
31
|
+
previousSeatings: [
|
|
32
|
+
[1, 2, 3, 4],
|
|
33
|
+
[5, 6, 7, 8],
|
|
34
|
+
],
|
|
35
|
+
groupsCount: 1,
|
|
36
|
+
randFactor: 1234455,
|
|
37
|
+
windShuffle: 0, // 0 == WindShuffle::Random, 1 == WindShuffle::Balanced
|
|
38
|
+
}),
|
|
39
|
+
);
|
|
32
40
|
|
|
33
|
-
console.log(
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
41
|
+
console.log(
|
|
42
|
+
"Interval seating",
|
|
43
|
+
make_seating_interval({
|
|
44
|
+
playersMap: {
|
|
45
|
+
"1": 1510,
|
|
46
|
+
"2": 1508,
|
|
47
|
+
"3": 1506,
|
|
48
|
+
"4": 1504,
|
|
49
|
+
"5": 1496,
|
|
50
|
+
"6": 1494,
|
|
51
|
+
"7": 1492,
|
|
52
|
+
"8": 1490,
|
|
53
|
+
},
|
|
54
|
+
previousSeatings: [
|
|
55
|
+
[1, 2, 3, 4],
|
|
56
|
+
[5, 6, 7, 8],
|
|
57
|
+
],
|
|
58
|
+
step: 2,
|
|
59
|
+
randFactor: 1234455,
|
|
60
|
+
windShuffle: 0, // 0 == WindShuffle::Random, 1 == WindShuffle::Balanced
|
|
61
|
+
}),
|
|
62
|
+
);
|
|
47
63
|
|
|
48
|
-
console.log(
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
[
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
64
|
+
console.log(
|
|
65
|
+
"Swiss seating",
|
|
66
|
+
make_seating_swiss({
|
|
67
|
+
playersMap: {
|
|
68
|
+
"1": 1510,
|
|
69
|
+
"2": 1508,
|
|
70
|
+
"3": 1506,
|
|
71
|
+
"4": 1504,
|
|
72
|
+
"5": 1496,
|
|
73
|
+
"6": 1494,
|
|
74
|
+
"7": 1492,
|
|
75
|
+
"8": 1490,
|
|
76
|
+
},
|
|
77
|
+
previousSeatings: [
|
|
78
|
+
[1, 2, 3, 4],
|
|
79
|
+
[5, 6, 7, 8],
|
|
80
|
+
],
|
|
81
|
+
randFactor: 1234455,
|
|
82
|
+
windShuffle: 0, // 0 == WindShuffle::Random, 1 == WindShuffle::Balanced
|
|
83
|
+
}),
|
|
84
|
+
);
|
|
65
85
|
```
|
|
66
86
|
|
|
67
87
|
Note that returned lists contain player ids and their rating. First four elements are first table, next four are second table, etc.## Riichi-rs-node
|
package/mahjong_seatings_rs.d.ts
CHANGED
|
@@ -1,25 +1,33 @@
|
|
|
1
1
|
export type PlayersMap = Record<string | number, number>;
|
|
2
2
|
export type Seating = Array<[number, number]>;
|
|
3
|
+
export const enum WindShuffle {
|
|
4
|
+
Random = 0,
|
|
5
|
+
Balanced = 1,
|
|
6
|
+
Prescripted = 2,
|
|
7
|
+
}
|
|
3
8
|
|
|
4
9
|
export type ShuffledSeatingInput = {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
+
playersMap: PlayersMap;
|
|
11
|
+
previousSeatings: number[][];
|
|
12
|
+
groupsCount: number;
|
|
13
|
+
randFactor: number;
|
|
14
|
+
windShuffle: WindShuffle;
|
|
15
|
+
};
|
|
10
16
|
|
|
11
17
|
export type IntervalSeatingInput = {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
18
|
+
playersMap: PlayersMap;
|
|
19
|
+
previousSeatings: number[][];
|
|
20
|
+
step: number;
|
|
21
|
+
randFactor: number;
|
|
22
|
+
windShuffle: WindShuffle;
|
|
23
|
+
};
|
|
16
24
|
|
|
17
25
|
export type SwissSeatingInput = {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
26
|
+
playersMap: PlayersMap;
|
|
27
|
+
previousSeatings: number[][];
|
|
28
|
+
randFactor: number;
|
|
29
|
+
windShuffle: WindShuffle;
|
|
30
|
+
};
|
|
23
31
|
|
|
24
32
|
export function make_seating_shuffled(val: ShuffledSeatingInput): Seating;
|
|
25
33
|
export function make_seating_interval(val: IntervalSeatingInput): Seating;
|
package/mahjong_seatings_rs.js
CHANGED
|
@@ -1,102 +1,244 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
let cachedUint8ArrayMemory0 = null;
|
|
10
|
-
|
|
11
|
-
function getUint8ArrayMemory0() {
|
|
12
|
-
if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
|
|
13
|
-
cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
|
|
14
|
-
}
|
|
15
|
-
return cachedUint8ArrayMemory0;
|
|
1
|
+
/**
|
|
2
|
+
* @param {any} val
|
|
3
|
+
* @returns {any}
|
|
4
|
+
*/
|
|
5
|
+
function make_seating_interval(val) {
|
|
6
|
+
const ret = wasm.make_seating_interval(val);
|
|
7
|
+
return ret;
|
|
16
8
|
}
|
|
9
|
+
exports.make_seating_interval = make_seating_interval;
|
|
17
10
|
|
|
18
|
-
|
|
11
|
+
/**
|
|
12
|
+
* @param {any} val
|
|
13
|
+
* @returns {any}
|
|
14
|
+
*/
|
|
15
|
+
function make_seating_shuffled(val) {
|
|
16
|
+
const ret = wasm.make_seating_shuffled(val);
|
|
17
|
+
return ret;
|
|
18
|
+
}
|
|
19
|
+
exports.make_seating_shuffled = make_seating_shuffled;
|
|
19
20
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
21
|
+
/**
|
|
22
|
+
* @param {any} val
|
|
23
|
+
* @returns {any}
|
|
24
|
+
*/
|
|
25
|
+
function make_seating_swiss(val) {
|
|
26
|
+
const ret = wasm.make_seating_swiss(val);
|
|
27
|
+
return ret;
|
|
23
28
|
}
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
29
|
+
exports.make_seating_swiss = make_seating_swiss;
|
|
30
|
+
function __wbg_get_imports() {
|
|
31
|
+
const import0 = {
|
|
32
|
+
__proto__: null,
|
|
33
|
+
__wbg_Error_bce6d499ff0a4aff: function(arg0, arg1) {
|
|
34
|
+
const ret = Error(getStringFromWasm0(arg0, arg1));
|
|
35
|
+
return ret;
|
|
36
|
+
},
|
|
37
|
+
__wbg_Number_b7972a139bfbfdf0: function(arg0) {
|
|
38
|
+
const ret = Number(arg0);
|
|
39
|
+
return ret;
|
|
40
|
+
},
|
|
41
|
+
__wbg_String_8564e559799eccda: function(arg0, arg1) {
|
|
42
|
+
const ret = String(arg1);
|
|
43
|
+
const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
44
|
+
const len1 = WASM_VECTOR_LEN;
|
|
45
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
46
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
47
|
+
},
|
|
48
|
+
__wbg___wbindgen_bigint_get_as_i64_410e28c7b761ad83: function(arg0, arg1) {
|
|
49
|
+
const v = arg1;
|
|
50
|
+
const ret = typeof(v) === 'bigint' ? v : undefined;
|
|
51
|
+
getDataViewMemory0().setBigInt64(arg0 + 8 * 1, isLikeNone(ret) ? BigInt(0) : ret, true);
|
|
52
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 0, !isLikeNone(ret), true);
|
|
53
|
+
},
|
|
54
|
+
__wbg___wbindgen_boolean_get_2304fb8c853028c8: function(arg0) {
|
|
55
|
+
const v = arg0;
|
|
56
|
+
const ret = typeof(v) === 'boolean' ? v : undefined;
|
|
57
|
+
return isLikeNone(ret) ? 0xFFFFFF : ret ? 1 : 0;
|
|
58
|
+
},
|
|
59
|
+
__wbg___wbindgen_debug_string_edece8177ad01481: function(arg0, arg1) {
|
|
60
|
+
const ret = debugString(arg1);
|
|
61
|
+
const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
62
|
+
const len1 = WASM_VECTOR_LEN;
|
|
63
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
64
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
65
|
+
},
|
|
66
|
+
__wbg___wbindgen_in_07056af4f902c445: function(arg0, arg1) {
|
|
67
|
+
const ret = arg0 in arg1;
|
|
68
|
+
return ret;
|
|
69
|
+
},
|
|
70
|
+
__wbg___wbindgen_is_bigint_aeae3893f30ed54e: function(arg0) {
|
|
71
|
+
const ret = typeof(arg0) === 'bigint';
|
|
72
|
+
return ret;
|
|
73
|
+
},
|
|
74
|
+
__wbg___wbindgen_is_function_5cd60d5cf78b4eef: function(arg0) {
|
|
75
|
+
const ret = typeof(arg0) === 'function';
|
|
76
|
+
return ret;
|
|
77
|
+
},
|
|
78
|
+
__wbg___wbindgen_is_object_b4593df85baada48: function(arg0) {
|
|
79
|
+
const val = arg0;
|
|
80
|
+
const ret = typeof(val) === 'object' && val !== null;
|
|
81
|
+
return ret;
|
|
82
|
+
},
|
|
83
|
+
__wbg___wbindgen_is_undefined_35bb9f4c7fd651d5: function(arg0) {
|
|
84
|
+
const ret = arg0 === undefined;
|
|
85
|
+
return ret;
|
|
86
|
+
},
|
|
87
|
+
__wbg___wbindgen_jsval_eq_c0ed08b3e0f393b9: function(arg0, arg1) {
|
|
88
|
+
const ret = arg0 === arg1;
|
|
89
|
+
return ret;
|
|
90
|
+
},
|
|
91
|
+
__wbg___wbindgen_jsval_loose_eq_0ad77b7717db155c: function(arg0, arg1) {
|
|
92
|
+
const ret = arg0 == arg1;
|
|
93
|
+
return ret;
|
|
94
|
+
},
|
|
95
|
+
__wbg___wbindgen_number_get_f73a1244370fcc2c: function(arg0, arg1) {
|
|
96
|
+
const obj = arg1;
|
|
97
|
+
const ret = typeof(obj) === 'number' ? obj : undefined;
|
|
98
|
+
getDataViewMemory0().setFloat64(arg0 + 8 * 1, isLikeNone(ret) ? 0 : ret, true);
|
|
99
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 0, !isLikeNone(ret), true);
|
|
100
|
+
},
|
|
101
|
+
__wbg___wbindgen_string_get_d109740c0d18f4d7: function(arg0, arg1) {
|
|
102
|
+
const obj = arg1;
|
|
103
|
+
const ret = typeof(obj) === 'string' ? obj : undefined;
|
|
104
|
+
var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
105
|
+
var len1 = WASM_VECTOR_LEN;
|
|
106
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
107
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
108
|
+
},
|
|
109
|
+
__wbg___wbindgen_throw_9c31b086c2b26051: function(arg0, arg1) {
|
|
110
|
+
throw new Error(getStringFromWasm0(arg0, arg1));
|
|
111
|
+
},
|
|
112
|
+
__wbg_call_13665d9f14390edc: function() { return handleError(function (arg0, arg1) {
|
|
113
|
+
const ret = arg0.call(arg1);
|
|
114
|
+
return ret;
|
|
115
|
+
}, arguments); },
|
|
116
|
+
__wbg_done_54b8da57023b7ed2: function(arg0) {
|
|
117
|
+
const ret = arg0.done;
|
|
118
|
+
return ret;
|
|
119
|
+
},
|
|
120
|
+
__wbg_get_3e9a707ab7d352eb: function() { return handleError(function (arg0, arg1) {
|
|
121
|
+
const ret = Reflect.get(arg0, arg1);
|
|
122
|
+
return ret;
|
|
123
|
+
}, arguments); },
|
|
124
|
+
__wbg_get_unchecked_1dfe6d05ad91d9b7: function(arg0, arg1) {
|
|
125
|
+
const ret = arg0[arg1 >>> 0];
|
|
126
|
+
return ret;
|
|
127
|
+
},
|
|
128
|
+
__wbg_get_with_ref_key_6412cf3094599694: function(arg0, arg1) {
|
|
129
|
+
const ret = arg0[arg1];
|
|
130
|
+
return ret;
|
|
131
|
+
},
|
|
132
|
+
__wbg_instanceof_ArrayBuffer_53db37b06f6b9afe: function(arg0) {
|
|
133
|
+
let result;
|
|
134
|
+
try {
|
|
135
|
+
result = arg0 instanceof ArrayBuffer;
|
|
136
|
+
} catch (_) {
|
|
137
|
+
result = false;
|
|
138
|
+
}
|
|
139
|
+
const ret = result;
|
|
140
|
+
return ret;
|
|
141
|
+
},
|
|
142
|
+
__wbg_instanceof_Uint8Array_abd07d4bd221d50b: function(arg0) {
|
|
143
|
+
let result;
|
|
144
|
+
try {
|
|
145
|
+
result = arg0 instanceof Uint8Array;
|
|
146
|
+
} catch (_) {
|
|
147
|
+
result = false;
|
|
148
|
+
}
|
|
149
|
+
const ret = result;
|
|
150
|
+
return ret;
|
|
151
|
+
},
|
|
152
|
+
__wbg_isArray_94898ed3aad6947b: function(arg0) {
|
|
153
|
+
const ret = Array.isArray(arg0);
|
|
154
|
+
return ret;
|
|
155
|
+
},
|
|
156
|
+
__wbg_isSafeInteger_01e964d144ad3a55: function(arg0) {
|
|
157
|
+
const ret = Number.isSafeInteger(arg0);
|
|
158
|
+
return ret;
|
|
159
|
+
},
|
|
160
|
+
__wbg_iterator_1441b47f341dc34f: function() {
|
|
161
|
+
const ret = Symbol.iterator;
|
|
162
|
+
return ret;
|
|
163
|
+
},
|
|
164
|
+
__wbg_length_2591a0f4f659a55c: function(arg0) {
|
|
165
|
+
const ret = arg0.length;
|
|
166
|
+
return ret;
|
|
167
|
+
},
|
|
168
|
+
__wbg_length_56fcd3e2b7e0299d: function(arg0) {
|
|
169
|
+
const ret = arg0.length;
|
|
170
|
+
return ret;
|
|
171
|
+
},
|
|
172
|
+
__wbg_new_02d162bc6cf02f60: function() {
|
|
173
|
+
const ret = new Object();
|
|
174
|
+
return ret;
|
|
175
|
+
},
|
|
176
|
+
__wbg_new_310879b66b6e95e1: function() {
|
|
177
|
+
const ret = new Array();
|
|
178
|
+
return ret;
|
|
179
|
+
},
|
|
180
|
+
__wbg_new_7ddec6de44ff8f5d: function(arg0) {
|
|
181
|
+
const ret = new Uint8Array(arg0);
|
|
182
|
+
return ret;
|
|
183
|
+
},
|
|
184
|
+
__wbg_next_2a4e19f4f5083b0f: function(arg0) {
|
|
185
|
+
const ret = arg0.next;
|
|
186
|
+
return ret;
|
|
187
|
+
},
|
|
188
|
+
__wbg_next_6429a146bf756f93: function() { return handleError(function (arg0) {
|
|
189
|
+
const ret = arg0.next();
|
|
190
|
+
return ret;
|
|
191
|
+
}, arguments); },
|
|
192
|
+
__wbg_prototypesetcall_5f9bdc8d75e07276: function(arg0, arg1, arg2) {
|
|
193
|
+
Uint8Array.prototype.set.call(getArrayU8FromWasm0(arg0, arg1), arg2);
|
|
194
|
+
},
|
|
195
|
+
__wbg_set_6be42768c690e380: function(arg0, arg1, arg2) {
|
|
196
|
+
arg0[arg1] = arg2;
|
|
197
|
+
},
|
|
198
|
+
__wbg_set_78ea6a19f4818587: function(arg0, arg1, arg2) {
|
|
199
|
+
arg0[arg1 >>> 0] = arg2;
|
|
200
|
+
},
|
|
201
|
+
__wbg_value_9cc0518af87a489c: function(arg0) {
|
|
202
|
+
const ret = arg0.value;
|
|
203
|
+
return ret;
|
|
204
|
+
},
|
|
205
|
+
__wbindgen_cast_0000000000000001: function(arg0) {
|
|
206
|
+
// Cast intrinsic for `F64 -> Externref`.
|
|
207
|
+
const ret = arg0;
|
|
208
|
+
return ret;
|
|
209
|
+
},
|
|
210
|
+
__wbindgen_cast_0000000000000002: function(arg0, arg1) {
|
|
211
|
+
// Cast intrinsic for `Ref(String) -> Externref`.
|
|
212
|
+
const ret = getStringFromWasm0(arg0, arg1);
|
|
213
|
+
return ret;
|
|
214
|
+
},
|
|
215
|
+
__wbindgen_cast_0000000000000003: function(arg0) {
|
|
216
|
+
// Cast intrinsic for `U64 -> Externref`.
|
|
217
|
+
const ret = BigInt.asUintN(64, arg0);
|
|
218
|
+
return ret;
|
|
219
|
+
},
|
|
220
|
+
__wbindgen_init_externref_table: function() {
|
|
221
|
+
const table = wasm.__wbindgen_externrefs;
|
|
222
|
+
const offset = table.grow(4);
|
|
223
|
+
table.set(0, undefined);
|
|
224
|
+
table.set(offset + 0, undefined);
|
|
225
|
+
table.set(offset + 1, null);
|
|
226
|
+
table.set(offset + 2, true);
|
|
227
|
+
table.set(offset + 3, false);
|
|
228
|
+
},
|
|
229
|
+
};
|
|
27
230
|
return {
|
|
28
|
-
|
|
29
|
-
|
|
231
|
+
__proto__: null,
|
|
232
|
+
"./mahjong_seatings_rs_bg.js": import0,
|
|
30
233
|
};
|
|
31
|
-
});
|
|
32
|
-
|
|
33
|
-
function passStringToWasm0(arg, malloc, realloc) {
|
|
34
|
-
|
|
35
|
-
if (realloc === undefined) {
|
|
36
|
-
const buf = cachedTextEncoder.encode(arg);
|
|
37
|
-
const ptr = malloc(buf.length, 1) >>> 0;
|
|
38
|
-
getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
|
|
39
|
-
WASM_VECTOR_LEN = buf.length;
|
|
40
|
-
return ptr;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
let len = arg.length;
|
|
44
|
-
let ptr = malloc(len, 1) >>> 0;
|
|
45
|
-
|
|
46
|
-
const mem = getUint8ArrayMemory0();
|
|
47
|
-
|
|
48
|
-
let offset = 0;
|
|
49
|
-
|
|
50
|
-
for (; offset < len; offset++) {
|
|
51
|
-
const code = arg.charCodeAt(offset);
|
|
52
|
-
if (code > 0x7F) break;
|
|
53
|
-
mem[ptr + offset] = code;
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
if (offset !== len) {
|
|
57
|
-
if (offset !== 0) {
|
|
58
|
-
arg = arg.slice(offset);
|
|
59
|
-
}
|
|
60
|
-
ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
|
|
61
|
-
const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
|
|
62
|
-
const ret = encodeString(arg, view);
|
|
63
|
-
|
|
64
|
-
offset += ret.written;
|
|
65
|
-
ptr = realloc(ptr, len, offset, 1) >>> 0;
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
WASM_VECTOR_LEN = offset;
|
|
69
|
-
return ptr;
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
let cachedDataViewMemory0 = null;
|
|
73
|
-
|
|
74
|
-
function getDataViewMemory0() {
|
|
75
|
-
if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
|
|
76
|
-
cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
|
|
77
|
-
}
|
|
78
|
-
return cachedDataViewMemory0;
|
|
79
234
|
}
|
|
80
235
|
|
|
81
236
|
function addToExternrefTable0(obj) {
|
|
82
237
|
const idx = wasm.__externref_table_alloc();
|
|
83
|
-
wasm.
|
|
238
|
+
wasm.__wbindgen_externrefs.set(idx, obj);
|
|
84
239
|
return idx;
|
|
85
240
|
}
|
|
86
241
|
|
|
87
|
-
function handleError(f, args) {
|
|
88
|
-
try {
|
|
89
|
-
return f.apply(this, args);
|
|
90
|
-
} catch (e) {
|
|
91
|
-
const idx = addToExternrefTable0(e);
|
|
92
|
-
wasm.__wbindgen_exn_store(idx);
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
function isLikeNone(x) {
|
|
97
|
-
return x === undefined || x === null;
|
|
98
|
-
}
|
|
99
|
-
|
|
100
242
|
function debugString(val) {
|
|
101
243
|
// primitive types
|
|
102
244
|
const type = typeof val;
|
|
@@ -162,293 +304,105 @@ function debugString(val) {
|
|
|
162
304
|
return className;
|
|
163
305
|
}
|
|
164
306
|
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
cachedTextDecoder.decode();
|
|
168
|
-
|
|
169
|
-
function getStringFromWasm0(ptr, len) {
|
|
307
|
+
function getArrayU8FromWasm0(ptr, len) {
|
|
170
308
|
ptr = ptr >>> 0;
|
|
171
|
-
return
|
|
309
|
+
return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
|
|
172
310
|
}
|
|
173
|
-
/**
|
|
174
|
-
* @param {any} val
|
|
175
|
-
* @returns {any}
|
|
176
|
-
*/
|
|
177
|
-
module.exports.make_seating_interval = function(val) {
|
|
178
|
-
const ret = wasm.make_seating_interval(val);
|
|
179
|
-
return ret;
|
|
180
|
-
};
|
|
181
|
-
|
|
182
|
-
/**
|
|
183
|
-
* @param {any} val
|
|
184
|
-
* @returns {any}
|
|
185
|
-
*/
|
|
186
|
-
module.exports.make_seating_swiss = function(val) {
|
|
187
|
-
const ret = wasm.make_seating_swiss(val);
|
|
188
|
-
return ret;
|
|
189
|
-
};
|
|
190
|
-
|
|
191
|
-
/**
|
|
192
|
-
* @param {any} val
|
|
193
|
-
* @returns {any}
|
|
194
|
-
*/
|
|
195
|
-
module.exports.make_seating_shuffled = function(val) {
|
|
196
|
-
const ret = wasm.make_seating_shuffled(val);
|
|
197
|
-
return ret;
|
|
198
|
-
};
|
|
199
|
-
|
|
200
|
-
module.exports.__wbg_String_8f0eb39a4a4c2f66 = function(arg0, arg1) {
|
|
201
|
-
const ret = String(arg1);
|
|
202
|
-
const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
203
|
-
const len1 = WASM_VECTOR_LEN;
|
|
204
|
-
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
205
|
-
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
206
|
-
};
|
|
207
|
-
|
|
208
|
-
module.exports.__wbg_buffer_609cc3eee51ed158 = function(arg0) {
|
|
209
|
-
const ret = arg0.buffer;
|
|
210
|
-
return ret;
|
|
211
|
-
};
|
|
212
|
-
|
|
213
|
-
module.exports.__wbg_call_672a4d21634d4a24 = function() { return handleError(function (arg0, arg1) {
|
|
214
|
-
const ret = arg0.call(arg1);
|
|
215
|
-
return ret;
|
|
216
|
-
}, arguments) };
|
|
217
311
|
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
return ret;
|
|
226
|
-
}, arguments) };
|
|
227
|
-
|
|
228
|
-
module.exports.__wbg_get_b9b93047fe3cf45b = function(arg0, arg1) {
|
|
229
|
-
const ret = arg0[arg1 >>> 0];
|
|
230
|
-
return ret;
|
|
231
|
-
};
|
|
312
|
+
let cachedDataViewMemory0 = null;
|
|
313
|
+
function getDataViewMemory0() {
|
|
314
|
+
if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
|
|
315
|
+
cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
|
|
316
|
+
}
|
|
317
|
+
return cachedDataViewMemory0;
|
|
318
|
+
}
|
|
232
319
|
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
};
|
|
320
|
+
function getStringFromWasm0(ptr, len) {
|
|
321
|
+
return decodeText(ptr >>> 0, len);
|
|
322
|
+
}
|
|
237
323
|
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
} catch (_) {
|
|
243
|
-
result = false;
|
|
324
|
+
let cachedUint8ArrayMemory0 = null;
|
|
325
|
+
function getUint8ArrayMemory0() {
|
|
326
|
+
if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
|
|
327
|
+
cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
|
|
244
328
|
}
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
};
|
|
329
|
+
return cachedUint8ArrayMemory0;
|
|
330
|
+
}
|
|
248
331
|
|
|
249
|
-
|
|
250
|
-
let result;
|
|
332
|
+
function handleError(f, args) {
|
|
251
333
|
try {
|
|
252
|
-
|
|
253
|
-
} catch (
|
|
254
|
-
|
|
334
|
+
return f.apply(this, args);
|
|
335
|
+
} catch (e) {
|
|
336
|
+
const idx = addToExternrefTable0(e);
|
|
337
|
+
wasm.__wbindgen_exn_store(idx);
|
|
255
338
|
}
|
|
256
|
-
|
|
257
|
-
return ret;
|
|
258
|
-
};
|
|
259
|
-
|
|
260
|
-
module.exports.__wbg_isArray_a1eab7e0d067391b = function(arg0) {
|
|
261
|
-
const ret = Array.isArray(arg0);
|
|
262
|
-
return ret;
|
|
263
|
-
};
|
|
264
|
-
|
|
265
|
-
module.exports.__wbg_isSafeInteger_343e2beeeece1bb0 = function(arg0) {
|
|
266
|
-
const ret = Number.isSafeInteger(arg0);
|
|
267
|
-
return ret;
|
|
268
|
-
};
|
|
269
|
-
|
|
270
|
-
module.exports.__wbg_iterator_9a24c88df860dc65 = function() {
|
|
271
|
-
const ret = Symbol.iterator;
|
|
272
|
-
return ret;
|
|
273
|
-
};
|
|
274
|
-
|
|
275
|
-
module.exports.__wbg_length_a446193dc22c12f8 = function(arg0) {
|
|
276
|
-
const ret = arg0.length;
|
|
277
|
-
return ret;
|
|
278
|
-
};
|
|
279
|
-
|
|
280
|
-
module.exports.__wbg_length_e2d2a49132c1b256 = function(arg0) {
|
|
281
|
-
const ret = arg0.length;
|
|
282
|
-
return ret;
|
|
283
|
-
};
|
|
284
|
-
|
|
285
|
-
module.exports.__wbg_new_405e22f390576ce2 = function() {
|
|
286
|
-
const ret = new Object();
|
|
287
|
-
return ret;
|
|
288
|
-
};
|
|
289
|
-
|
|
290
|
-
module.exports.__wbg_new_78feb108b6472713 = function() {
|
|
291
|
-
const ret = new Array();
|
|
292
|
-
return ret;
|
|
293
|
-
};
|
|
294
|
-
|
|
295
|
-
module.exports.__wbg_new_a12002a7f91c75be = function(arg0) {
|
|
296
|
-
const ret = new Uint8Array(arg0);
|
|
297
|
-
return ret;
|
|
298
|
-
};
|
|
299
|
-
|
|
300
|
-
module.exports.__wbg_next_25feadfc0913fea9 = function(arg0) {
|
|
301
|
-
const ret = arg0.next;
|
|
302
|
-
return ret;
|
|
303
|
-
};
|
|
304
|
-
|
|
305
|
-
module.exports.__wbg_next_6574e1a8a62d1055 = function() { return handleError(function (arg0) {
|
|
306
|
-
const ret = arg0.next();
|
|
307
|
-
return ret;
|
|
308
|
-
}, arguments) };
|
|
309
|
-
|
|
310
|
-
module.exports.__wbg_set_37837023f3d740e8 = function(arg0, arg1, arg2) {
|
|
311
|
-
arg0[arg1 >>> 0] = arg2;
|
|
312
|
-
};
|
|
313
|
-
|
|
314
|
-
module.exports.__wbg_set_3f1d0b984ed272ed = function(arg0, arg1, arg2) {
|
|
315
|
-
arg0[arg1] = arg2;
|
|
316
|
-
};
|
|
317
|
-
|
|
318
|
-
module.exports.__wbg_set_65595bdd868b3009 = function(arg0, arg1, arg2) {
|
|
319
|
-
arg0.set(arg1, arg2 >>> 0);
|
|
320
|
-
};
|
|
321
|
-
|
|
322
|
-
module.exports.__wbg_value_cd1ffa7b1ab794f1 = function(arg0) {
|
|
323
|
-
const ret = arg0.value;
|
|
324
|
-
return ret;
|
|
325
|
-
};
|
|
326
|
-
|
|
327
|
-
module.exports.__wbindgen_as_number = function(arg0) {
|
|
328
|
-
const ret = +arg0;
|
|
329
|
-
return ret;
|
|
330
|
-
};
|
|
331
|
-
|
|
332
|
-
module.exports.__wbindgen_bigint_from_u64 = function(arg0) {
|
|
333
|
-
const ret = BigInt.asUintN(64, arg0);
|
|
334
|
-
return ret;
|
|
335
|
-
};
|
|
336
|
-
|
|
337
|
-
module.exports.__wbindgen_bigint_get_as_i64 = function(arg0, arg1) {
|
|
338
|
-
const v = arg1;
|
|
339
|
-
const ret = typeof(v) === 'bigint' ? v : undefined;
|
|
340
|
-
getDataViewMemory0().setBigInt64(arg0 + 8 * 1, isLikeNone(ret) ? BigInt(0) : ret, true);
|
|
341
|
-
getDataViewMemory0().setInt32(arg0 + 4 * 0, !isLikeNone(ret), true);
|
|
342
|
-
};
|
|
343
|
-
|
|
344
|
-
module.exports.__wbindgen_boolean_get = function(arg0) {
|
|
345
|
-
const v = arg0;
|
|
346
|
-
const ret = typeof(v) === 'boolean' ? (v ? 1 : 0) : 2;
|
|
347
|
-
return ret;
|
|
348
|
-
};
|
|
349
|
-
|
|
350
|
-
module.exports.__wbindgen_debug_string = function(arg0, arg1) {
|
|
351
|
-
const ret = debugString(arg1);
|
|
352
|
-
const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
353
|
-
const len1 = WASM_VECTOR_LEN;
|
|
354
|
-
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
355
|
-
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
356
|
-
};
|
|
357
|
-
|
|
358
|
-
module.exports.__wbindgen_error_new = function(arg0, arg1) {
|
|
359
|
-
const ret = new Error(getStringFromWasm0(arg0, arg1));
|
|
360
|
-
return ret;
|
|
361
|
-
};
|
|
362
|
-
|
|
363
|
-
module.exports.__wbindgen_in = function(arg0, arg1) {
|
|
364
|
-
const ret = arg0 in arg1;
|
|
365
|
-
return ret;
|
|
366
|
-
};
|
|
367
|
-
|
|
368
|
-
module.exports.__wbindgen_init_externref_table = function() {
|
|
369
|
-
const table = wasm.__wbindgen_export_4;
|
|
370
|
-
const offset = table.grow(4);
|
|
371
|
-
table.set(0, undefined);
|
|
372
|
-
table.set(offset + 0, undefined);
|
|
373
|
-
table.set(offset + 1, null);
|
|
374
|
-
table.set(offset + 2, true);
|
|
375
|
-
table.set(offset + 3, false);
|
|
376
|
-
;
|
|
377
|
-
};
|
|
378
|
-
|
|
379
|
-
module.exports.__wbindgen_is_bigint = function(arg0) {
|
|
380
|
-
const ret = typeof(arg0) === 'bigint';
|
|
381
|
-
return ret;
|
|
382
|
-
};
|
|
383
|
-
|
|
384
|
-
module.exports.__wbindgen_is_function = function(arg0) {
|
|
385
|
-
const ret = typeof(arg0) === 'function';
|
|
386
|
-
return ret;
|
|
387
|
-
};
|
|
339
|
+
}
|
|
388
340
|
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
return ret;
|
|
393
|
-
};
|
|
341
|
+
function isLikeNone(x) {
|
|
342
|
+
return x === undefined || x === null;
|
|
343
|
+
}
|
|
394
344
|
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
345
|
+
function passStringToWasm0(arg, malloc, realloc) {
|
|
346
|
+
if (realloc === undefined) {
|
|
347
|
+
const buf = cachedTextEncoder.encode(arg);
|
|
348
|
+
const ptr = malloc(buf.length, 1) >>> 0;
|
|
349
|
+
getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
|
|
350
|
+
WASM_VECTOR_LEN = buf.length;
|
|
351
|
+
return ptr;
|
|
352
|
+
}
|
|
399
353
|
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
return ret;
|
|
403
|
-
};
|
|
354
|
+
let len = arg.length;
|
|
355
|
+
let ptr = malloc(len, 1) >>> 0;
|
|
404
356
|
|
|
405
|
-
|
|
406
|
-
const ret = arg0 == arg1;
|
|
407
|
-
return ret;
|
|
408
|
-
};
|
|
357
|
+
const mem = getUint8ArrayMemory0();
|
|
409
358
|
|
|
410
|
-
|
|
411
|
-
const ret = wasm.memory;
|
|
412
|
-
return ret;
|
|
413
|
-
};
|
|
359
|
+
let offset = 0;
|
|
414
360
|
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
361
|
+
for (; offset < len; offset++) {
|
|
362
|
+
const code = arg.charCodeAt(offset);
|
|
363
|
+
if (code > 0x7F) break;
|
|
364
|
+
mem[ptr + offset] = code;
|
|
365
|
+
}
|
|
366
|
+
if (offset !== len) {
|
|
367
|
+
if (offset !== 0) {
|
|
368
|
+
arg = arg.slice(offset);
|
|
369
|
+
}
|
|
370
|
+
ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
|
|
371
|
+
const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
|
|
372
|
+
const ret = cachedTextEncoder.encodeInto(arg, view);
|
|
421
373
|
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
};
|
|
374
|
+
offset += ret.written;
|
|
375
|
+
ptr = realloc(ptr, len, offset, 1) >>> 0;
|
|
376
|
+
}
|
|
426
377
|
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
431
|
-
var len1 = WASM_VECTOR_LEN;
|
|
432
|
-
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
433
|
-
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
434
|
-
};
|
|
378
|
+
WASM_VECTOR_LEN = offset;
|
|
379
|
+
return ptr;
|
|
380
|
+
}
|
|
435
381
|
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
382
|
+
let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
|
|
383
|
+
cachedTextDecoder.decode();
|
|
384
|
+
function decodeText(ptr, len) {
|
|
385
|
+
return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
|
|
386
|
+
}
|
|
440
387
|
|
|
441
|
-
|
|
442
|
-
throw new Error(getStringFromWasm0(arg0, arg1));
|
|
443
|
-
};
|
|
388
|
+
const cachedTextEncoder = new TextEncoder();
|
|
444
389
|
|
|
445
|
-
|
|
446
|
-
|
|
390
|
+
if (!('encodeInto' in cachedTextEncoder)) {
|
|
391
|
+
cachedTextEncoder.encodeInto = function (arg, view) {
|
|
392
|
+
const buf = cachedTextEncoder.encode(arg);
|
|
393
|
+
view.set(buf);
|
|
394
|
+
return {
|
|
395
|
+
read: arg.length,
|
|
396
|
+
written: buf.length
|
|
397
|
+
};
|
|
398
|
+
};
|
|
399
|
+
}
|
|
447
400
|
|
|
448
|
-
|
|
449
|
-
const wasmInstance = new WebAssembly.Instance(wasmModule, imports);
|
|
450
|
-
wasm = wasmInstance.exports;
|
|
451
|
-
module.exports.__wasm = wasm;
|
|
401
|
+
let WASM_VECTOR_LEN = 0;
|
|
452
402
|
|
|
403
|
+
const wasmPath = `${__dirname}/mahjong_seatings_rs_bg.wasm`;
|
|
404
|
+
const wasmBytes = require('fs').readFileSync(wasmPath);
|
|
405
|
+
const wasmModule = new WebAssembly.Module(wasmBytes);
|
|
406
|
+
let wasmInstance = new WebAssembly.Instance(wasmModule, __wbg_get_imports());
|
|
407
|
+
let wasm = wasmInstance.exports;
|
|
453
408
|
wasm.__wbindgen_start();
|
|
454
|
-
|
|
Binary file
|
|
@@ -1,31 +1,44 @@
|
|
|
1
|
-
const orig = require(
|
|
1
|
+
const orig = require("./mahjong_seatings_rs.js");
|
|
2
2
|
|
|
3
3
|
module.exports = {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
4
|
+
make_seating_shuffled: function (val) {
|
|
5
|
+
const input = {
|
|
6
|
+
players_map: Object.entries(val.playersMap).map(([k, v]) => [
|
|
7
|
+
parseInt(k.toString(), 10),
|
|
8
|
+
v,
|
|
9
|
+
]),
|
|
10
|
+
previous_seatings: val.previousSeatings,
|
|
11
|
+
groups_count: val.groupsCount,
|
|
12
|
+
rand_factor: val.randFactor,
|
|
13
|
+
wind_shuffle: val.windShuffle,
|
|
14
|
+
};
|
|
15
|
+
return orig.make_seating_shuffled(input).result;
|
|
16
|
+
},
|
|
13
17
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
18
|
+
make_seating_interval: function (val) {
|
|
19
|
+
const input = {
|
|
20
|
+
players_map: Object.entries(val.playersMap).map(([k, v]) => [
|
|
21
|
+
parseInt(k.toString(), 10),
|
|
22
|
+
v,
|
|
23
|
+
]),
|
|
24
|
+
previous_seatings: val.previousSeatings,
|
|
25
|
+
step: val.step,
|
|
26
|
+
rand_factor: val.randFactor,
|
|
27
|
+
wind_shuffle: val.windShuffle,
|
|
28
|
+
};
|
|
29
|
+
return orig.make_seating_interval(input).result;
|
|
30
|
+
},
|
|
22
31
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
+
make_seating_swiss: function (val) {
|
|
33
|
+
const input = {
|
|
34
|
+
players_map: Object.entries(val.playersMap).map(([k, v]) => [
|
|
35
|
+
parseInt(k.toString(), 10),
|
|
36
|
+
v,
|
|
37
|
+
]),
|
|
38
|
+
previous_seatings: val.previousSeatings,
|
|
39
|
+
rand_factor: val.randFactor,
|
|
40
|
+
wind_shuffle: val.windShuffle,
|
|
41
|
+
};
|
|
42
|
+
return orig.make_seating_swiss(input).result;
|
|
43
|
+
},
|
|
44
|
+
};
|