libram 0.7.16 → 0.7.17

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.
@@ -2,7 +2,7 @@ import { Item, Location, canAdventure, getMonsters, itemDropsArray, Effect, toEf
2
2
  import { have as have_ } from "../../lib";
3
3
  import { get } from "../../property";
4
4
  import { $item } from "../../template-string";
5
- import { clamp } from "../../utils";
5
+ import { clamp, flat } from "../../utils";
6
6
  export const item = $item `cursed monkey's paw`;
7
7
  /**
8
8
  * @returns Whether or not we currently `have` the cursed monkey's paw
@@ -20,15 +20,14 @@ export function wishes() {
20
20
  * @returns A set of all items we expect to be able to wish; this doesn't actually constitute all items
21
21
  */
22
22
  export function wishableItems() {
23
- return new Set(...Location.all()
23
+ return new Set(...flat(Location.all()
24
24
  .filter((l) => canAdventure(l))
25
25
  .map((l) => getMonsters(l)
26
26
  .filter((m) => m.copyable)
27
27
  .map((m) => itemDropsArray(m)
28
28
  .filter(({ type, rate, drop }) => !drop.quest && (type !== "c" || rate >= 1) // Remove random roll drops
29
29
  )
30
- .map(({ drop }) => drop)))
31
- .flat());
30
+ .map(({ drop }) => drop)))));
32
31
  }
33
32
  const INVALID_CHARACTERS = /[^a-z\d -]/g;
34
33
  let _unwishableEffects;
package/dist/utils.d.ts CHANGED
@@ -151,7 +151,7 @@ export declare function makeByXFunction<T extends string>(source: Delayed<T>): <
151
151
  * Flattens an array. Basically replacing Array.prototype.flat for which Rhino doesn't yet have an implementation
152
152
  *
153
153
  * @param arr Array to flatten
154
- * @param depth Level to flatten
154
+ * @param depth Number of layers to flatten by; Infinity for a fully flat array
155
155
  * @returns Flattened array
156
156
  */
157
157
  export declare function flat<A extends any[], D extends number = 1>(arr: A, depth?: number): FlatArray<A, D>[];
package/dist/utils.js CHANGED
@@ -219,11 +219,11 @@ export function makeByXFunction(source) {
219
219
  * Flattens an array. Basically replacing Array.prototype.flat for which Rhino doesn't yet have an implementation
220
220
  *
221
221
  * @param arr Array to flatten
222
- * @param depth Level to flatten
222
+ * @param depth Number of layers to flatten by; Infinity for a fully flat array
223
223
  * @returns Flattened array
224
224
  */
225
225
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
226
- export function flat(arr, depth = 1) {
226
+ export function flat(arr, depth = Infinity) {
227
227
  let flatArray = [];
228
228
  for (const item of arr) {
229
229
  if (Array.isArray(item) && depth > 0) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "libram",
3
- "version": "0.7.16",
3
+ "version": "0.7.17",
4
4
  "description": "JavaScript helper library for KoLmafia",
5
5
  "module": "dist/index.js",
6
6
  "types": "dist/index.d.ts",