@pkmn/sim 0.7.58 → 0.7.59

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 (138) hide show
  1. package/build/cjs/config/formats.js +83 -61
  2. package/build/cjs/config/formats.js.map +1 -1
  3. package/build/cjs/data/aliases.js +4 -2
  4. package/build/cjs/data/aliases.js.map +1 -1
  5. package/build/cjs/data/formats-data.js +180 -170
  6. package/build/cjs/data/formats-data.js.map +1 -1
  7. package/build/esm/config/formats.mjs +83 -61
  8. package/build/esm/config/formats.mjs.map +1 -1
  9. package/build/esm/data/aliases.mjs +4 -2
  10. package/build/esm/data/aliases.mjs.map +1 -1
  11. package/build/esm/data/formats-data.mjs +180 -170
  12. package/build/esm/data/formats-data.mjs.map +1 -1
  13. package/build/types/config/formats.d.ts +1 -0
  14. package/build/types/data/abilities.d.ts +3 -0
  15. package/build/types/data/aliases.d.ts +3 -0
  16. package/build/types/data/conditions.d.ts +3 -0
  17. package/build/types/data/formats-data.d.ts +3 -0
  18. package/build/types/data/index.d.ts +11 -0
  19. package/build/types/data/items.d.ts +3 -0
  20. package/build/types/data/learnsets.d.ts +3 -0
  21. package/build/types/data/legality.d.ts +3 -0
  22. package/build/types/data/mods/gen1/conditions.d.ts +12 -0
  23. package/build/types/data/mods/gen1/formats-data.d.ts +3 -0
  24. package/build/types/data/mods/gen1/index.d.ts +7 -0
  25. package/build/types/data/mods/gen1/moves.d.ts +7 -0
  26. package/build/types/data/mods/gen1/pokedex.d.ts +3 -0
  27. package/build/types/data/mods/gen1/rulesets.d.ts +3 -0
  28. package/build/types/data/mods/gen1/scripts.d.ts +6 -0
  29. package/build/types/data/mods/gen1/typechart.d.ts +10 -0
  30. package/build/types/data/mods/gen2/conditions.d.ts +3 -0
  31. package/build/types/data/mods/gen2/formats-data.d.ts +3 -0
  32. package/build/types/data/mods/gen2/index.d.ts +8 -0
  33. package/build/types/data/mods/gen2/items.d.ts +3 -0
  34. package/build/types/data/mods/gen2/learnsets.d.ts +3 -0
  35. package/build/types/data/mods/gen2/legality.d.ts +3 -0
  36. package/build/types/data/mods/gen2/moves.d.ts +6 -0
  37. package/build/types/data/mods/gen2/pokedex.d.ts +3 -0
  38. package/build/types/data/mods/gen2/rulesets.d.ts +3 -0
  39. package/build/types/data/mods/gen2/scripts.d.ts +4 -0
  40. package/build/types/data/mods/gen2/typechart.d.ts +3 -0
  41. package/build/types/data/mods/gen3/abilities.d.ts +3 -0
  42. package/build/types/data/mods/gen3/conditions.d.ts +3 -0
  43. package/build/types/data/mods/gen3/formats-data.d.ts +3 -0
  44. package/build/types/data/mods/gen3/index.d.ts +7 -0
  45. package/build/types/data/mods/gen3/items.d.ts +3 -0
  46. package/build/types/data/mods/gen3/moves.d.ts +6 -0
  47. package/build/types/data/mods/gen3/rulesets.d.ts +3 -0
  48. package/build/types/data/mods/gen3/scripts.d.ts +1 -0
  49. package/build/types/data/mods/gen4/abilities.d.ts +3 -0
  50. package/build/types/data/mods/gen4/conditions.d.ts +3 -0
  51. package/build/types/data/mods/gen4/formats-data.d.ts +3 -0
  52. package/build/types/data/mods/gen4/index.d.ts +8 -0
  53. package/build/types/data/mods/gen4/items.d.ts +3 -0
  54. package/build/types/data/mods/gen4/moves.d.ts +3 -0
  55. package/build/types/data/mods/gen4/pokedex.d.ts +3 -0
  56. package/build/types/data/mods/gen4/rulesets.d.ts +3 -0
  57. package/build/types/data/mods/gen4/scripts.d.ts +1 -0
  58. package/build/types/data/mods/gen5/abilities.d.ts +3 -0
  59. package/build/types/data/mods/gen5/conditions.d.ts +3 -0
  60. package/build/types/data/mods/gen5/formats-data.d.ts +3 -0
  61. package/build/types/data/mods/gen5/index.d.ts +9 -0
  62. package/build/types/data/mods/gen5/items.d.ts +3 -0
  63. package/build/types/data/mods/gen5/moves.d.ts +3 -0
  64. package/build/types/data/mods/gen5/pokedex.d.ts +3 -0
  65. package/build/types/data/mods/gen5/rulesets.d.ts +3 -0
  66. package/build/types/data/mods/gen5/scripts.d.ts +1 -0
  67. package/build/types/data/mods/gen5/typechart.d.ts +3 -0
  68. package/build/types/data/mods/gen6/abilities.d.ts +3 -0
  69. package/build/types/data/mods/gen6/conditions.d.ts +3 -0
  70. package/build/types/data/mods/gen6/formats-data.d.ts +3 -0
  71. package/build/types/data/mods/gen6/index.d.ts +8 -0
  72. package/build/types/data/mods/gen6/items.d.ts +3 -0
  73. package/build/types/data/mods/gen6/learnsets.d.ts +3 -0
  74. package/build/types/data/mods/gen6/legality.d.ts +3 -0
  75. package/build/types/data/mods/gen6/moves.d.ts +3 -0
  76. package/build/types/data/mods/gen6/pokedex.d.ts +3 -0
  77. package/build/types/data/mods/gen6/scripts.d.ts +1 -0
  78. package/build/types/data/mods/gen6/typechart.d.ts +3 -0
  79. package/build/types/data/mods/gen7/abilities.d.ts +3 -0
  80. package/build/types/data/mods/gen7/formats-data.d.ts +3 -0
  81. package/build/types/data/mods/gen7/index.d.ts +7 -0
  82. package/build/types/data/mods/gen7/items.d.ts +3 -0
  83. package/build/types/data/mods/gen7/moves.d.ts +3 -0
  84. package/build/types/data/mods/gen7/pokedex.d.ts +3 -0
  85. package/build/types/data/mods/gen7/rulesets.d.ts +3 -0
  86. package/build/types/data/mods/gen7/scripts.d.ts +1 -0
  87. package/build/types/data/mods/gen8/abilities.d.ts +3 -0
  88. package/build/types/data/mods/gen8/formats-data.d.ts +3 -0
  89. package/build/types/data/mods/gen8/index.d.ts +7 -0
  90. package/build/types/data/mods/gen8/items.d.ts +3 -0
  91. package/build/types/data/mods/gen8/learnsets.d.ts +3 -0
  92. package/build/types/data/mods/gen8/legality.d.ts +3 -0
  93. package/build/types/data/mods/gen8/moves.d.ts +3 -0
  94. package/build/types/data/mods/gen8/pokedex.d.ts +3 -0
  95. package/build/types/data/mods/gen8/rulesets.d.ts +3 -0
  96. package/build/types/data/mods/gen8/scripts.d.ts +1 -0
  97. package/build/types/data/moves.d.ts +3 -0
  98. package/build/types/data/natures.d.ts +3 -0
  99. package/build/types/data/pokedex.d.ts +3 -0
  100. package/build/types/data/pokemongo.d.ts +31 -0
  101. package/build/types/data/rulesets.d.ts +3 -0
  102. package/build/types/data/scripts.d.ts +1 -0
  103. package/build/types/data/tags.d.ts +15 -0
  104. package/build/types/data/text/abilities.d.ts +3 -0
  105. package/build/types/data/text/default.d.ts +3 -0
  106. package/build/types/data/text/items.d.ts +3 -0
  107. package/build/types/data/text/moves.d.ts +3 -0
  108. package/build/types/data/typechart.d.ts +3 -0
  109. package/build/types/lib/index.d.ts +2 -0
  110. package/build/types/lib/streams.d.ts +1 -0
  111. package/build/types/lib/utils.d.ts +139 -0
  112. package/build/types/sim/battle-actions.d.ts +90 -0
  113. package/build/types/sim/battle-queue.d.ts +164 -0
  114. package/build/types/sim/battle-stream.d.ts +67 -0
  115. package/build/types/sim/battle.d.ts +396 -0
  116. package/build/types/sim/dex-abilities.d.ts +35 -0
  117. package/build/types/sim/dex-conditions.d.ts +518 -0
  118. package/build/types/sim/dex-data.d.ts +169 -0
  119. package/build/types/sim/dex-formats.d.ts +170 -0
  120. package/build/types/sim/dex-items.d.ts +110 -0
  121. package/build/types/sim/dex-moves.d.ts +441 -0
  122. package/build/types/sim/dex-species.d.ts +289 -0
  123. package/build/types/sim/dex.d.ts +162 -0
  124. package/build/types/sim/exported-global-types.d.ts +510 -0
  125. package/build/types/sim/field.d.ts +30 -0
  126. package/build/types/sim/global-types.d.ts +510 -0
  127. package/build/types/sim/index.d.ts +13 -0
  128. package/build/types/sim/pokemon.d.ts +427 -0
  129. package/build/types/sim/prng.d.ts +97 -0
  130. package/build/types/sim/side.d.ts +127 -0
  131. package/build/types/sim/state.d.ts +42 -0
  132. package/build/types/sim/team-validator.d.ts +198 -0
  133. package/build/types/sim/teams.d.ts +26 -0
  134. package/build/types/sim/tools/exhaustive-runner.d.ts +52 -0
  135. package/build/types/sim/tools/index.d.ts +2 -0
  136. package/build/types/sim/tools/random-player-ai.d.ts +32 -0
  137. package/build/types/sim/tools/runner.d.ts +41 -0
  138. package/package.json +1 -1
@@ -0,0 +1,3 @@
1
+ export declare const Legality: {
2
+ [k: string]: ModdedLearnsetData;
3
+ };
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Gen 2 moves
3
+ */
4
+ export declare const Moves: {
5
+ [k: string]: ModdedMoveData;
6
+ };
@@ -0,0 +1,3 @@
1
+ export declare const Pokedex: {
2
+ [k: string]: ModdedSpeciesData;
3
+ };
@@ -0,0 +1,3 @@
1
+ export declare const Rulesets: {
2
+ [k: string]: ModdedFormatData;
3
+ };
@@ -0,0 +1,4 @@
1
+ /**
2
+ * Gen 2 scripts.
3
+ */
4
+ export declare const Scripts: ModdedBattleScriptsData;
@@ -0,0 +1,3 @@
1
+ export declare const TypeChart: {
2
+ [k: string]: ModdedTypeData;
3
+ };
@@ -0,0 +1,3 @@
1
+ export declare const Abilities: {
2
+ [k: string]: ModdedAbilityData;
3
+ };
@@ -0,0 +1,3 @@
1
+ export declare const Conditions: {
2
+ [k: string]: ModdedConditionData;
3
+ };
@@ -0,0 +1,3 @@
1
+ export declare const FormatsData: {
2
+ [k: string]: ModdedSpeciesFormatsData;
3
+ };
@@ -0,0 +1,7 @@
1
+ export { Abilities } from './abilities';
2
+ export { Conditions } from './conditions';
3
+ export { Rulesets } from './rulesets';
4
+ export { FormatsData } from './formats-data';
5
+ export { Items } from './items';
6
+ export { Moves } from './moves';
7
+ export { Scripts } from './scripts';
@@ -0,0 +1,3 @@
1
+ export declare const Items: {
2
+ [k: string]: ModdedItemData;
3
+ };
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Gen 3 moves
3
+ */
4
+ export declare const Moves: {
5
+ [k: string]: ModdedMoveData;
6
+ };
@@ -0,0 +1,3 @@
1
+ export declare const Rulesets: {
2
+ [k: string]: ModdedFormatData;
3
+ };
@@ -0,0 +1 @@
1
+ export declare const Scripts: ModdedBattleScriptsData;
@@ -0,0 +1,3 @@
1
+ export declare const Abilities: {
2
+ [k: string]: ModdedAbilityData;
3
+ };
@@ -0,0 +1,3 @@
1
+ export declare const Conditions: {
2
+ [k: string]: ModdedConditionData;
3
+ };
@@ -0,0 +1,3 @@
1
+ export declare const FormatsData: {
2
+ [k: string]: ModdedSpeciesFormatsData;
3
+ };
@@ -0,0 +1,8 @@
1
+ export { Abilities } from './abilities';
2
+ export { Conditions } from './conditions';
3
+ export { Rulesets } from './rulesets';
4
+ export { FormatsData } from './formats-data';
5
+ export { Items } from './items';
6
+ export { Moves } from './moves';
7
+ export { Pokedex } from './pokedex';
8
+ export { Scripts } from './scripts';
@@ -0,0 +1,3 @@
1
+ export declare const Items: {
2
+ [k: string]: ModdedItemData;
3
+ };
@@ -0,0 +1,3 @@
1
+ export declare const Moves: {
2
+ [k: string]: ModdedMoveData;
3
+ };
@@ -0,0 +1,3 @@
1
+ export declare const Pokedex: {
2
+ [k: string]: ModdedSpeciesData;
3
+ };
@@ -0,0 +1,3 @@
1
+ export declare const Rulesets: {
2
+ [k: string]: ModdedFormatData;
3
+ };
@@ -0,0 +1 @@
1
+ export declare const Scripts: ModdedBattleScriptsData;
@@ -0,0 +1,3 @@
1
+ export declare const Abilities: {
2
+ [k: string]: ModdedAbilityData;
3
+ };
@@ -0,0 +1,3 @@
1
+ export declare const Conditions: {
2
+ [k: string]: ModdedConditionData;
3
+ };
@@ -0,0 +1,3 @@
1
+ export declare const FormatsData: {
2
+ [k: string]: ModdedSpeciesFormatsData;
3
+ };
@@ -0,0 +1,9 @@
1
+ export { Abilities } from './abilities';
2
+ export { Conditions } from './conditions';
3
+ export { Rulesets } from './rulesets';
4
+ export { FormatsData } from './formats-data';
5
+ export { Items } from './items';
6
+ export { Moves } from './moves';
7
+ export { Pokedex } from './pokedex';
8
+ export { Scripts } from './scripts';
9
+ export { TypeChart } from './typechart';
@@ -0,0 +1,3 @@
1
+ export declare const Items: {
2
+ [k: string]: ModdedItemData;
3
+ };
@@ -0,0 +1,3 @@
1
+ export declare const Moves: {
2
+ [k: string]: ModdedMoveData;
3
+ };
@@ -0,0 +1,3 @@
1
+ export declare const Pokedex: {
2
+ [k: string]: ModdedSpeciesData;
3
+ };
@@ -0,0 +1,3 @@
1
+ export declare const Rulesets: {
2
+ [k: string]: ModdedFormatData;
3
+ };
@@ -0,0 +1 @@
1
+ export declare const Scripts: ModdedBattleScriptsData;
@@ -0,0 +1,3 @@
1
+ export declare const TypeChart: {
2
+ [k: string]: ModdedTypeData | null;
3
+ };
@@ -0,0 +1,3 @@
1
+ export declare const Abilities: {
2
+ [k: string]: ModdedAbilityData;
3
+ };
@@ -0,0 +1,3 @@
1
+ export declare const Conditions: {
2
+ [k: string]: ModdedConditionData;
3
+ };
@@ -0,0 +1,3 @@
1
+ export declare const FormatsData: {
2
+ [k: string]: ModdedSpeciesFormatsData;
3
+ };
@@ -0,0 +1,8 @@
1
+ export { Abilities } from './abilities';
2
+ export { Conditions } from './conditions';
3
+ export { FormatsData } from './formats-data';
4
+ export { Items } from './items';
5
+ export { Moves } from './moves';
6
+ export { Pokedex } from './pokedex';
7
+ export { Scripts } from './scripts';
8
+ export { TypeChart } from './typechart';
@@ -0,0 +1,3 @@
1
+ export declare const Items: {
2
+ [k: string]: ModdedItemData;
3
+ };
@@ -0,0 +1,3 @@
1
+ export declare const Learnsets: {
2
+ [k: string]: ModdedLearnsetData;
3
+ };
@@ -0,0 +1,3 @@
1
+ export declare const Legality: {
2
+ [k: string]: ModdedLearnsetData;
3
+ };
@@ -0,0 +1,3 @@
1
+ export declare const Moves: {
2
+ [k: string]: ModdedMoveData;
3
+ };
@@ -0,0 +1,3 @@
1
+ export declare const Pokedex: {
2
+ [k: string]: ModdedSpeciesData;
3
+ };
@@ -0,0 +1 @@
1
+ export declare const Scripts: ModdedBattleScriptsData;
@@ -0,0 +1,3 @@
1
+ export declare const TypeChart: {
2
+ [k: string]: ModdedTypeData;
3
+ };
@@ -0,0 +1,3 @@
1
+ export declare const Abilities: {
2
+ [k: string]: ModdedAbilityData;
3
+ };
@@ -0,0 +1,3 @@
1
+ export declare const FormatsData: {
2
+ [k: string]: ModdedSpeciesFormatsData;
3
+ };
@@ -0,0 +1,7 @@
1
+ export { Abilities } from './abilities';
2
+ export { Rulesets } from './rulesets';
3
+ export { FormatsData } from './formats-data';
4
+ export { Items } from './items';
5
+ export { Moves } from './moves';
6
+ export { Pokedex } from './pokedex';
7
+ export { Scripts } from './scripts';
@@ -0,0 +1,3 @@
1
+ export declare const Items: {
2
+ [k: string]: ModdedItemData;
3
+ };
@@ -0,0 +1,3 @@
1
+ export declare const Moves: {
2
+ [k: string]: ModdedMoveData;
3
+ };
@@ -0,0 +1,3 @@
1
+ export declare const Pokedex: {
2
+ [k: string]: ModdedSpeciesData;
3
+ };
@@ -0,0 +1,3 @@
1
+ export declare const Rulesets: {
2
+ [k: string]: ModdedFormatData;
3
+ };
@@ -0,0 +1 @@
1
+ export declare const Scripts: ModdedBattleScriptsData;
@@ -0,0 +1,3 @@
1
+ export declare const Abilities: {
2
+ [k: string]: ModdedAbilityData;
3
+ };
@@ -0,0 +1,3 @@
1
+ export declare const FormatsData: {
2
+ [k: string]: SpeciesFormatsData;
3
+ };
@@ -0,0 +1,7 @@
1
+ export { Abilities } from './abilities';
2
+ export { Items } from './items';
3
+ export { Rulesets } from './rulesets';
4
+ export { FormatsData } from './formats-data';
5
+ export { Moves } from './moves';
6
+ export { Pokedex } from './pokedex';
7
+ export { Scripts } from './scripts';
@@ -0,0 +1,3 @@
1
+ export declare const Items: {
2
+ [k: string]: ModdedItemData;
3
+ };
@@ -0,0 +1,3 @@
1
+ export declare const Learnsets: {
2
+ [k: string]: ModdedLearnsetData;
3
+ };
@@ -0,0 +1,3 @@
1
+ export declare const Legality: {
2
+ [k: string]: ModdedLearnsetData;
3
+ };
@@ -0,0 +1,3 @@
1
+ export declare const Moves: {
2
+ [k: string]: ModdedMoveData;
3
+ };
@@ -0,0 +1,3 @@
1
+ export declare const Pokedex: {
2
+ [k: string]: ModdedSpeciesData;
3
+ };
@@ -0,0 +1,3 @@
1
+ export declare const Rulesets: {
2
+ [k: string]: ModdedFormatData;
3
+ };
@@ -0,0 +1 @@
1
+ export declare const Scripts: ModdedBattleScriptsData;
@@ -0,0 +1,3 @@
1
+ export declare const Moves: {
2
+ [moveid: string]: MoveData;
3
+ };
@@ -0,0 +1,3 @@
1
+ export declare const Natures: {
2
+ [k: string]: NatureData;
3
+ };
@@ -0,0 +1,3 @@
1
+ export declare const Pokedex: {
2
+ [speciesid: string]: SpeciesData;
3
+ };
@@ -0,0 +1,31 @@
1
+ /**
2
+ * A listing of every Pokemon that can be obtained from Pokemon GO and how the can be obtained.
3
+ * If a Pokemon is not listed here, it cannot be obtained from Pokemon GO.
4
+ *
5
+ * Key:
6
+ * - Origin:
7
+ * - wild: Can be found in the overworld, either as a regular spawn or through a similar source such as GO Snapshot
8
+ * - egg: Hatches from 2, 5, or 10 km eggs
9
+ * - giovanni: Shadow Pokemon rescued from Giovanni and purified
10
+ * - 12kmegg: Hatches from a 12 km egg, which is obtained from Team GO Rocket Leaders which unlock at level 8
11
+ * - raid: Caught from defeating a raid boss
12
+ * - research: Reward from field research, special research, or research breakthrough
13
+ * If the Pokemon is obtainable from the wild, other sources do not need to be included due to redundancy.
14
+ * For shinies that can't be obtained from the wild, all other sources should be included.
15
+ *
16
+ * - Shiny origin restrictions:
17
+ * - noshiny: This Pokemon's shiny form is unavailable in Pokemon GO
18
+ * - nowildshiny: This Pokemon can't be obtained as shiny from the wild
19
+ *
20
+ * - Trade restrictions:
21
+ * - notrade: This Pokemon cannot be traded at all
22
+ * - specialtrade: This Pokemon must be traded in a special trade
23
+ *
24
+ * Certain sources have been excluded from this list, which are:
25
+ * - GO Battle League: same level and IV floor as raid bosses, and all from GO Battle League have also been in raids
26
+ * - Shadow Pokemon: most can also be obtained from the wild, and those that can't are from defeating Giovanni, which
27
+ * is handled as as its own encounter
28
+ */
29
+ export declare const PokemonGoData: {
30
+ [source: string]: PokemonGoData;
31
+ };
@@ -0,0 +1,3 @@
1
+ export declare const Rulesets: {
2
+ [k: string]: FormatData;
3
+ };
@@ -0,0 +1 @@
1
+ export declare const Scripts: BattleScriptsData;
@@ -0,0 +1,15 @@
1
+ import { Ability, Item, Move, Species } from '../sim/exported-global-types';
2
+ interface TagData {
3
+ name: string;
4
+ desc?: string;
5
+ speciesFilter?: (species: Species) => boolean;
6
+ moveFilter?: (move: Move) => boolean;
7
+ genericFilter?: (thing: Species | Move | Item | Ability) => boolean;
8
+ speciesNumCol?: (species: Species) => number;
9
+ moveNumCol?: (move: Move) => number;
10
+ genericNumCol?: (thing: Species | Move | Item | Ability) => number;
11
+ }
12
+ export declare const Tags: {
13
+ [id: string]: TagData;
14
+ };
15
+ export {};
@@ -0,0 +1,3 @@
1
+ export declare const AbilitiesText: {
2
+ [k: string]: AbilityText;
3
+ };
@@ -0,0 +1,3 @@
1
+ export declare const DefaultText: {
2
+ [k: string]: DefaultText;
3
+ };
@@ -0,0 +1,3 @@
1
+ export declare const ItemsText: {
2
+ [k: string]: ItemText;
3
+ };
@@ -0,0 +1,3 @@
1
+ export declare const MovesText: {
2
+ [k: string]: MoveText;
3
+ };
@@ -0,0 +1,3 @@
1
+ export declare const TypeChart: {
2
+ [k: string]: TypeData;
3
+ };
@@ -0,0 +1,2 @@
1
+ export * as Streams from './streams';
2
+ export * as Utils from './utils';
@@ -0,0 +1 @@
1
+ export * from "@pkmn/streams";
@@ -0,0 +1,139 @@
1
+ /**
2
+ * Utils library
3
+ *
4
+ * Miscellaneous utility functions that don't really have a better place.
5
+ *
6
+ * It'll always be a judgment call whether or not a function goes into a
7
+ * "catch-all" library like this, so here are some guidelines:
8
+ *
9
+ * - It must not have any dependencies
10
+ *
11
+ * - It must conceivably have a use in a wide variety of projects, not just
12
+ * Pokémon (if it's Pokémon-specific, Dex is probably a good place for it)
13
+ *
14
+ * - A lot of Chat functions are kind of iffy, but I'm going to say for now
15
+ * that if it's English-specific, it should be left out of here.
16
+ */
17
+ /// <reference types="node" />
18
+ export type Comparable = number | string | boolean | Comparable[] | {
19
+ reverse: Comparable;
20
+ };
21
+ /**
22
+ * Safely converts the passed variable into a string. Unlike '' + str,
23
+ * String(str), or str.toString(), Utils.getString is guaranteed not to
24
+ * crash.
25
+ *
26
+ * Specifically, the fear with untrusted JSON is an object like:
27
+ *
28
+ * let a = {"toString": "this is not a function"};
29
+ * console.log(`a is ${a}`);
30
+ *
31
+ * This will crash (because a.toString() is not a function). Instead,
32
+ * getString simply returns '' if the passed variable isn't a
33
+ * string or a number.
34
+ */
35
+ export declare function getString(str: any): string;
36
+ export declare function escapeRegex(str: string): string;
37
+ /**
38
+ * Escapes HTML in a string.
39
+ */
40
+ export declare function escapeHTML(str: string | number): string;
41
+ /**
42
+ * Strips HTML from a string.
43
+ */
44
+ export declare function stripHTML(htmlContent: string): string;
45
+ /**
46
+ * Maps numbers to their ordinal string.
47
+ */
48
+ export declare function formatOrder(place: number): string;
49
+ /**
50
+ * Visualizes eval output in a slightly more readable form
51
+ */
52
+ export declare function visualize(value: any, depth?: number): string;
53
+ /**
54
+ * Compares two variables; intended to be used as a smarter comparator.
55
+ * The two variables must be the same type (TypeScript will not check this).
56
+ *
57
+ * - Numbers are sorted low-to-high, use `-val` to reverse
58
+ * - Strings are sorted A to Z case-semi-insensitively, use `{reverse: val}` to reverse
59
+ * - Booleans are sorted true-first (REVERSE of casting to numbers), use `!val` to reverse
60
+ * - Arrays are sorted lexically in the order of their elements
61
+ *
62
+ * In other words: `[num, str]` will be sorted A to Z, `[num, {reverse: str}]` will be sorted Z to A.
63
+ */
64
+ export declare function compare(a: Comparable, b: Comparable): number;
65
+ /**
66
+ * Sorts an array according to the callback's output on its elements.
67
+ *
68
+ * The callback's output is compared according to `PSUtils.compare`
69
+ * (numbers low to high, strings A-Z, booleans true-first, arrays in order).
70
+ */
71
+ export declare function sortBy<T>(array: T[], callback: (a: T) => Comparable): T[];
72
+ /**
73
+ * Sorts an array according to `PSUtils.compare`
74
+ * (numbers low to high, strings A-Z, booleans true-first, arrays in order).
75
+ *
76
+ * Note that array.sort() only works on strings, not numbers, so you'll need
77
+ * this to sort numbers.
78
+ */
79
+ export declare function sortBy<T extends Comparable>(array: T[]): T[];
80
+ export declare function splitFirst(str: string, delimiter: string): [string, string];
81
+ export declare function splitFirst(str: string, delimiter: string, limit: 2): [string, string, string];
82
+ export declare function splitFirst(str: string, delimiter: string, limit: 3): [string, string, string, string];
83
+ export declare function splitFirst(str: string, delimiter: string, limit: number): string[];
84
+ /**
85
+ * Template string tag function for escaping HTML
86
+ */
87
+ export declare function html(strings: TemplateStringsArray, ...args: any): string;
88
+ /**
89
+ * This combines escapeHTML and forceWrap. The combination allows us to use
90
+ * <wbr /> instead of U+200B, which will make sure the word-wrapping hints
91
+ * can't be copy/pasted (which would mess up code).
92
+ */
93
+ export declare function escapeHTMLForceWrap(text: string): string;
94
+ /**
95
+ * HTML doesn't support `word-wrap: break-word` in tables, but sometimes it
96
+ * would be really nice if it did. This emulates `word-wrap: break-word` by
97
+ * manually inserting U+200B to tell long words to wrap.
98
+ */
99
+ export declare function forceWrap(text: string): string;
100
+ export declare function shuffle<T>(arr: T[]): T[];
101
+ export declare function randomElement<T>(arr: T[]): T;
102
+ /** Forces num to be an integer (between min and max). */
103
+ export declare function clampIntRange(num: any, min?: number, max?: number): number;
104
+ export declare function clearRequireCache(options?: {
105
+ exclude?: string[];
106
+ }): void;
107
+ export declare function uncacheModuleTree(mod: NodeJS.Module, excludes: string[], depth?: number): void;
108
+ export declare function deepClone(obj: any): any;
109
+ export declare function levenshtein(s: string, t: string, l: number): number;
110
+ export declare function waitUntil(time: number): Promise<void>;
111
+ /** Like parseInt, but returns NaN if the int isn't already in normalized form */
112
+ export declare function parseExactInt(str: string): number;
113
+ /** formats an array into a series of question marks and adds the elements to an arguments array */
114
+ export declare function formatSQLArray(arr: unknown[], args?: unknown[]): string;
115
+ export declare class Multiset<T> extends Map<T, number> {
116
+ add(key: T): this;
117
+ remove(key: T): boolean;
118
+ }
119
+ export declare const Utils: {
120
+ parseExactInt: typeof parseExactInt;
121
+ waitUntil: typeof waitUntil;
122
+ html: typeof html;
123
+ escapeHTML: typeof escapeHTML;
124
+ compare: typeof compare;
125
+ sortBy: typeof sortBy;
126
+ levenshtein: typeof levenshtein;
127
+ shuffle: typeof shuffle;
128
+ deepClone: typeof deepClone;
129
+ clearRequireCache: typeof clearRequireCache;
130
+ randomElement: typeof randomElement;
131
+ forceWrap: typeof forceWrap;
132
+ splitFirst: typeof splitFirst;
133
+ stripHTML: typeof stripHTML;
134
+ visualize: typeof visualize;
135
+ getString: typeof getString;
136
+ escapeRegex: typeof escapeRegex;
137
+ formatSQLArray: typeof formatSQLArray;
138
+ Multiset: typeof Multiset;
139
+ };