isaacscript-common 83.1.0 → 83.3.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.
@@ -130,6 +130,11 @@ export declare function filterMap<OldT, NewT>(array: readonly OldT[], func: (ele
130
130
  * the length of the array.
131
131
  */
132
132
  export declare function getArrayCombinations<T>(array: readonly T[], includeEmptyArray: boolean, min?: int, max?: int): ReadonlyArray<readonly T[]>;
133
+ /**
134
+ * Helper function to get the duplicate elements in an array. Only one element for each value will
135
+ * be returned. The elements will be sorted before they are returned.
136
+ */
137
+ export declare function getArrayDuplicateElements<T>(array: readonly T[]): readonly T[];
133
138
  /**
134
139
  * Helper function to get an array containing the indexes of an array.
135
140
  *
@@ -216,6 +221,12 @@ export declare function isArray(object: unknown, ensureContiguousValues?: boolea
216
221
  * For example, `[2, 3, 4]` would return true, and `[2, 3, 5]` would return false.
217
222
  */
218
223
  export declare function isArrayContiguous(array: readonly int[]): boolean;
224
+ /**
225
+ * Helper function to check if all the elements of an array are unique within that array.
226
+ *
227
+ * Under the hood, this is performed by converting the array to a set.
228
+ */
229
+ export declare function isArrayElementsUnique(array: readonly unknown[]): boolean;
219
230
  /** Checks if an array is in the provided 2-dimensional array. */
220
231
  export declare function isArrayInArray<T>(arrayToMatch: readonly T[], parentArray: ReadonlyArray<readonly T[]>): boolean;
221
232
  /** Helper function to set every element in an array to a specific value. */
@@ -1 +1 @@
1
- {"version":3,"file":"array.d.ts","sourceRoot":"","sources":["../../src/functions/array.ts"],"names":[],"mappings":";;;AACA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAM1D;;;GAGG;AACH,wBAAgB,WAAW,CAAC,CAAC,EAC3B,MAAM,EAAE,SAAS,CAAC,EAAE,EACpB,MAAM,EAAE,SAAS,CAAC,EAAE,GACnB,OAAO,CAST;AAED;;;;;;;;;;GAUG;AAEH,wBAAgB,WAAW,CAAC,CAAC,EAC3B,aAAa,EAAE,SAAS,CA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GAAG,EAAE,GAAG,OAAO,CAahE;AAED;;;;GAIG;AACH,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,SAAS,OAAO,EAAE,GAAG,OAAO,CAGxE;AAED,iEAAiE;AACjE,wBAAgB,cAAc,CAAC,CAAC,EAC9B,YAAY,EAAE,SAAS,CAAC,EAAE,EAC1B,WAAW,EAAE,aAAa,CAAC,SAAS,CAAC,EAAE,CAAC,GACvC,OAAO,CAET;AAED,4EAA4E;AAE5E,wBAAgB,mBAAmB,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,EAAE,KAAK,EAAE,CAAC,GAAG,IAAI,CAIjE;AAED;;;;;;;;;;;;GAYG;AAEH,wBAAgB,YAAY,CAAC,CAAC,EAC5B,aAAa,EAAE,SAAS,CAAC,EAAE,EAC3B,SAAS,EAAE,IAAI,GAAG,GAAG,GAAG,SAAS,GAChC,CAAC,EAAE,CAKL;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,mBAAmB,CAAC,CAAC,EAEnC,KAAK,EAAE,CAAC,EAAE,EACV,SAAS,EAAE,IAAI,GAAG,GAAG,GAAG,SAAS,GAChC,IAAI,CAWN;AAED,+DAA+D;AAC/D,wBAAgB,QAAQ,CAAC,KAAK,EAAE,SAAS,MAAM,EAAE,GAAG,MAAM,CAEzD;AAED;;GAEG;AAEH,wBAAgB,iBAAiB,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,IAAI,CAM3E"}
@@ -13,6 +13,9 @@ local __TS__ArraySlice = ____lualib.__TS__ArraySlice
13
13
  local __TS__SparseArrayNew = ____lualib.__TS__SparseArrayNew
14
14
  local __TS__SparseArrayPush = ____lualib.__TS__SparseArrayPush
15
15
  local __TS__SparseArraySpread = ____lualib.__TS__SparseArraySpread
16
+ local Set = ____lualib.Set
17
+ local __TS__Spread = ____lualib.__TS__Spread
18
+ local __TS__ArraySort = ____lualib.__TS__ArraySort
16
19
  local __TS__ArrayIncludes = ____lualib.__TS__ArrayIncludes
17
20
  local __TS__ObjectKeys = ____lualib.__TS__ObjectKeys
18
21
  local __TS__ArraySome = ____lualib.__TS__ArraySome
@@ -372,6 +375,20 @@ function ____exports.getArrayCombinations(self, array, includeEmptyArray, min, m
372
375
  end
373
376
  return all
374
377
  end
378
+ --- Helper function to get the duplicate elements in an array. Only one element for each value will
379
+ -- be returned. The elements will be sorted before they are returned.
380
+ function ____exports.getArrayDuplicateElements(self, array)
381
+ local duplicateElements = __TS__New(Set)
382
+ local set = __TS__New(Set)
383
+ for ____, element in ipairs(array) do
384
+ if set:has(element) then
385
+ duplicateElements:add(element)
386
+ end
387
+ set:add(element)
388
+ end
389
+ local values = {__TS__Spread(duplicateElements)}
390
+ return __TS__ArraySort(values)
391
+ end
375
392
  --- Helper function to get an array containing the indexes of an array.
376
393
  --
377
394
  -- For example, an array of `["Apple", "Banana"]` would return an array of `[0, 1]`.
@@ -528,6 +545,13 @@ function ____exports.isArrayContiguous(self, array)
528
545
  end
529
546
  return true
530
547
  end
548
+ --- Helper function to check if all the elements of an array are unique within that array.
549
+ --
550
+ -- Under the hood, this is performed by converting the array to a set.
551
+ function ____exports.isArrayElementsUnique(self, array)
552
+ local set = __TS__New(Set, array)
553
+ return set.size == #array
554
+ end
531
555
  --- Checks if an array is in the provided 2-dimensional array.
532
556
  function ____exports.isArrayInArray(self, arrayToMatch, parentArray)
533
557
  return __TS__ArraySome(
@@ -5003,6 +5003,12 @@ export declare function getAngleDifference(angle1: float, angle2: float): float;
5003
5003
  */
5004
5004
  export declare function getArrayCombinations<T>(array: readonly T[], includeEmptyArray: boolean, min?: int, max?: int): ReadonlyArray<readonly T[]>;
5005
5005
 
5006
+ /**
5007
+ * Helper function to get the duplicate elements in an array. Only one element for each value will
5008
+ * be returned. The elements will be sorted before they are returned.
5009
+ */
5010
+ export declare function getArrayDuplicateElements<T>(array: readonly T[]): readonly T[];
5011
+
5006
5012
  /**
5007
5013
  * Helper function to get an array containing the indexes of an array.
5008
5014
  *
@@ -9020,6 +9026,13 @@ export declare function isArray(object: unknown, ensureContiguousValues?: boolea
9020
9026
  */
9021
9027
  export declare function isArrayContiguous(array: readonly int[]): boolean;
9022
9028
 
9029
+ /**
9030
+ * Helper function to check if all the elements of an array are unique within that array.
9031
+ *
9032
+ * Under the hood, this is performed by converting the array to a set.
9033
+ */
9034
+ export declare function isArrayElementsUnique(array: readonly unknown[]): boolean;
9035
+
9023
9036
  /** Checks if an array is in the provided 2-dimensional array. */
9024
9037
  export declare function isArrayInArray<T>(arrayToMatch: readonly T[], parentArray: ReadonlyArray<readonly T[]>): boolean;
9025
9038
 
@@ -1,6 +1,6 @@
1
1
  --[[
2
2
 
3
- isaacscript-common 83.0.0
3
+ isaacscript-common 83.2.0
4
4
 
5
5
  This is the "isaacscript-common" library, which was created with the IsaacScript tool.
6
6
 
@@ -12722,6 +12722,7 @@ return ____exports
12722
12722
  end,
12723
12723
  ["lua_modules.isaac-typescript-definitions.dist.enums.RoomType"] = function(...)
12724
12724
  local ____exports = {}
12725
+ --- This enum is contiguous. (Every value is satisfied between 1 and 29, inclusive.)
12725
12726
  ____exports.RoomType = {}
12726
12727
  ____exports.RoomType.DEFAULT = 1
12727
12728
  ____exports.RoomType[____exports.RoomType.DEFAULT] = "DEFAULT"
@@ -18691,6 +18692,9 @@ local __TS__ArraySlice = ____lualib.__TS__ArraySlice
18691
18692
  local __TS__SparseArrayNew = ____lualib.__TS__SparseArrayNew
18692
18693
  local __TS__SparseArrayPush = ____lualib.__TS__SparseArrayPush
18693
18694
  local __TS__SparseArraySpread = ____lualib.__TS__SparseArraySpread
18695
+ local Set = ____lualib.Set
18696
+ local __TS__Spread = ____lualib.__TS__Spread
18697
+ local __TS__ArraySort = ____lualib.__TS__ArraySort
18694
18698
  local __TS__ArrayIncludes = ____lualib.__TS__ArrayIncludes
18695
18699
  local __TS__ObjectKeys = ____lualib.__TS__ObjectKeys
18696
18700
  local __TS__ArraySome = ____lualib.__TS__ArraySome
@@ -19050,6 +19054,20 @@ function ____exports.getArrayCombinations(self, array, includeEmptyArray, min, m
19050
19054
  end
19051
19055
  return all
19052
19056
  end
19057
+ --- Helper function to get the duplicate elements in an array. Only one element for each value will
19058
+ -- be returned. The elements will be sorted before they are returned.
19059
+ function ____exports.getArrayDuplicateElements(self, array)
19060
+ local duplicateElements = __TS__New(Set)
19061
+ local set = __TS__New(Set)
19062
+ for ____, element in ipairs(array) do
19063
+ if set:has(element) then
19064
+ duplicateElements:add(element)
19065
+ end
19066
+ set:add(element)
19067
+ end
19068
+ local values = {__TS__Spread(duplicateElements)}
19069
+ return __TS__ArraySort(values)
19070
+ end
19053
19071
  --- Helper function to get an array containing the indexes of an array.
19054
19072
  --
19055
19073
  -- For example, an array of `["Apple", "Banana"]` would return an array of `[0, 1]`.
@@ -19206,6 +19224,13 @@ function ____exports.isArrayContiguous(self, array)
19206
19224
  end
19207
19225
  return true
19208
19226
  end
19227
+ --- Helper function to check if all the elements of an array are unique within that array.
19228
+ --
19229
+ -- Under the hood, this is performed by converting the array to a set.
19230
+ function ____exports.isArrayElementsUnique(self, array)
19231
+ local set = __TS__New(Set, array)
19232
+ return set.size == #array
19233
+ end
19209
19234
  --- Checks if an array is in the provided 2-dimensional array.
19210
19235
  function ____exports.isArrayInArray(self, arrayToMatch, parentArray)
19211
19236
  return __TS__ArraySome(
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "isaacscript-common",
3
- "version": "83.1.0",
3
+ "version": "83.3.0",
4
4
  "description": "Helper functions and features for IsaacScript mods.",
5
5
  "keywords": [
6
6
  "isaac",
@@ -37,6 +37,6 @@
37
37
  "lint": "tsx --tsconfig ./scripts/tsconfig.json ./scripts/lint.mts"
38
38
  },
39
39
  "dependencies": {
40
- "isaac-typescript-definitions": "^40.0.0"
40
+ "isaac-typescript-definitions": "^40.0.1"
41
41
  }
42
42
  }
@@ -355,6 +355,27 @@ function addCombinations<T>(
355
355
  }
356
356
  }
357
357
 
358
+ /**
359
+ * Helper function to get the duplicate elements in an array. Only one element for each value will
360
+ * be returned. The elements will be sorted before they are returned.
361
+ */
362
+ export function getArrayDuplicateElements<T>(
363
+ array: readonly T[],
364
+ ): readonly T[] {
365
+ const duplicateElements = new Set<T>();
366
+ const set = new Set<T>();
367
+
368
+ for (const element of array) {
369
+ if (set.has(element)) {
370
+ duplicateElements.add(element);
371
+ }
372
+ set.add(element);
373
+ }
374
+
375
+ const values = [...duplicateElements];
376
+ return values.sort();
377
+ }
378
+
358
379
  /**
359
380
  * Helper function to get an array containing the indexes of an array.
360
381
  *
@@ -587,6 +608,16 @@ export function isArrayContiguous(array: readonly int[]): boolean {
587
608
  return true;
588
609
  }
589
610
 
611
+ /**
612
+ * Helper function to check if all the elements of an array are unique within that array.
613
+ *
614
+ * Under the hood, this is performed by converting the array to a set.
615
+ */
616
+ export function isArrayElementsUnique(array: readonly unknown[]): boolean {
617
+ const set = new Set(array);
618
+ return set.size === array.length;
619
+ }
620
+
590
621
  /** Checks if an array is in the provided 2-dimensional array. */
591
622
  export function isArrayInArray<T>(
592
623
  arrayToMatch: readonly T[],