gnablib
Version:
A lean, zero dependency library to provide a useful base for your project.
2 lines • 644 B
JavaScript
/*! Copyright 2023-2024 the gnablib contributors MPL-1.1 */
import{utf8 as t}from"../../codec/Utf8.js";import{FromBinResult as r}from"../../primitive/FromBinResult.js";import{sLen as e}from"../../safe/safe.js";export class Plane{constructor(t,r){e("char",t).exactly(1).throwNot(),this.char=t,this.human=r}get isCtrl(){return"c"===this.char}toBin(){return t.toBytes(this.char)}static get Control(){return new Plane("c","control")}static get Data(){return new Plane("d","data")}static fromBin(t,e=0){switch(t[e]){case 99:return new r(1,Plane.Control);case 100:return new r(1,Plane.Data)}return new r(0,void 0,"Plane.fromBin unrecognized plane")}}