UNPKG

yimultiscreenserver-sdk-web

Version:

YiMultiScreenServer SDK for Web

37 lines (31 loc) 824 B
import { Code } from "./Code"; export class Result<T> { code: number; msg: string; data: T | null; constructor() { this.code = Code.OK; this.msg = ""; this.data = null; } static create<T>(code: number, msg: string, data: T): Result<T> { let result = new Result<T>(); result.code = code; result.msg = msg; result.data = data; return result; } equals(o: any): boolean { return o instanceof Result && this.code === o.code && this.msg === o.msg && this.data === o.data; } toString(): string { return `Result{` + `code=${this.code}, ` + `msg='${this.msg}', ` + `data=${this.data?.toString()}` + `}`; } }