@cruncheevos/core
Version:
Parse and generate achievements and leaderboards for RetroAchievements.org
58 lines (57 loc) • 2.37 kB
TypeScript
import type { Achievement } from './achievement.js';
import type { Leaderboard } from './leaderboard.js';
export interface AssetData<IdType = number> {
/**
* ID of an Asset matching the one on server.
* If Asset does not exist on the server yet, `id` should be set
* to a high number like 111000001, similar to what RAIntegration
* does when creating local assets.
*/
id: IdType;
/**
* Optional Subset ID that an Asset belongs to, matching the one on server.
*/
setId?: IdType;
/**
* Title of an Asset, must be set.
*/
title: string;
/**
* Description of an Asset, required by server, but optional for library.
*/
description?: string;
}
export type Asset = Achievement | Leaderboard;
export type PartialByKey<T, K extends keyof T> = Partial<Pick<T, K>> & Omit<T, K>;
export type DeepPartial<T> = T extends object ? {
[P in keyof T]?: DeepPartial<T[P]>;
} : T;
export declare function invertObject(obj: Record<string, string>): any;
export declare function capitalizeWord(word: string): string;
export declare function formatNumberAsHex(num: number, upperCase?: boolean): string;
export declare function eatSymbols(str: TemplateStringsArray, ...args: any[]): string;
export declare function isObject(val: any): val is object;
export declare function isNumber(val: any, opts?: {
isInteger?: boolean;
isPositive?: boolean;
}): val is number;
export declare function deepFreeze<T extends Record<string, any> | any[]>(obj: T): Readonly<T>;
export declare function deepObjectCopy<T extends Record<string, any>>(obj: T): T;
export declare function wrappedError(err: Error, message: string): Error;
export declare function parseCSV(str: string): string[];
export declare function quoteIfHaveTo(str: string): string;
export declare const validate: {
andNormalizeId(id: number | string, propertyName?: string): number;
string(input: string, propertyName?: string): void;
nonEmptyString(input: string, propertyName?: string): void;
};
export declare function indexToConditionGroupName(index: number): string;
/**
* Splits string into numeric chunks, little endian
*
* @example
* stringToNumberLE('abcde') // [ 1684234849, 101 ]
* // abcd = 0x64636261 = 1684234849
* // e = 0x65 = 101
*/
export declare function stringToNumberLE(input: string): number[];