UNPKG

cooperation

Version:
32 lines (31 loc) 614 B
/*规范标准输出*/ function msg(data = "", state = "OK") { let code, msg; switch (state) { case "OK": code = 0; msg = "SUCCEED"; break; case "WARN": code = -1; msg = "FAILED"; break; case "ERROR": code = -2; msg = "FAILED"; break; } let message = { code: code, msg: msg }; if (data) message["data"] = data; return JSON.stringify(message) } module.exports = { msg, S: "SUCCEED", F: "FAILED", H: "HAS", N: "NIL", };