@cloudquery/plugin-sdk-javascript
Version:
This is the high-level package to use for developing CloudQuery plugins in JavaScript
48 lines • 1.23 kB
JavaScript
import { Bool as ArrowBool } from '@apache-arrow/esnext-esm';
import { boolean, isBooleanable } from 'boolean';
import { FormatError } from '../errors/errors.js';
import { isInvalid, NULL_VALUE } from './util.js';
export class Bool {
_valid = false;
_value = null;
constructor(v) {
this.value = v;
return this;
}
get dataType() {
return new ArrowBool();
}
get valid() {
return this._valid;
}
get value() {
if (!this._valid) {
return null;
}
return this._value;
}
set value(value) {
if (isInvalid(value)) {
this._valid = false;
return;
}
if (value instanceof Bool) {
this._valid = value.valid;
this._value = value.value;
return;
}
if (isBooleanable(value)) {
this._value = boolean(value);
this._valid = true;
return;
}
throw new FormatError(`Unable to set Bool from value`, { props: { value } });
}
toString() {
if (this._valid) {
return String(this._value);
}
return NULL_VALUE;
}
}
//# sourceMappingURL=bool.js.map