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 CHANGED
@@ -9,59 +9,79 @@ wasm, node version.
9
9
  - Invoke function as follows:
10
10
 
11
11
  ```typescript
12
- const {make_seating_shuffled, make_seating_interval, make_seating_swiss} = require("mahjong-seatings-rs-node");
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('Shuffled seating', make_seating_shuffled({
15
- playersMap: {
16
- '1': 1500,
17
- '2': 1500,
18
- '3': 1500,
19
- '4': 1500,
20
- '5': 1500,
21
- '6': 1500,
22
- '7': 1500,
23
- '8': 1500,
24
- },
25
- previousSeatings: [
26
- [1, 2, 3, 4],
27
- [5, 6, 7, 8],
28
- ],
29
- groupsCount: 1,
30
- randFactor: 1234455,
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('Interval seating', make_seating_interval({
34
- playersMap: {
35
- '1': 1510,
36
- '2': 1508,
37
- '3': 1506,
38
- '4': 1504,
39
- '5': 1496,
40
- '6': 1494,
41
- '7': 1492,
42
- '8': 1490,
43
- },
44
- step: 2,
45
- randFactor: 1234455,
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('Swiss seating', make_seating_swiss({
49
- playersMap: {
50
- '1': 1510,
51
- '2': 1508,
52
- '3': 1506,
53
- '4': 1504,
54
- '5': 1496,
55
- '6': 1494,
56
- '7': 1492,
57
- '8': 1490,
58
- },
59
- previousSeatings: [
60
- [1, 2, 3, 4],
61
- [5, 6, 7, 8],
62
- ],
63
- randFactor: 1234455,
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
@@ -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
- playersMap: PlayersMap,
6
- previousSeatings: number[][],
7
- groupsCount: number,
8
- randFactor: number,
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
- playersMap: PlayersMap,
13
- step: number,
14
- randFactor: number,
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
- playersMap: PlayersMap,
19
- previousSeatings: number[][],
20
- randFactor: number,
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;
@@ -1,102 +1,244 @@
1
-
2
- let imports = {};
3
- imports['__wbindgen_placeholder__'] = module.exports;
4
- let wasm;
5
- const { TextEncoder, TextDecoder } = require(`util`);
6
-
7
- let WASM_VECTOR_LEN = 0;
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
- let cachedTextEncoder = new TextEncoder('utf-8');
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
- const encodeString = (typeof cachedTextEncoder.encodeInto === 'function'
21
- ? function (arg, view) {
22
- return cachedTextEncoder.encodeInto(arg, view);
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
- : function (arg, view) {
25
- const buf = cachedTextEncoder.encode(arg);
26
- view.set(buf);
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
- read: arg.length,
29
- written: buf.length
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.__wbindgen_export_4.set(idx, obj);
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
- let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
166
-
167
- cachedTextDecoder.decode();
168
-
169
- function getStringFromWasm0(ptr, len) {
307
+ function getArrayU8FromWasm0(ptr, len) {
170
308
  ptr = ptr >>> 0;
171
- return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
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
- module.exports.__wbg_done_769e5ede4b31c67b = function(arg0) {
219
- const ret = arg0.done;
220
- return ret;
221
- };
222
-
223
- module.exports.__wbg_get_67b2ba62fc30de12 = function() { return handleError(function (arg0, arg1) {
224
- const ret = Reflect.get(arg0, arg1);
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
- module.exports.__wbg_getwithrefkey_1dc361bd10053bfe = function(arg0, arg1) {
234
- const ret = arg0[arg1];
235
- return ret;
236
- };
320
+ function getStringFromWasm0(ptr, len) {
321
+ return decodeText(ptr >>> 0, len);
322
+ }
237
323
 
238
- module.exports.__wbg_instanceof_ArrayBuffer_e14585432e3737fc = function(arg0) {
239
- let result;
240
- try {
241
- result = arg0 instanceof ArrayBuffer;
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
- const ret = result;
246
- return ret;
247
- };
329
+ return cachedUint8ArrayMemory0;
330
+ }
248
331
 
249
- module.exports.__wbg_instanceof_Uint8Array_17156bcf118086a9 = function(arg0) {
250
- let result;
332
+ function handleError(f, args) {
251
333
  try {
252
- result = arg0 instanceof Uint8Array;
253
- } catch (_) {
254
- result = false;
334
+ return f.apply(this, args);
335
+ } catch (e) {
336
+ const idx = addToExternrefTable0(e);
337
+ wasm.__wbindgen_exn_store(idx);
255
338
  }
256
- const ret = result;
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
- module.exports.__wbindgen_is_object = function(arg0) {
390
- const val = arg0;
391
- const ret = typeof(val) === 'object' && val !== null;
392
- return ret;
393
- };
341
+ function isLikeNone(x) {
342
+ return x === undefined || x === null;
343
+ }
394
344
 
395
- module.exports.__wbindgen_is_undefined = function(arg0) {
396
- const ret = arg0 === undefined;
397
- return ret;
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
- module.exports.__wbindgen_jsval_eq = function(arg0, arg1) {
401
- const ret = arg0 === arg1;
402
- return ret;
403
- };
354
+ let len = arg.length;
355
+ let ptr = malloc(len, 1) >>> 0;
404
356
 
405
- module.exports.__wbindgen_jsval_loose_eq = function(arg0, arg1) {
406
- const ret = arg0 == arg1;
407
- return ret;
408
- };
357
+ const mem = getUint8ArrayMemory0();
409
358
 
410
- module.exports.__wbindgen_memory = function() {
411
- const ret = wasm.memory;
412
- return ret;
413
- };
359
+ let offset = 0;
414
360
 
415
- module.exports.__wbindgen_number_get = function(arg0, arg1) {
416
- const obj = arg1;
417
- const ret = typeof(obj) === 'number' ? obj : undefined;
418
- getDataViewMemory0().setFloat64(arg0 + 8 * 1, isLikeNone(ret) ? 0 : ret, true);
419
- getDataViewMemory0().setInt32(arg0 + 4 * 0, !isLikeNone(ret), true);
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
- module.exports.__wbindgen_number_new = function(arg0) {
423
- const ret = arg0;
424
- return ret;
425
- };
374
+ offset += ret.written;
375
+ ptr = realloc(ptr, len, offset, 1) >>> 0;
376
+ }
426
377
 
427
- module.exports.__wbindgen_string_get = function(arg0, arg1) {
428
- const obj = arg1;
429
- const ret = typeof(obj) === 'string' ? obj : undefined;
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
- module.exports.__wbindgen_string_new = function(arg0, arg1) {
437
- const ret = getStringFromWasm0(arg0, arg1);
438
- return ret;
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
- module.exports.__wbindgen_throw = function(arg0, arg1) {
442
- throw new Error(getStringFromWasm0(arg0, arg1));
443
- };
388
+ const cachedTextEncoder = new TextEncoder();
444
389
 
445
- const path = require('path').join(__dirname, 'mahjong_seatings_rs_bg.wasm');
446
- const bytes = require('fs').readFileSync(path);
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
- const wasmModule = new WebAssembly.Module(bytes);
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('./mahjong_seatings_rs.js');
1
+ const orig = require("./mahjong_seatings_rs.js");
2
2
 
3
3
  module.exports = {
4
- make_seating_shuffled: function (val) {
5
- const input = {
6
- players_map: Object.entries(val.playersMap).map(([k, v]) => [parseInt(k.toString(), 10), v]),
7
- previous_seatings: val.previousSeatings,
8
- groups_count: val.groupsCount,
9
- rand_factor: val.randFactor,
10
- };
11
- return orig.make_seating_shuffled(input).result;
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
- make_seating_interval: function (val) {
15
- const input = {
16
- players_map: Object.entries(val.playersMap).map(([k, v]) => [parseInt(k.toString(), 10), v]),
17
- step: val.step,
18
- rand_factor: val.randFactor,
19
- };
20
- return orig.make_seating_interval(input).result;
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
- make_seating_swiss: function (val) {
24
- const input = {
25
- players_map: Object.entries(val.playersMap).map(([k, v]) => [parseInt(k.toString(), 10), v]),
26
- previous_seatings: val.previousSeatings,
27
- rand_factor: val.randFactor,
28
- };
29
- return orig.make_seating_swiss(input).result;
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
+ };
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "collaborators": [
4
4
  "Oleg Klimenko <me@ctizen.dev>"
5
5
  ],
6
- "version": "1.2.0",
6
+ "version": "2.0.1",
7
7
  "files": [
8
8
  "mahjong_seatings_rs_node.js",
9
9
  "mahjong_seatings_rs_node.mjs",