mahjong-seatings-rs-node 1.1.0 → 2.0.0

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.
@@ -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;
@@ -183,8 +183,8 @@ module.exports.make_seating_shuffled = function(val) {
183
183
  * @param {any} val
184
184
  * @returns {any}
185
185
  */
186
- module.exports.make_seating_interval = function(val) {
187
- const ret = wasm.make_seating_interval(val);
186
+ module.exports.make_seating_swiss = function(val) {
187
+ const ret = wasm.make_seating_swiss(val);
188
188
  return ret;
189
189
  };
190
190
 
@@ -192,8 +192,8 @@ module.exports.make_seating_interval = function(val) {
192
192
  * @param {any} val
193
193
  * @returns {any}
194
194
  */
195
- module.exports.make_seating_swiss = function(val) {
196
- const ret = wasm.make_seating_swiss(val);
195
+ module.exports.make_seating_interval = function(val) {
196
+ const ret = wasm.make_seating_interval(val);
197
197
  return ret;
198
198
  };
199
199
 
@@ -220,6 +220,11 @@ module.exports.__wbg_done_769e5ede4b31c67b = function(arg0) {
220
220
  return ret;
221
221
  };
222
222
 
223
+ module.exports.__wbg_entries_3265d4158b33e5dc = function(arg0) {
224
+ const ret = Object.entries(arg0);
225
+ return ret;
226
+ };
227
+
223
228
  module.exports.__wbg_get_67b2ba62fc30de12 = function() { return handleError(function (arg0, arg1) {
224
229
  const ret = Reflect.get(arg0, arg1);
225
230
  return ret;
@@ -392,6 +397,11 @@ module.exports.__wbindgen_is_object = function(arg0) {
392
397
  return ret;
393
398
  };
394
399
 
400
+ module.exports.__wbindgen_is_string = function(arg0) {
401
+ const ret = typeof(arg0) === 'string';
402
+ return ret;
403
+ };
404
+
395
405
  module.exports.__wbindgen_is_undefined = function(arg0) {
396
406
  const ret = arg0 === undefined;
397
407
  return ret;
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.1.0",
6
+ "version": "2.0.0",
7
7
  "files": [
8
8
  "mahjong_seatings_rs_node.js",
9
9
  "mahjong_seatings_rs.d.ts",