gnablib
Version:
A lean, zero dependency library to provide a useful base for your project.
2 lines • 910 B
JavaScript
/*! Copyright 2023-2024 the gnablib contributors MPL-1.1 */
import{utf as t}from"../../primitive/Utf.js";import{sLen as o}from"../../safe/safe.js";const r=Symbol.for("nodejs.util.inspect.custom");export class CharMatch{constructor(t){"string"==typeof t?(o("code",t).atLeast(1).throwNot(),this._code=t.charCodeAt(0)):this._code=t}match(t){return this._code===t}toString(){return t.printable(this._code)?"'"+String.fromCharCode(this._code)+"'":"\\d"+this._code}[r](){return this.toString()}}export class InsensitiveMatch{constructor(r){"string"==typeof r&&(o("code",r).atLeast(1).throwNot(),r=r.charCodeAt(0)),t.asciiCased(r)?this._code=32|r:this._code=r}match(t){return this._code===(32|t)}toString(){return this._code+"/i"}[r](){return this.toString()}}export class RangeMatch{constructor(t,o){this._low=t,this._high=o}match(t){return!(t<this._low)&&!(t>this._high)}toString(){return this._low+"-"+this._high}}