ts-std-lib
Version:
A standard library for typescript
28 lines • 839 B
JavaScript
;
var _a;
Object.defineProperty(exports, "__esModule", { value: true });
exports.URLJsonSerializer = void 0;
const url_1 = require("url");
const IJsonSerializer_1 = require("./IJsonSerializer");
const Type_1 = require("../../Type");
const UnexpectedJsonError_1 = require("./UnexpectedJsonError");
/**
* Json serializer for the node URL class
*/
class URLJsonSerializer {
constructor() {
this[_a] = true;
}
serialize(object) {
return object;
}
deserialize(json) {
if (!Type_1.Type.isString(json)) {
throw new UnexpectedJsonError_1.UnexpectedJsonError(json);
}
return new url_1.URL(json);
}
}
exports.URLJsonSerializer = URLJsonSerializer;
_a = IJsonSerializer_1.jsonSerializer;
//# sourceMappingURL=URLJsonSerializer.js.map