@ianlucas/cs2-lib 5.0.0-rc.2 → 5.0.0-rc.4
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/inventory.d.ts +5 -1
- package/dist/inventory.js +23 -1
- package/dist/utils.d.ts +2 -0
- package/dist/utils.js +3 -0
- package/package.json +1 -1
package/dist/inventory.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { CS2ItemTypeValues, CS2UnlockedItem } from "./economy-types.js";
|
|
2
2
|
import { CS2EconomyInstance, CS2EconomyItem } from "./economy.js";
|
|
3
3
|
import { CS2TeamValues } from "./teams.js";
|
|
4
|
-
import { Interface } from "./utils.js";
|
|
4
|
+
import { Interface, MapValue } from "./utils.js";
|
|
5
5
|
export interface CS2BaseInventoryItem {
|
|
6
6
|
containerId?: number;
|
|
7
7
|
equipped?: boolean;
|
|
@@ -110,3 +110,7 @@ export declare class CS2InventoryItem extends CS2EconomyItem implements Interfac
|
|
|
110
110
|
constructor(inventory: CS2Inventory, uid: number, baseInventoryItem: CS2BaseInventoryItem, { economy, item, language }: CS2EconomyItem);
|
|
111
111
|
edit(...sources: Partial<CS2BaseInventoryItem>[]): void;
|
|
112
112
|
}
|
|
113
|
+
export declare function mapAllStickers(stickers: CS2InventoryItem["stickers"]): ([number, MapValue<typeof stickers>] | undefined)[];
|
|
114
|
+
export declare function mapStickers(stickers: CS2InventoryItem["stickers"]): [number, MapValue<typeof stickers>][];
|
|
115
|
+
export declare function mapAllPatches(patches: CS2InventoryItem["patches"]): ([number, number] | undefined)[];
|
|
116
|
+
export declare function mapPatches(patches: CS2InventoryItem["patches"]): [number, number][];
|
package/dist/inventory.js
CHANGED
|
@@ -7,7 +7,7 @@ import { CS2ItemType } from "./economy-types.js";
|
|
|
7
7
|
import { CS2Economy, CS2EconomyItem } from "./economy.js";
|
|
8
8
|
import { resolveInventoryData } from "./inventory-upgrader.js";
|
|
9
9
|
import { CS2Team } from "./teams.js";
|
|
10
|
-
import { assert, ensure, float } from "./utils.js";
|
|
10
|
+
import { assert, ensure, float, isNotUndefined } from "./utils.js";
|
|
11
11
|
export const CS2_INVENTORY_VERSION = 1;
|
|
12
12
|
export const CS2_INVENTORY_TIMESTAMP = 1707696138408;
|
|
13
13
|
// prettier-ignore
|
|
@@ -442,3 +442,25 @@ export class CS2InventoryItem extends CS2EconomyItem {
|
|
|
442
442
|
}
|
|
443
443
|
}
|
|
444
444
|
}
|
|
445
|
+
export function mapAllStickers(stickers) {
|
|
446
|
+
const entries = [];
|
|
447
|
+
for (let slot = 0; slot < CS2_MAX_STICKERS; slot++) {
|
|
448
|
+
const sticker = stickers?.get(slot);
|
|
449
|
+
entries.push(sticker !== undefined ? [slot, sticker] : undefined);
|
|
450
|
+
}
|
|
451
|
+
return entries;
|
|
452
|
+
}
|
|
453
|
+
export function mapStickers(stickers) {
|
|
454
|
+
return mapAllStickers(stickers).filter(isNotUndefined);
|
|
455
|
+
}
|
|
456
|
+
export function mapAllPatches(patches) {
|
|
457
|
+
const entries = [];
|
|
458
|
+
for (let slot = 0; slot < CS2_MAX_PATCHES; slot++) {
|
|
459
|
+
const patch = patches?.get(slot);
|
|
460
|
+
entries.push(patch !== undefined ? [slot, patch] : undefined);
|
|
461
|
+
}
|
|
462
|
+
return entries;
|
|
463
|
+
}
|
|
464
|
+
export function mapPatches(patches) {
|
|
465
|
+
return mapAllPatches(patches).filter(isNotUndefined);
|
|
466
|
+
}
|
package/dist/utils.d.ts
CHANGED
|
@@ -8,9 +8,11 @@ export type Interface<T extends object> = {
|
|
|
8
8
|
[K in keyof T]-?: {} extends Pick<T, K> ? K : never;
|
|
9
9
|
}[keyof T] : never]-?: T[key] | undefined;
|
|
10
10
|
};
|
|
11
|
+
export type MapValue<T> = T extends Map<any, infer I> ? I : never;
|
|
11
12
|
export declare function compare<T, U>(var1: T, var2: U): boolean;
|
|
12
13
|
export declare function float(literal: number, fractionDigits?: number): number;
|
|
13
14
|
export declare function ensure<T>(value: T): NonNullable<T>;
|
|
14
15
|
export declare function safe<T>(fn: () => T): false | T;
|
|
15
16
|
export declare function assert(condition: any, message?: string): asserts condition;
|
|
16
17
|
export declare function fail(message?: string): never;
|
|
18
|
+
export declare function isNotUndefined<T>(value: T): value is NonNullable<T>;
|
package/dist/utils.js
CHANGED