mahjong-seatings-rs-node 2.0.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.js +307 -363
- package/mahjong_seatings_rs_bg.wasm +0 -0
- package/mahjong_seatings_rs_node.mjs +38 -0
- package/package.json +9 -2
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.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,303 +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_shuffled = function(val) {
|
|
178
|
-
const ret = wasm.make_seating_shuffled(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_interval = function(val) {
|
|
196
|
-
const ret = wasm.make_seating_interval(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
|
-
|
|
218
|
-
module.exports.__wbg_done_769e5ede4b31c67b = function(arg0) {
|
|
219
|
-
const ret = arg0.done;
|
|
220
|
-
return ret;
|
|
221
|
-
};
|
|
222
311
|
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
return ret;
|
|
231
|
-
}, arguments) };
|
|
232
|
-
|
|
233
|
-
module.exports.__wbg_get_b9b93047fe3cf45b = function(arg0, arg1) {
|
|
234
|
-
const ret = arg0[arg1 >>> 0];
|
|
235
|
-
return ret;
|
|
236
|
-
};
|
|
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
|
+
}
|
|
237
319
|
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
};
|
|
320
|
+
function getStringFromWasm0(ptr, len) {
|
|
321
|
+
return decodeText(ptr >>> 0, len);
|
|
322
|
+
}
|
|
242
323
|
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
} catch (_) {
|
|
248
|
-
result = false;
|
|
324
|
+
let cachedUint8ArrayMemory0 = null;
|
|
325
|
+
function getUint8ArrayMemory0() {
|
|
326
|
+
if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
|
|
327
|
+
cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
|
|
249
328
|
}
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
};
|
|
329
|
+
return cachedUint8ArrayMemory0;
|
|
330
|
+
}
|
|
253
331
|
|
|
254
|
-
|
|
255
|
-
let result;
|
|
332
|
+
function handleError(f, args) {
|
|
256
333
|
try {
|
|
257
|
-
|
|
258
|
-
} catch (
|
|
259
|
-
|
|
334
|
+
return f.apply(this, args);
|
|
335
|
+
} catch (e) {
|
|
336
|
+
const idx = addToExternrefTable0(e);
|
|
337
|
+
wasm.__wbindgen_exn_store(idx);
|
|
260
338
|
}
|
|
261
|
-
|
|
262
|
-
return ret;
|
|
263
|
-
};
|
|
264
|
-
|
|
265
|
-
module.exports.__wbg_isArray_a1eab7e0d067391b = function(arg0) {
|
|
266
|
-
const ret = Array.isArray(arg0);
|
|
267
|
-
return ret;
|
|
268
|
-
};
|
|
269
|
-
|
|
270
|
-
module.exports.__wbg_isSafeInteger_343e2beeeece1bb0 = function(arg0) {
|
|
271
|
-
const ret = Number.isSafeInteger(arg0);
|
|
272
|
-
return ret;
|
|
273
|
-
};
|
|
274
|
-
|
|
275
|
-
module.exports.__wbg_iterator_9a24c88df860dc65 = function() {
|
|
276
|
-
const ret = Symbol.iterator;
|
|
277
|
-
return ret;
|
|
278
|
-
};
|
|
279
|
-
|
|
280
|
-
module.exports.__wbg_length_a446193dc22c12f8 = function(arg0) {
|
|
281
|
-
const ret = arg0.length;
|
|
282
|
-
return ret;
|
|
283
|
-
};
|
|
284
|
-
|
|
285
|
-
module.exports.__wbg_length_e2d2a49132c1b256 = function(arg0) {
|
|
286
|
-
const ret = arg0.length;
|
|
287
|
-
return ret;
|
|
288
|
-
};
|
|
289
|
-
|
|
290
|
-
module.exports.__wbg_new_405e22f390576ce2 = function() {
|
|
291
|
-
const ret = new Object();
|
|
292
|
-
return ret;
|
|
293
|
-
};
|
|
294
|
-
|
|
295
|
-
module.exports.__wbg_new_78feb108b6472713 = function() {
|
|
296
|
-
const ret = new Array();
|
|
297
|
-
return ret;
|
|
298
|
-
};
|
|
299
|
-
|
|
300
|
-
module.exports.__wbg_new_a12002a7f91c75be = function(arg0) {
|
|
301
|
-
const ret = new Uint8Array(arg0);
|
|
302
|
-
return ret;
|
|
303
|
-
};
|
|
304
|
-
|
|
305
|
-
module.exports.__wbg_next_25feadfc0913fea9 = function(arg0) {
|
|
306
|
-
const ret = arg0.next;
|
|
307
|
-
return ret;
|
|
308
|
-
};
|
|
309
|
-
|
|
310
|
-
module.exports.__wbg_next_6574e1a8a62d1055 = function() { return handleError(function (arg0) {
|
|
311
|
-
const ret = arg0.next();
|
|
312
|
-
return ret;
|
|
313
|
-
}, arguments) };
|
|
314
|
-
|
|
315
|
-
module.exports.__wbg_set_37837023f3d740e8 = function(arg0, arg1, arg2) {
|
|
316
|
-
arg0[arg1 >>> 0] = arg2;
|
|
317
|
-
};
|
|
318
|
-
|
|
319
|
-
module.exports.__wbg_set_3f1d0b984ed272ed = function(arg0, arg1, arg2) {
|
|
320
|
-
arg0[arg1] = arg2;
|
|
321
|
-
};
|
|
322
|
-
|
|
323
|
-
module.exports.__wbg_set_65595bdd868b3009 = function(arg0, arg1, arg2) {
|
|
324
|
-
arg0.set(arg1, arg2 >>> 0);
|
|
325
|
-
};
|
|
326
|
-
|
|
327
|
-
module.exports.__wbg_value_cd1ffa7b1ab794f1 = function(arg0) {
|
|
328
|
-
const ret = arg0.value;
|
|
329
|
-
return ret;
|
|
330
|
-
};
|
|
331
|
-
|
|
332
|
-
module.exports.__wbindgen_as_number = function(arg0) {
|
|
333
|
-
const ret = +arg0;
|
|
334
|
-
return ret;
|
|
335
|
-
};
|
|
336
|
-
|
|
337
|
-
module.exports.__wbindgen_bigint_from_u64 = function(arg0) {
|
|
338
|
-
const ret = BigInt.asUintN(64, arg0);
|
|
339
|
-
return ret;
|
|
340
|
-
};
|
|
341
|
-
|
|
342
|
-
module.exports.__wbindgen_bigint_get_as_i64 = function(arg0, arg1) {
|
|
343
|
-
const v = arg1;
|
|
344
|
-
const ret = typeof(v) === 'bigint' ? v : undefined;
|
|
345
|
-
getDataViewMemory0().setBigInt64(arg0 + 8 * 1, isLikeNone(ret) ? BigInt(0) : ret, true);
|
|
346
|
-
getDataViewMemory0().setInt32(arg0 + 4 * 0, !isLikeNone(ret), true);
|
|
347
|
-
};
|
|
348
|
-
|
|
349
|
-
module.exports.__wbindgen_boolean_get = function(arg0) {
|
|
350
|
-
const v = arg0;
|
|
351
|
-
const ret = typeof(v) === 'boolean' ? (v ? 1 : 0) : 2;
|
|
352
|
-
return ret;
|
|
353
|
-
};
|
|
354
|
-
|
|
355
|
-
module.exports.__wbindgen_debug_string = function(arg0, arg1) {
|
|
356
|
-
const ret = debugString(arg1);
|
|
357
|
-
const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
358
|
-
const len1 = WASM_VECTOR_LEN;
|
|
359
|
-
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
360
|
-
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
361
|
-
};
|
|
362
|
-
|
|
363
|
-
module.exports.__wbindgen_error_new = function(arg0, arg1) {
|
|
364
|
-
const ret = new Error(getStringFromWasm0(arg0, arg1));
|
|
365
|
-
return ret;
|
|
366
|
-
};
|
|
367
|
-
|
|
368
|
-
module.exports.__wbindgen_in = function(arg0, arg1) {
|
|
369
|
-
const ret = arg0 in arg1;
|
|
370
|
-
return ret;
|
|
371
|
-
};
|
|
372
|
-
|
|
373
|
-
module.exports.__wbindgen_init_externref_table = function() {
|
|
374
|
-
const table = wasm.__wbindgen_export_4;
|
|
375
|
-
const offset = table.grow(4);
|
|
376
|
-
table.set(0, undefined);
|
|
377
|
-
table.set(offset + 0, undefined);
|
|
378
|
-
table.set(offset + 1, null);
|
|
379
|
-
table.set(offset + 2, true);
|
|
380
|
-
table.set(offset + 3, false);
|
|
381
|
-
;
|
|
382
|
-
};
|
|
383
|
-
|
|
384
|
-
module.exports.__wbindgen_is_bigint = function(arg0) {
|
|
385
|
-
const ret = typeof(arg0) === 'bigint';
|
|
386
|
-
return ret;
|
|
387
|
-
};
|
|
388
|
-
|
|
389
|
-
module.exports.__wbindgen_is_function = function(arg0) {
|
|
390
|
-
const ret = typeof(arg0) === 'function';
|
|
391
|
-
return ret;
|
|
392
|
-
};
|
|
393
|
-
|
|
394
|
-
module.exports.__wbindgen_is_object = function(arg0) {
|
|
395
|
-
const val = arg0;
|
|
396
|
-
const ret = typeof(val) === 'object' && val !== null;
|
|
397
|
-
return ret;
|
|
398
|
-
};
|
|
339
|
+
}
|
|
399
340
|
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
};
|
|
341
|
+
function isLikeNone(x) {
|
|
342
|
+
return x === undefined || x === null;
|
|
343
|
+
}
|
|
404
344
|
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
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
|
+
}
|
|
409
353
|
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
return ret;
|
|
413
|
-
};
|
|
354
|
+
let len = arg.length;
|
|
355
|
+
let ptr = malloc(len, 1) >>> 0;
|
|
414
356
|
|
|
415
|
-
|
|
416
|
-
const ret = arg0 == arg1;
|
|
417
|
-
return ret;
|
|
418
|
-
};
|
|
357
|
+
const mem = getUint8ArrayMemory0();
|
|
419
358
|
|
|
420
|
-
|
|
421
|
-
const ret = wasm.memory;
|
|
422
|
-
return ret;
|
|
423
|
-
};
|
|
359
|
+
let offset = 0;
|
|
424
360
|
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
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);
|
|
431
373
|
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
};
|
|
374
|
+
offset += ret.written;
|
|
375
|
+
ptr = realloc(ptr, len, offset, 1) >>> 0;
|
|
376
|
+
}
|
|
436
377
|
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
441
|
-
var len1 = WASM_VECTOR_LEN;
|
|
442
|
-
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
443
|
-
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
444
|
-
};
|
|
378
|
+
WASM_VECTOR_LEN = offset;
|
|
379
|
+
return ptr;
|
|
380
|
+
}
|
|
445
381
|
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
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
|
+
}
|
|
450
387
|
|
|
451
|
-
|
|
452
|
-
throw new Error(getStringFromWasm0(arg0, arg1));
|
|
453
|
-
};
|
|
388
|
+
const cachedTextEncoder = new TextEncoder();
|
|
454
389
|
|
|
455
|
-
|
|
456
|
-
|
|
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
|
+
}
|
|
457
400
|
|
|
458
|
-
|
|
459
|
-
const wasmInstance = new WebAssembly.Instance(wasmModule, imports);
|
|
460
|
-
wasm = wasmInstance.exports;
|
|
461
|
-
module.exports.__wasm = wasm;
|
|
401
|
+
let WASM_VECTOR_LEN = 0;
|
|
462
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;
|
|
463
408
|
wasm.__wbindgen_start();
|
|
464
|
-
|
|
Binary file
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import orig from "./mahjong_seatings_rs.js";
|
|
2
|
+
|
|
3
|
+
export function make_seating_shuffled(val) {
|
|
4
|
+
const input = {
|
|
5
|
+
players_map: Object.entries(val.playersMap).map(([k, v]) => [
|
|
6
|
+
parseInt(k.toString(), 10),
|
|
7
|
+
v,
|
|
8
|
+
]),
|
|
9
|
+
previous_seatings: val.previousSeatings,
|
|
10
|
+
groups_count: val.groupsCount,
|
|
11
|
+
rand_factor: val.randFactor,
|
|
12
|
+
};
|
|
13
|
+
return orig.make_seating_shuffled(input).result;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export function make_seating_interval(val) {
|
|
17
|
+
const input = {
|
|
18
|
+
players_map: Object.entries(val.playersMap).map(([k, v]) => [
|
|
19
|
+
parseInt(k.toString(), 10),
|
|
20
|
+
v,
|
|
21
|
+
]),
|
|
22
|
+
step: val.step,
|
|
23
|
+
rand_factor: val.randFactor,
|
|
24
|
+
};
|
|
25
|
+
return orig.make_seating_interval(input).result;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export function make_seating_swiss(val) {
|
|
29
|
+
const input = {
|
|
30
|
+
players_map: Object.entries(val.playersMap).map(([k, v]) => [
|
|
31
|
+
parseInt(k.toString(), 10),
|
|
32
|
+
v,
|
|
33
|
+
]),
|
|
34
|
+
previous_seatings: val.previousSeatings,
|
|
35
|
+
rand_factor: val.randFactor,
|
|
36
|
+
};
|
|
37
|
+
return orig.make_seating_swiss(input).result;
|
|
38
|
+
}
|
package/package.json
CHANGED
|
@@ -3,13 +3,20 @@
|
|
|
3
3
|
"collaborators": [
|
|
4
4
|
"Oleg Klimenko <me@ctizen.dev>"
|
|
5
5
|
],
|
|
6
|
-
"version": "2.0.
|
|
6
|
+
"version": "2.0.1",
|
|
7
7
|
"files": [
|
|
8
8
|
"mahjong_seatings_rs_node.js",
|
|
9
|
+
"mahjong_seatings_rs_node.mjs",
|
|
9
10
|
"mahjong_seatings_rs.d.ts",
|
|
10
11
|
"mahjong_seatings_rs_bg.wasm",
|
|
11
12
|
"mahjong_seatings_rs.js"
|
|
12
13
|
],
|
|
13
14
|
"main": "mahjong_seatings_rs_node.js",
|
|
14
|
-
"types": "mahjong_seatings_rs.d.ts"
|
|
15
|
+
"types": "mahjong_seatings_rs.d.ts",
|
|
16
|
+
"exports": {
|
|
17
|
+
".": {
|
|
18
|
+
"types": "./mahjong_seatings_rs.d.ts",
|
|
19
|
+
"default": "./mahjong_seatings_rs_node.mjs"
|
|
20
|
+
}
|
|
21
|
+
}
|
|
15
22
|
}
|