isaacscript-common 9.18.2 → 9.19.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.
- package/dist/functions/arrayLua.d.ts +53 -0
- package/dist/functions/arrayLua.d.ts.map +1 -0
- package/dist/functions/arrayLua.lua +52 -0
- package/dist/index.d.ts +58 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.lua +8 -0
- package/dist/isaacscript-common.lua +55960 -0
- package/package.json +2 -2
- package/src/functions/arrayLua.ts +82 -0
- package/src/index.ts +1 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "isaacscript-common",
|
|
3
|
-
"version": "9.
|
|
3
|
+
"version": "9.19.0",
|
|
4
4
|
"description": "Helper functions and features for IsaacScript mods.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"isaac",
|
|
@@ -22,6 +22,6 @@
|
|
|
22
22
|
"main": "dist/index",
|
|
23
23
|
"types": "dist/index.d.ts",
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"isaac-typescript-definitions": "^5.0.
|
|
25
|
+
"isaac-typescript-definitions": "^5.0.3"
|
|
26
26
|
}
|
|
27
27
|
}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* These are a collection of functions for non-TypeScript users so that they can access some of
|
|
3
|
+
* useful methods offered on the `Array` class in the JavaScript standard library.
|
|
4
|
+
*
|
|
5
|
+
* If you are a TypeScript user, you should never use these functions, and instead use the more
|
|
6
|
+
* idiomatic object-oriented approach.
|
|
7
|
+
*
|
|
8
|
+
* @module
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Helper function for non-TypeScript users to check if every element in the array is equal to a
|
|
13
|
+
* condition.
|
|
14
|
+
*
|
|
15
|
+
* Internally, this just calls `array.every`.
|
|
16
|
+
*/
|
|
17
|
+
export function every<T>(
|
|
18
|
+
array: T[],
|
|
19
|
+
func: (value: T, index: number, array: T[]) => boolean,
|
|
20
|
+
): boolean {
|
|
21
|
+
return array.every(func);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Helper function for non-TypeScript users to filter the elements in an array. Returns the filtered
|
|
26
|
+
* array.
|
|
27
|
+
*
|
|
28
|
+
* Internally, this just calls `array.filter`.
|
|
29
|
+
*/
|
|
30
|
+
export function filter<T>(
|
|
31
|
+
array: T[],
|
|
32
|
+
func: (value: T, index: number, array: T[]) => boolean,
|
|
33
|
+
): T[] {
|
|
34
|
+
return array.filter(func);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Helper function for non-TypeScript users to find an element in an array.
|
|
39
|
+
*
|
|
40
|
+
* Internally, this just calls `array.find`.
|
|
41
|
+
*/
|
|
42
|
+
export function find<T>(
|
|
43
|
+
array: T[],
|
|
44
|
+
func: (value: T, index: number, array: T[]) => boolean,
|
|
45
|
+
): T | undefined {
|
|
46
|
+
return array.find(func);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Helper function for non-TypeScript users to check if an element is in an array.
|
|
51
|
+
*
|
|
52
|
+
* Since this takes O(N) time, using this function is usually a mistake, since you can use a `Map`
|
|
53
|
+
* data structure to get O(1) lookups.
|
|
54
|
+
*
|
|
55
|
+
* Internally, this just calls `array.includes`.
|
|
56
|
+
*/
|
|
57
|
+
export function includes<T>(array: T[], element: T): boolean {
|
|
58
|
+
return array.includes(element);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* Helper function for non-TypeScript users to convert an array to a string with the specified
|
|
63
|
+
* separator.
|
|
64
|
+
*
|
|
65
|
+
* Internally, this just calls `array.join`.
|
|
66
|
+
*/
|
|
67
|
+
export function join<T>(array: T[], separator: string): string {
|
|
68
|
+
return array.join(separator);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* Helper function for non-TypeScript users to convert all of the elements in an array to something
|
|
73
|
+
* else.
|
|
74
|
+
*
|
|
75
|
+
* Internally, this just calls `array.map`.
|
|
76
|
+
*/
|
|
77
|
+
export function map<T, U>(
|
|
78
|
+
array: T[],
|
|
79
|
+
func: (value: T, index: number, array: T[]) => U,
|
|
80
|
+
): U[] {
|
|
81
|
+
return array.map(func);
|
|
82
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -48,6 +48,7 @@ export * from "./features/stageHistory";
|
|
|
48
48
|
export * from "./features/taintedLazarusPlayers";
|
|
49
49
|
export * from "./functions/ambush";
|
|
50
50
|
export * from "./functions/array";
|
|
51
|
+
export * from "./functions/arrayLua";
|
|
51
52
|
export * from "./functions/benchmark";
|
|
52
53
|
export * from "./functions/bitSet128";
|
|
53
54
|
export * from "./functions/bitwise";
|