UNPKG

@brimdata/zealot

Version:

The Javascript Client for Zed Lakes

53 lines (52 loc) 1.44 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); Object.defineProperty(exports, "Union", { enumerable: true, get: ()=>Union }); const _isNull = require("../utils/is-null"); 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 Union { toString() { if ((0, _isNull.isNull)(this.value)) return "null"; return this.value.toString(); } serialize(stream) { if ((0, _isNull.isNull)(this.index) || (0, _isNull.isNull)(this.value)) return null; return [ this.index.toString(), stream.encodeValue(this.value) ]; } isUnset() { return (0, _isNull.isNull)(this.index) || (0, _isNull.isNull)(this.value); } toJS() { if (this.isUnset()) return null; return this.value?.toJS(); } constructor(type, innerType, index, value){ _defineProperty(this, "type", void 0); _defineProperty(this, "innerType", void 0); _defineProperty(this, "index", void 0); _defineProperty(this, "value", void 0); this.type = type; this.innerType = innerType; this.index = index; this.value = value; } }