UNPKG

@zikeji/hypixel

Version:

With IntelliSense support & test coverage, this is an unopinionated async/await API wrapper for Hypixel's Public API. It is developed in TypeScript complete with documentation, typed interfaces for all API responses, built-in rate-limit handling, flexible

28 lines (24 loc) 727 B
import type * as prismarineNbt from "prismarine-nbt"; import type { NBTInventoryItem } from "../helpers/TransformItemData"; let nbt: typeof prismarineNbt; export async function parse( value: number[] | string | Buffer ): Promise<NBTInventoryItem[]> { let buffer: Buffer; if (Buffer.isBuffer(value)) { buffer = value; } else { buffer = Array.isArray(value) ? Buffer.from(value) : Buffer.from(value, "base64"); } if (!nbt) { try { nbt = await import("prismarine-nbt"); } catch (e) { /* istanbul ignore next */ throw new Error("prismarine-nbt must be installed to use this helper"); } } return nbt.simplify((await nbt.parse(buffer)).parsed.value.i as never); }