socket.io-ts-controllers
Version:
Use class-based controllers to handle websocket events
27 lines (25 loc) • 783 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
var isString = function (value) { return (typeof value === "string" || Object.prototype.toString.call(value) === "[object String]"); };
var isPlainObject = function (value) { return (Object.prototype.toString.call(value) === "[object Object]"); };
var isJSON = function (str, options) {
if (options === void 0) { options = {}; }
if (isPlainObject(str) && options.allowObjects === true) {
return true;
}
if (!isString(str)) {
return false;
}
if (!isNaN(str)) {
return false;
}
try {
JSON.parse(str);
}
catch (error) {
return false;
}
return true;
};
exports.default = isJSON;
//# sourceMappingURL=is-valid-json.js.map