UNPKG

pack-mc-2

Version:
63 lines (55 loc) 1.63 kB
declare class MinecraftObject { id: string; label: string; format: string; component: object | undefined; event: object | undefined; conditions: any[] | undefined; body: object; namespace: string; constructor(label: string, id: string, version?: string, namespace?: string); json(): { "format_version": string; [key: string]: { description: { identifier: string; }; components?: object; events?: object; conditions?: any[]; [key: string]: any; }; }; initComponent(obj?: object): this; initEvent(obj?: object): this; initCondition(array: any[]): this; set(key: string, value: any, namespace?: string): this; setEvent(key: string, value: any): this; condition(rule: any): this; subId(): string; /** * Events */ onGenerateJSON(json: object): void; } // Added Object prototype extensions interface Object { /** * Iterates over object properties with ability to break the loop * @param callback Function called for each property with parameters: * (value, key, breakFunction, originalObject) */ each(callback: (value: any, key: string, breakFunction: () => void, obj: object) => void): void; /** * Converts object to formatted JSON string * @param tab Number of spaces for indentation (default: 2) */ jsonify(tab?: number): string; } // Added String prototype extension interface String { /** * Parses JSON string to object */ jsonify(): any; }