@brimdata/zealot
Version:
The Javascript Client for Zed Lakes
55 lines (54 loc) • 1.49 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
Object.defineProperty(exports, "Set", {
enumerable: true,
get: ()=>Set
});
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 Set {
indexOf(value) {
if ((0, _isNull.isNull)(this.items)) return -1;
return this.items.indexOf(value);
}
at(index) {
if ((0, _isNull.isNull)(this.items)) return undefined;
return this.items[index];
}
toString() {
if ((0, _isNull.isNull)(this.items)) return "null";
const contents = this.items.map((i)=>i.toString()).join(",");
return `|[${contents}]|`;
}
serialize(stream) {
if ((0, _isNull.isNull)(this.items)) return null;
return this.items.map((i)=>stream.encodeValue(i));
}
isUnset() {
return (0, _isNull.isNull)(this.items);
}
toJS(opts = {}) {
if ((0, _isNull.isNull)(this.items)) return null;
return this.items.map((i)=>i.toJS(opts));
}
constructor(type, items){
_defineProperty(this, "type", void 0);
_defineProperty(this, "items", void 0);
this.type = type;
this.items = items;
}
}