@tsed/schema
Version:
JsonSchema module for Ts.ED Framework
25 lines (24 loc) • 650 B
JavaScript
import { isFunction } from "@tsed/core";
import { execMapper } from "../registries/JsonSchemaMapperContainer.js";
export class JsonMap extends Map {
constructor(obj = {}) {
super();
this.$kind = "map";
this.$isJsonDocument = true;
this.assign(obj);
}
assign(obj = {}) {
Object.entries(obj).forEach(([key, value]) => {
if (isFunction(this[key])) {
this[key](value);
}
else {
this.set(key, value);
}
});
return this;
}
toJSON(options) {
return execMapper("map", [this], options);
}
}