UNPKG

warframe-worldstate-parser

Version:

An Open parser for Warframe's Worldstate in Javascript

70 lines (69 loc) 1.97 kB
import { n as __decorateMetadata, t as __decorate } from "../../decorate-BCC26nnB.mjs"; import { IsDate, IsOptional, IsString } from "class-validator"; import { fromNow, insist, parseDate, timeDeltaToString } from "warframe-worldstate-data/utilities"; //#region lib/models/WorldStateObject.ts /** * Represents a generic object from WorldState */ var WorldStateObject = class { /** * The object's id field */ id; /** * The date and time at which the WorldStateObject started */ activation; /** * The date and time at which the WorldStateObject ends */ expiry; /** * @param data The object data */ constructor(data) { insist({ ...data }); this.id = data._id ? data._id.$oid || data._id.$id : void 0; if (data.Activation) this.activation = parseDate(data.Activation); if (data.Expiry) this.expiry = parseDate(data.Expiry); } /** * Whether the void trader is active (at time of object creation) */ get active() { if (!this.activation && !this.expiry) return false; return fromNow(this.activation) < 0 && fromNow(this.expiry) > 0; } /** * A string indicating how long it will take for the trader to arrive * (at time of object creation) */ get startString() { if (!this.activation) return void 0; return timeDeltaToString(fromNow(this.activation)); } /** * Time delta string from now to the end */ get endString() { if (!this.expiry) return void 0; return timeDeltaToString(fromNow(this.expiry)); } }; __decorate([ IsOptional(), IsString(), __decorateMetadata("design:type", String) ], WorldStateObject.prototype, "id", void 0); __decorate([ IsOptional(), IsDate(), __decorateMetadata("design:type", typeof Date === "undefined" ? Object : Date) ], WorldStateObject.prototype, "activation", void 0); __decorate([ IsOptional(), IsDate(), __decorateMetadata("design:type", typeof Date === "undefined" ? Object : Date) ], WorldStateObject.prototype, "expiry", void 0); //#endregion export { WorldStateObject };