@brimdata/zealot
Version:
The Javascript Client for Zed Lakes
57 lines (56 loc) • 1.5 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
Object.defineProperty(exports, "TypeAlias", {
enumerable: true,
get: ()=>TypeAlias
});
const _typeRecord = require("./type-record");
function _defineProperty(obj, key, value) {
if (key in obj) {
Object.defineProperty(obj, key, {
value: value,
enumerable: true,
configurable: true,
writable: true
});
} else {
obj[key] = value;
}
return obj;
}
class TypeAlias {
static stringify(name, type) {
return name + "=(" + type.toString() + ")";
}
create(value, stream, parent) {
let v;
if (this.type instanceof _typeRecord.TypeRecord || this.type instanceof TypeAlias) {
v = this.type.create(value, stream, parent);
} else {
v = this.type.create(value, stream);
}
v.type = this // a better way to do this?
;
return v;
}
serialize(stream) {
return {
kind: "named",
name: this.name,
type: stream.encodeType(this.type)
};
}
toString() {
return this.name + "=(" + this.type.toString() + ")";
}
constructor(name, type){
_defineProperty(this, "name", void 0);
_defineProperty(this, "type", void 0);
_defineProperty(this, "kind", void 0);
this.name = name;
this.type = type;
this.kind = "alias";
}
}