UNPKG

gnablib

Version:

A lean, zero dependency library to provide a useful base for your project.

2 lines 886 B
/*! Copyright 2023-2024 the gnablib contributors MPL-1.1 */ import{FromBinResult as o}from"../../primitive/FromBinResult.js";import{ColType as n}from"./ColType.js";import{ACudColType as r}from"./ACudColType.js";import{TypeProblem as e}from"../../error/probs/TypeProblem.js";import{ContentError as t}from"../../error/ContentError.js";export class Bool extends r{constructor(o=!1){super(o),this.mysqlType="tinyint(1)",this.sqliteType="TINYINT",this.postgresType="boolean",this.cudType="bool",this._colType=n.Bool}cudByteSize(){return 1}valid(o){if(null==o&&!this.nullable)return e.Null("input")}unknownBin(o){if(!o){if(!this.nullable)throw new t("cannot be null","Bool",void 0);return new Uint8Array([0])}const n=new Uint8Array(2);return n[0]=1,n[1]=o?1:0,n}binUnknown(n,r){return 0===n[r]?this.nullable?new o(1,void 0):new o(0,void 0,"Bool.binUnknown cannot be null"):new o(2,0!==n[1])}}