UNPKG

moomooio-client

Version:

MooMooIO-Client is a client-side wrapper API designed for the game MooMoo.io. This package aims to provide a simple yet powerful API for creating clones, mods, or plugins for MooMoo.io.

19 lines (14 loc) 738 B
import hats from "../data/hats"; type ReturnHat = (typeof hats)[number] | undefined; export default function getHat(hatID: number): ReturnHat; export default function getHat(hatName: string): ReturnHat; export default function getHat(prop: PropertyKey, propValue: unknown): ReturnHat; export default function getHat( IDOrNameOrProp: number | string | PropertyKey, propValue?: unknown ): ReturnHat { if (propValue !== undefined) return hats.find((hat) => (hat as any)[IDOrNameOrProp] == propValue); if (typeof IDOrNameOrProp == "string") return hats.find((hat) => hat.name == IDOrNameOrProp); if (typeof IDOrNameOrProp == "number") return hats.find((hat) => hat.id == IDOrNameOrProp); return undefined; }