@pkmn/randoms 0.10.7 → 0.10.9
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/build/gen1.d.ts +50 -0
- package/build/gen2.d.ts +18 -0
- package/build/gen3.d.ts +23 -0
- package/build/gen4.d.ts +21 -0
- package/build/gen5.d.ts +22 -0
- package/build/gen6.d.ts +24 -0
- package/build/gen7.d.ts +52 -0
- package/build/gen8.d.ts +60 -0
- package/build/gen9.d.ts +178 -0
- package/build/index.d.mts +2 -4
- package/build/index.d.ts +2 -4
- package/build/index.js +8091 -9045
- package/build/index.js.map +1 -1
- package/build/index.mjs +7845 -8799
- package/build/index.mjs.map +1 -1
- package/build/test/index.test.d.ts +1 -0
- package/build/utils.d.ts +44 -0
- package/package.json +2 -2
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/build/utils.d.ts
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
type Comparable = number | string | boolean | Comparable[] | {
|
|
2
|
+
reverse: Comparable;
|
|
3
|
+
};
|
|
4
|
+
/** Forces num to be an integer (between min and max). */
|
|
5
|
+
declare function clampIntRange(num: any, min?: number, max?: number): number;
|
|
6
|
+
/**
|
|
7
|
+
* Compares two variables; intended to be used as a smarter comparator.
|
|
8
|
+
* The two variables must be the same type (TypeScript will not check this).
|
|
9
|
+
*
|
|
10
|
+
* - Numbers are sorted low-to-high, use `-val` to reverse
|
|
11
|
+
* - Strings are sorted A to Z case-semi-insensitively, use `{reverse: val}` to reverse
|
|
12
|
+
* - Booleans are sorted true-first (REVERSE of casting to numbers), use `!val` to reverse
|
|
13
|
+
* - Arrays are sorted lexically in the order of their elements
|
|
14
|
+
*
|
|
15
|
+
* In other words: `[num, str]` will be sorted A to Z, `[num, {reverse: str}]` will be sorted Z to A.
|
|
16
|
+
*/
|
|
17
|
+
declare function compare(a: Comparable, b: Comparable): number;
|
|
18
|
+
/**
|
|
19
|
+
* Sorts an array according to the callback's output on its elements.
|
|
20
|
+
*
|
|
21
|
+
* The callback's output is compared according to `PSUtils.compare`
|
|
22
|
+
* (numbers low to high, strings A-Z, booleans true-first, arrays in order).
|
|
23
|
+
*/
|
|
24
|
+
declare function sortBy<T>(array: T[], callback: (a: T) => Comparable): T[];
|
|
25
|
+
/**
|
|
26
|
+
* Sorts an array according to `PSUtils.compare`
|
|
27
|
+
* (numbers low to high, strings A-Z, booleans true-first, arrays in order).
|
|
28
|
+
*
|
|
29
|
+
* Note that array.sort() only works on strings, not numbers, so you'll need
|
|
30
|
+
* this to sort numbers.
|
|
31
|
+
*/
|
|
32
|
+
declare function sortBy<T extends Comparable>(array: T[]): T[];
|
|
33
|
+
declare class Multiset<T> extends Map<T, number> {
|
|
34
|
+
get(key: T): number;
|
|
35
|
+
add(key: T): this;
|
|
36
|
+
remove(key: T): boolean;
|
|
37
|
+
}
|
|
38
|
+
export declare const Utils: {
|
|
39
|
+
clampIntRange: typeof clampIntRange;
|
|
40
|
+
compare: typeof compare;
|
|
41
|
+
sortBy: typeof sortBy;
|
|
42
|
+
Multiset: typeof Multiset;
|
|
43
|
+
};
|
|
44
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pkmn/randoms",
|
|
3
|
-
"version": "0.10.
|
|
3
|
+
"version": "0.10.9",
|
|
4
4
|
"description": "Random team generation logic for Pokémon Showdown's Random Battle formats",
|
|
5
5
|
"repository": "github:pkmn/ps",
|
|
6
6
|
"license": "MIT",
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
"build"
|
|
16
16
|
],
|
|
17
17
|
"dependencies": {
|
|
18
|
-
"@pkmn/sim": "^0.10.
|
|
18
|
+
"@pkmn/sim": "^0.10.9"
|
|
19
19
|
},
|
|
20
20
|
"scripts": {
|
|
21
21
|
"lint": "eslint --cache src",
|