create-abi
Version:
Interactive CLI for create Abi.js projects.
2 lines (1 loc) • 1.94 kB
JavaScript
import{M as l,N as c,O as h}from"./chunk-5AAY5SUW.js";import{statSync as u}from"fs";import{pathExistsSync as m}from"fs-extra/esm";var p=class{constructor(e){this.program=e}intercept(e,r){return this.program.intercept(e,r),this}async scanString(e,r){let n=r===void 0?await this.program.scanString(e):await this.program.scanString(e,r);return new t(n)}async scanBoolean(e,r,n){let i=n===void 0?await this.program.scanBoolean(e,r):await this.program.scanBoolean(e,r,n);return new t(i)}async scanChoice(e,r,n){let i=n===void 0?await this.program.scanChoice(e,r):await this.program.scanChoice(e,r,n);return new t(i)}parse(e){return new o(this.program.parse(e))}async interact(e){return new o(await this.program.interact(e))}async execute(e){let r=await this.program.execute(e);return new a(r)}async run(e){let r=await this.program.run(e);return new a(r)}},o=class{constructor(e){this.definition=e}has(e,...r){if(r.length){for(let n of[e,...r])if(!this.has(n))return!1;return!0}return e in this.definition}get(e){let r=Object.entries(this.definition).find(([n,i])=>n===e);return new t(r?r[1]:void 0)}},t=class{constructor(e){this.value=e}isUndefined(){return typeof this.value>"u"}isNull(){return this.value===null}isBoolean(){return h(this.value)}isTrue(){return this.value===!0}isFalse(){return this.value===!1}isNumber(e){return c(this.value)&&e?e(this.value):!0}isString(e){return l(this.value)&&e?e(this.value):!0}equals(e){return this.value===e}},a=class{constructor(e){this.result=e}isSuccess(){return this.result===0}isFailure(){return this.result===1}isInvalid(){return this.result===2}isUnknown(){return![0,1,2].includes(this.result)}},g=class{constructor(e){this.path=e}isFile(){return u(this.path).isFile()}isDir(){return u(this.path).isDirectory()}isSymbolicLink(){return u(this.path).isSymbolicLink()}exists(){return m(this.path)}};export{o as DefinitionTester,g as PathTester,p as ProgramTester,a as ResultTester,t as ValueTester};