yolkbot 0.1.1-alpha.9 → 0.1.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.
Files changed (41) hide show
  1. package/README.md +2 -2
  2. package/browser/build/global.js +3 -0
  3. package/browser/build/module.js +3 -0
  4. package/package.json +11 -27
  5. package/src/api.js +56 -34
  6. package/src/bot/GamePlayer.js +18 -16
  7. package/src/bot.js +91 -37
  8. package/src/comm/Codes.js +1 -74
  9. package/src/comm/index.js +1 -1
  10. package/src/constants/codes.js +45 -0
  11. package/src/constants/guns.js +18 -2
  12. package/src/constants/index.js +11 -1
  13. package/src/constants/items.js +477 -88
  14. package/src/constants/maps.js +27 -14
  15. package/src/dispatches/BootPlayerDispatch.js +6 -2
  16. package/src/dispatches/ChatDispatch.js +7 -2
  17. package/src/dispatches/GameOptionsDispatch.js +20 -2
  18. package/src/dispatches/MeleeDispatch.js +6 -4
  19. package/src/dispatches/PauseDispatch.js +7 -3
  20. package/src/dispatches/ReloadDispatch.js +5 -2
  21. package/src/dispatches/ReportPlayerDispatch.js +7 -2
  22. package/src/dispatches/SaveLoadoutDispatch.js +11 -6
  23. package/src/dispatches/SpawnDispatch.js +5 -2
  24. package/src/dispatches/SwapWeaponDispatch.js +7 -2
  25. package/src/dispatches/SwitchTeamDispatch.js +5 -2
  26. package/src/dispatches/ThrowGrenadeDispatch.js +6 -2
  27. package/src/globals.js +15 -0
  28. package/src/matchmaker.js +13 -9
  29. package/src/pathing/astar.js +7 -25
  30. package/src/pathing/binaryheap.js +6 -6
  31. package/src/pathing/mapnode.js +4 -53
  32. package/src/socket.js +4 -10
  33. package/src/types/bot/GamePlayer.d.ts +39 -15
  34. package/src/types/bot.d.ts +1 -1
  35. package/src/types/constants/guns.d.ts +8 -0
  36. package/src/types/constants/index.d.ts +11 -1
  37. package/src/types/matchmaker.d.ts +8 -2
  38. package/build/browser.js +0 -8
  39. package/src/browser.js +0 -15
  40. package/src/dispatches/LookDispatch2.js +0 -18
  41. package/src/packet.js +0 -128
@@ -127,7 +127,7 @@ export const Maps = [
127
127
  "Spatula": true,
128
128
  "King": true
129
129
  },
130
- "availability": "both",
130
+ "availability": "private",
131
131
  "numPlayers": "18"
132
132
  },
133
133
  {
@@ -335,7 +335,7 @@ export const Maps = [
335
335
  "Spatula": true,
336
336
  "King": true
337
337
  },
338
- "availability": "private",
338
+ "availability": "both",
339
339
  "numPlayers": "18"
340
340
  },
341
341
  {
@@ -348,7 +348,7 @@ export const Maps = [
348
348
  "Spatula": true,
349
349
  "King": true
350
350
  },
351
- "availability": "private",
351
+ "availability": "both",
352
352
  "numPlayers": "18"
353
353
  },
354
354
  {
@@ -400,7 +400,7 @@ export const Maps = [
400
400
  "Spatula": true,
401
401
  "King": true
402
402
  },
403
- "availability": "both",
403
+ "availability": "private",
404
404
  "numPlayers": "18"
405
405
  },
406
406
  {
@@ -491,7 +491,7 @@ export const Maps = [
491
491
  "Spatula": true,
492
492
  "King": true
493
493
  },
494
- "availability": "private",
494
+ "availability": "both",
495
495
  "numPlayers": "14"
496
496
  },
497
497
  {
@@ -574,7 +574,7 @@ export const Maps = [
574
574
  },
575
575
  {
576
576
  "filename": "metamorph",
577
- "hash": "hlpma5zbhi",
577
+ "hash": "l9o69l8e1b",
578
578
  "name": "Metamorph",
579
579
  "modes": {
580
580
  "FFA": true,
@@ -582,7 +582,7 @@ export const Maps = [
582
582
  "Spatula": true,
583
583
  "King": false
584
584
  },
585
- "availability": "both",
585
+ "availability": "private",
586
586
  "numPlayers": "14"
587
587
  },
588
588
  {
@@ -634,7 +634,7 @@ export const Maps = [
634
634
  "Spatula": true,
635
635
  "King": true
636
636
  },
637
- "availability": "private",
637
+ "availability": "both",
638
638
  "numPlayers": "18"
639
639
  },
640
640
  {
@@ -764,7 +764,7 @@ export const Maps = [
764
764
  "Spatula": true,
765
765
  "King": true
766
766
  },
767
- "availability": "both",
767
+ "availability": "private",
768
768
  "numPlayers": "14"
769
769
  },
770
770
  {
@@ -816,7 +816,7 @@ export const Maps = [
816
816
  "Spatula": true,
817
817
  "King": true
818
818
  },
819
- "availability": "both",
819
+ "availability": "private",
820
820
  "numPlayers": "16"
821
821
  },
822
822
  {
@@ -829,7 +829,7 @@ export const Maps = [
829
829
  "Spatula": true,
830
830
  "King": true
831
831
  },
832
- "availability": "both",
832
+ "availability": "private",
833
833
  "numPlayers": "18"
834
834
  },
835
835
  {
@@ -972,7 +972,7 @@ export const Maps = [
972
972
  "Spatula": true,
973
973
  "King": true
974
974
  },
975
- "availability": "private",
975
+ "availability": "both",
976
976
  "numPlayers": "18"
977
977
  },
978
978
  {
@@ -1024,7 +1024,7 @@ export const Maps = [
1024
1024
  "Spatula": true,
1025
1025
  "King": false
1026
1026
  },
1027
- "availability": "both",
1027
+ "availability": "private",
1028
1028
  "numPlayers": "12"
1029
1029
  },
1030
1030
  {
@@ -1076,7 +1076,20 @@ export const Maps = [
1076
1076
  "Spatula": true,
1077
1077
  "King": true
1078
1078
  },
1079
- "availability": "private",
1079
+ "availability": "both",
1080
+ "numPlayers": "18"
1081
+ },
1082
+ {
1083
+ "filename": "yolkido",
1084
+ "hash": "127ppvq4k6n",
1085
+ "name": "Yolkido Garrison",
1086
+ "modes": {
1087
+ "FFA": true,
1088
+ "Teams": true,
1089
+ "Spatula": true,
1090
+ "King": true
1091
+ },
1092
+ "availability": "both",
1080
1093
  "numPlayers": "18"
1081
1094
  }
1082
1095
  ];
@@ -1,4 +1,5 @@
1
- import packet from '#packet';
1
+ import CommOut from '../comm/CommOut.js';
2
+ import { CommCode } from '../constants/codes.js';
2
3
 
3
4
  export class BootPlayerDispatch {
4
5
  constructor(uniqueId) {
@@ -10,7 +11,10 @@ export class BootPlayerDispatch {
10
11
  }
11
12
 
12
13
  execute(bot) {
13
- new packet.BootPacket(this.uniqueId).execute(bot.game.socket);
14
+ const out = CommOut.getBuffer();
15
+ out.packInt8(CommCode.bootPlayer);
16
+ out.packString(this.uniqueId);
17
+ out.send(bot.game.socket);
14
18
  }
15
19
  }
16
20
 
@@ -1,4 +1,5 @@
1
- import packet from '#packet';
1
+ import CommOut from '../comm/CommOut.js';
2
+ import { CommCode } from '../constants/codes.js';
2
3
 
3
4
  export class ChatDispatch {
4
5
  constructor(msg, noLimit = false) {
@@ -17,7 +18,11 @@ export class ChatDispatch {
17
18
  }
18
19
 
19
20
  execute(bot) {
20
- new packet.ChatPacket(this.msg).execute(bot.game.socket);
21
+ const out = CommOut.getBuffer();
22
+ out.packInt8(CommCode.chat);
23
+ out.packString(this.msg);
24
+ out.send(bot.game.socket);
25
+
21
26
  bot.lastChatTime = Date.now();
22
27
  }
23
28
  }
@@ -1,4 +1,5 @@
1
- import packet from '#packet';
1
+ import CommOut from '../comm/CommOut.js';
2
+ import { CommCode } from '../constants/codes.js';
2
3
 
3
4
  const regenScale = [0, 0.25, 0.5, 0.75, 1, 1.25, 1.5, 1.75, 2, 2.25, 2.5, 2.75, 3, 3.25, 3.5, 3.75, 4];
4
5
 
@@ -21,7 +22,24 @@ export class GameOptionsDispatch {
21
22
  }
22
23
 
23
24
  execute(bot) {
24
- new packet.GameOptionsPacket(bot.game.options).execute(bot.game.socket);
25
+ const flags =
26
+ (bot.game.options.locked ? 1 : 0) |
27
+ (bot.game.options.noTeamChange ? 2 : 0) |
28
+ (bot.game.options.noTeamShuffle ? 4 : 0);
29
+
30
+ const out = CommOut.getBuffer();
31
+
32
+ out.packInt8(CommCode.gameOptions);
33
+ out.packInt8(bot.game.options.gravity * 4);
34
+ out.packInt8(bot.game.options.damage * 4);
35
+ out.packInt8(bot.game.options.healthRegen * 4);
36
+ out.packInt8(flags);
37
+
38
+ bot.game.options.weaponsDisabled.forEach((v) => {
39
+ out.packInt8(v ? 1 : 0);
40
+ });
41
+
42
+ out.send(bot.game.socket);
25
43
  }
26
44
  }
27
45
 
@@ -1,4 +1,5 @@
1
- import packet from '#packet';
1
+ import CommOut from '../comm/CommOut.js';
2
+ import { CommCode } from '../constants/codes.js';
2
3
 
3
4
  export class MeleeDispatch {
4
5
  check(bot) {
@@ -6,17 +7,18 @@ export class MeleeDispatch {
6
7
  }
7
8
 
8
9
  execute(bot) {
9
- new packet.MeleePacket().execute(bot.game.socket);
10
+ const out = CommOut.getBuffer();
11
+ out.packInt8(CommCode.melee);
12
+ out.send(bot.game.socket);
13
+
10
14
  bot.usingMelee = true;
11
15
 
12
16
  // gameloop every 33.33 (repeating) ms, 17 ticks, so 566.61 is the closest you get
13
17
  setTimeout(() => {
14
- // new ChatDispatch('end melee, start swap gun').execute(player);
15
18
  bot.usingMelee = false
16
19
  bot.swappingGun = true
17
20
 
18
21
  setTimeout(() => {
19
- // new ChatDispatch('end swap gun').execute(player);
20
22
  bot.swappingGun = false
21
23
  }, 0.5 * bot.me.weapons[0].equipTime)
22
24
  }, 566.61);
@@ -1,4 +1,5 @@
1
- import packet from '#packet';
1
+ import CommOut from '../comm/CommOut.js';
2
+ import { CommCode } from '../constants/codes.js';
2
3
 
3
4
  export class PauseDispatch {
4
5
  check(bot) {
@@ -6,8 +7,11 @@ export class PauseDispatch {
6
7
  }
7
8
 
8
9
  execute(bot) {
9
- new packet.PausePacket().execute(bot.game.socket);
10
- setTimeout(() => bot.me.playing = false, 3000);
10
+ const out = CommOut.getBuffer();
11
+ out.packInt8(CommCode.pause);
12
+ out.send(bot.game.socket);
13
+
14
+ setTimeout(() => bot.me.playing = false, 3000);
11
15
  }
12
16
  }
13
17
 
@@ -1,4 +1,5 @@
1
- import packet from '#packet';
1
+ import CommOut from '../comm/CommOut.js';
2
+ import { CommCode } from '../constants/codes.js';
2
3
 
3
4
  export class ReloadDispatch {
4
5
  check(bot) {
@@ -6,7 +7,9 @@ export class ReloadDispatch {
6
7
  }
7
8
 
8
9
  execute(bot) {
9
- new packet.ReloadPacket().execute(bot.game.socket);
10
+ const out = CommOut.getBuffer();
11
+ out.packInt8(CommCode.reload);
12
+ out.send(bot.game.socket);
10
13
 
11
14
  const playerActiveWeapon = bot.me.weapons[bot.me.activeGun];
12
15
 
@@ -1,4 +1,5 @@
1
- import packet from '#packet';
1
+ import CommOut from '../comm/CommOut.js';
2
+ import { CommCode } from '../constants/codes.js';
2
3
 
3
4
  export class ReportPlayerDispatch {
4
5
  constructor(idOrName, reasons = {}) {
@@ -39,7 +40,11 @@ export class ReportPlayerDispatch {
39
40
 
40
41
  if (!target) throw new Error('target player for ReportPlayerDispatch not found')
41
42
 
42
- new packet.ReportPacket(target, this.reasonInt).execute(bot.game.socket);
43
+ const out = CommOut.getBuffer();
44
+ out.packInt8(CommCode.reportPlayer);
45
+ out.packString(target);
46
+ out.packInt8(this.reasonInt);
47
+ out.send(bot.game.socket);
43
48
  }
44
49
  }
45
50
 
@@ -1,9 +1,10 @@
1
1
  /* eslint-disable stylistic/max-len */
2
2
 
3
- import { queryServices } from '#api';
4
- import { findItemById, GunList, ItemTypes } from '#constants';
3
+ import { queryServices } from '../api.js';
4
+ import { findItemById, GunList, ItemTypes } from '../constants/index.js';
5
5
 
6
- import packet from '#packet';
6
+ import CommOut from '../comm/CommOut.js';
7
+ import { CommCode } from '../constants/codes.js';
7
8
 
8
9
  const isDefault = (itemId) => findItemById(itemId) && findItemById(itemId).unlock == 'default';
9
10
  const isType = (itemId, type) => findItemById(itemId) && findItemById(itemId).item_type_id == type;
@@ -89,8 +90,12 @@ export class SaveLoadoutDispatch {
89
90
  bot.account.loadout = loadout;
90
91
 
91
92
  saveLoadout.then(() => {
92
- if (bot.state.joinedGame)
93
- new packet.ChangeCharacterPacket(this.changes?.classIdx || bot.me.selectedGun).execute(bot.game.socket);
93
+ if (bot.state.joinedGame) {
94
+ const out = CommOut.getBuffer();
95
+ out.packInt8(CommCode.changeCharacter);
96
+ out.packInt8(this.changes?.classIdx || bot.me.selectedGun);
97
+ out.send(bot.game.socket);
98
+ }
94
99
 
95
100
  const findCosmetics = bot.intents.includes(bot.Intents.COSMETIC_DATA);
96
101
 
@@ -102,7 +107,7 @@ export class SaveLoadoutDispatch {
102
107
  else if (changeKey === 'grenadeId') bot.me.character.grenade = findCosmetics ? findItemById(changeValue) : changeValue;
103
108
  else if (changeKey === 'meleeId') bot.me.character.melee = findCosmetics ? findItemById(changeValue) : changeValue;
104
109
  else if (changeKey === 'colorIdx') bot.me.character.eggColor = changeValue;
105
- else if (changeKey === 'primaryId') bot.me.character.primaryGun = findItemById(changeValue[bot.me.selectedGun]);
110
+ else if (changeKey === 'primaryId') bot.me.character.primaryGun = findCosmetics ? findItemById(changeValue[bot.me.selectedGun]) : changeValue;
106
111
  else if (changeKey === 'secondaryId') bot.me.character.secondaryGun = findCosmetics ? findItemById(changeValue[bot.me.selectedGun]) : changeValue;
107
112
  })
108
113
  })
@@ -1,4 +1,5 @@
1
- import packet from '#packet';
1
+ import CommOut from '../comm/CommOut.js';
2
+ import { CommCode } from '../constants/codes.js';
2
3
 
3
4
  export class SpawnDispatch {
4
5
  check(bot) {
@@ -8,7 +9,9 @@ export class SpawnDispatch {
8
9
  }
9
10
 
10
11
  execute(bot) {
11
- new packet.RespawnPacket().execute(bot.game.socket);
12
+ const out = CommOut.getBuffer();
13
+ out.packInt8(CommCode.requestRespawn);
14
+ out.send(bot.game.socket);
12
15
 
13
16
  bot.lastSpawnedTime = Date.now();
14
17
  bot.me.playing = true;
@@ -1,4 +1,5 @@
1
- import packet from '#packet';
1
+ import CommOut from '../comm/CommOut.js';
2
+ import { CommCode } from '../constants/codes.js';
2
3
 
3
4
  export class SwapWeaponDispatch {
4
5
  check(bot) {
@@ -7,7 +8,11 @@ export class SwapWeaponDispatch {
7
8
 
8
9
  execute(bot) {
9
10
  bot.me.activeGun = +!bot.me.activeGun;
10
- new packet.SwapWeaponPacket(bot.me.activeGun).execute(bot.game.socket);
11
+
12
+ const out = CommOut.getBuffer();
13
+ out.packInt8(CommCode.swapWeapon);
14
+ out.packInt8(bot.me.activeGun);
15
+ out.send(bot.game.socket);
11
16
  }
12
17
  }
13
18
 
@@ -1,4 +1,5 @@
1
- import packet from '#packet';
1
+ import CommOut from '../comm/CommOut.js';
2
+ import { CommCode } from '../constants/codes.js';
2
3
 
3
4
  export class SwitchTeamDispatch {
4
5
  check(bot) {
@@ -24,7 +25,9 @@ export class SwitchTeamDispatch {
24
25
  }
25
26
 
26
27
  execute(bot) {
27
- new packet.TeamSwitchingTraitorPacket().execute(bot.game.socket);
28
+ const out = CommOut.getBuffer();
29
+ out.packInt8(CommCode.switchTeam);
30
+ out.send(bot.game.socket);
28
31
  }
29
32
  }
30
33
 
@@ -1,4 +1,5 @@
1
- import packet from '#packet';
1
+ import CommOut from '../comm/CommOut.js';
2
+ import { CommCode } from '../constants/codes.js';
2
3
 
3
4
  export class ThrowGrenadeDispatch {
4
5
  constructor(power = 1) {
@@ -15,7 +16,10 @@ export class ThrowGrenadeDispatch {
15
16
  }
16
17
 
17
18
  execute(bot) {
18
- new packet.ThrowGrenadePacket(this.power).execute(bot.game.socket);
19
+ const out = CommOut.getBuffer();
20
+ out.packInt8(CommCode.throwGrenade);
21
+ out.packFloat(this.power);
22
+ out.send(bot.game.socket);
19
23
  }
20
24
  }
21
25
 
package/src/globals.js ADDED
@@ -0,0 +1,15 @@
1
+ const globals = {};
2
+
3
+ if (typeof process !== 'undefined') {
4
+ globals.fetch = (await import('undici')).fetch;
5
+ globals.SocksProxyAgent = (await import('smallsocks')).SocksProxyAgent;
6
+ globals.ProxyAgent = (await import('undici')).ProxyAgent;
7
+ globals.WebSocket = (await import('ws')).default;
8
+ } else {
9
+ globals.fetch = fetch;
10
+ globals.SocksProxyAgent = undefined;
11
+ globals.ProxyAgent = class {};
12
+ globals.WebSocket = WebSocket;
13
+ }
14
+
15
+ export default globals;
package/src/matchmaker.js CHANGED
@@ -1,5 +1,5 @@
1
- import { loginAnonymously } from '#api';
2
- import { GameModes, PlayTypes, ProxiesEnabled } from '#constants';
1
+ import { loginAnonymously } from './api.js';
2
+ import { GameModes, PlayTypes, ProxiesEnabled } from './constants/index.js';
3
3
 
4
4
  import yolkws from './socket.js';
5
5
 
@@ -10,14 +10,11 @@ export class Matchmaker {
10
10
  proxy = null;
11
11
  sessionId = '';
12
12
 
13
- forceClose = false;
14
-
15
13
  onListeners = new Map();
16
14
  onceListeners = new Map();
17
15
 
18
- // sessionId: string, a custom session id
19
- // proxy: a socks5 proxy string
20
- // instance: a custom game instance
16
+ #forceClose = false;
17
+
21
18
  constructor(params = {}) {
22
19
  if (!params.instance) params.instance = 'shellshock.io';
23
20
 
@@ -34,6 +31,11 @@ export class Matchmaker {
34
31
  const attempt = async () => {
35
32
  try {
36
33
  this.ws = new yolkws(`wss://${instance}/matchmaker/`, this.proxy);
34
+ this.ws.onerror = async (e) => {
35
+ console.error(e);
36
+ await new Promise((resolve) => setTimeout(resolve, 100));
37
+ return await attempt();
38
+ }
37
39
  } catch {
38
40
  await new Promise((resolve) => setTimeout(resolve, 100));
39
41
  await attempt();
@@ -44,6 +46,8 @@ export class Matchmaker {
44
46
 
45
47
  this.ws.onopen = () => {
46
48
  this.connected = true;
49
+ this.ws.onerror = null;
50
+
47
51
  if (this.sessionId) {
48
52
  this.onceConnected.forEach(func => func());
49
53
  }
@@ -55,7 +59,7 @@ export class Matchmaker {
55
59
  }
56
60
 
57
61
  this.ws.onclose = () => {
58
- if (this.forceClose) return;
62
+ if (this.#forceClose) return;
59
63
 
60
64
  this.connected = false;
61
65
  this.#createSocket(instance);
@@ -159,7 +163,7 @@ export class Matchmaker {
159
163
  }
160
164
 
161
165
  close() {
162
- this.forceClose = true;
166
+ this.#forceClose = true;
163
167
  this.ws.close();
164
168
  }
165
169
 
@@ -1,27 +1,17 @@
1
- import { NodeList } from './mapnode.js';
2
1
  import { BinaryHeap } from './binaryheap.js';
3
2
 
4
- function printPath(path) {
5
- for (const item of path) {
6
- console.log(item.position);
7
- }
8
- } // have it your way eslint
9
-
10
3
  export default class AStar {
11
4
  constructor(list) {
12
5
  this.list = list;
13
-
14
- if (!typeof list == NodeList) {
15
- throw new Error('AStar requires a NodeList');
16
- }
17
6
  }
18
7
 
19
- heuristic(pos1, pos2) { // @1ust Taxicab3D!
8
+ heuristic(pos1, pos2) {
20
9
  return Math.abs(pos1.x - pos2.x) + Math.abs(pos1.y - pos2.y) + Math.abs(pos1.z - pos2.z);
21
10
  }
22
11
 
23
12
  reversePath(node) {
24
13
  const path = [];
14
+
25
15
  while (node.parent) {
26
16
  path.push(node);
27
17
  node = node.parent;
@@ -35,7 +25,6 @@ export default class AStar {
35
25
  this.list.clean();
36
26
 
37
27
  const heap = new BinaryHeap(node => node.f);
38
-
39
28
  const closedSet = [];
40
29
 
41
30
  start.h = this.heuristic(start, end);
@@ -48,9 +37,7 @@ export default class AStar {
48
37
  const current = heap.pop();
49
38
 
50
39
  if (current === end) {
51
- // console.log('done with astar - path found')
52
40
  const val = this.reversePath(current);
53
- printPath(val);
54
41
  return val;
55
42
  }
56
43
 
@@ -61,29 +48,24 @@ export default class AStar {
61
48
  for (let i = 0; i < neighbors.length; i++) {
62
49
  const neighbor = neighbors[i];
63
50
 
64
- if (closedSet.includes(neighbor)) {
65
- continue;
66
- }
51
+ if (closedSet.includes(neighbor)) continue;
67
52
 
68
53
  const tentativeGScore = current.g + 1;
69
54
  const visited = neighbor.visited;
55
+
70
56
  if (!visited || tentativeGScore < neighbor.g) {
71
57
  neighbor.visited = true;
72
58
  neighbor.parent = current;
73
59
  neighbor.g = tentativeGScore;
74
60
  neighbor.h = this.heuristic(neighbor.position, end.position);
75
61
  neighbor.f = neighbor.g + neighbor.h;
76
- if (!visited) {
77
- heap.push(neighbor);
78
- } else {
79
- heap.rescoreElement(neighbor);
80
- }
62
+
63
+ if (!visited) heap.push(neighbor);
64
+ else heap.rescoreElement(neighbor);
81
65
  }
82
66
  }
83
67
  }
84
68
 
85
- // console.log('done with astar - no path found')
86
- // return null if no path has been found
87
69
  return null
88
70
  }
89
71
  }
@@ -34,13 +34,13 @@ class BinaryHeap {
34
34
  // To remove a value, we must search through the array to find
35
35
  // it.
36
36
  for (let i = 0; i < length; i++) {
37
- if (this.content[i] != node) { continue; }
37
+ if (this.content[i] != node) continue;
38
38
  // When it is found, the process seen in 'pop' is repeated
39
39
  // to fill up the hole.
40
40
  const end = this.content.pop();
41
41
  // If the element we popped was the one we needed to remove,
42
42
  // we're done.
43
- if (i == length - 1) { break; }
43
+ if (i == length - 1) break;
44
44
  // Otherwise, we replace the removed element with the popped
45
45
  // one, and allow it to float up or sink down as appropriate.
46
46
  this.content[i] = end;
@@ -63,7 +63,7 @@ class BinaryHeap {
63
63
  const parentN = Math.floor((n + 1) / 2) - 1, parent = this.content[parentN];
64
64
  // If the parent has a lesser score, things are in order and we
65
65
  // are done.
66
- if (score >= this.scoreFunction(parent)) { break; }
66
+ if (score >= this.scoreFunction(parent)) break;
67
67
 
68
68
  // Otherwise, swap the parent with the current element and
69
69
  // continue.
@@ -94,16 +94,16 @@ class BinaryHeap {
94
94
  const child1 = this.content[child1N];
95
95
  child1Score = this.scoreFunction(child1);
96
96
  // If the score is less than our element's, we need to swap.
97
- if (child1Score < elemScore) { swap = child1N; }
97
+ if (child1Score < elemScore) swap = child1N;
98
98
  }
99
99
  // Do the same checks for the other child.
100
100
  if (child2N < length) {
101
101
  const child2 = this.content[child2N], child2Score = this.scoreFunction(child2);
102
- if (child2Score < (swap == null ? elemScore : child1Score)) { swap = child2N; }
102
+ if (child2Score < (swap == null ? elemScore : child1Score)) swap = child2N;
103
103
  }
104
104
 
105
105
  // No need to swap further, we are done.
106
- if (swap == null) { break; }
106
+ if (swap == null) break;
107
107
 
108
108
  // Otherwise, swap and continue.
109
109
  this.content[n] = this.content[swap];