| Linux premium331.web-hosting.com 4.18.0-553.80.1.lve.el8.x86_64 #1 SMP Wed Oct 22 19:29:36 UTC 2025 x86_64 Path : /home/livedhms/lmgt/node_modules/better-result/dist/ |
| Current File : /home/livedhms/lmgt/node_modules/better-result/dist/index.mjs |
function e(e,t){return e===2?((...e)=>e.length>=2?t(e[0],e[1]):n=>t(n,e[0])):e===3?((...e)=>e.length>=3?t(e[0],e[1],e[2]):n=>t(n,e[0],e[1])):e===4?((...e)=>e.length>=4?t(e[0],e[1],e[2],e[3]):n=>t(n,e[0],e[1],e[2])):((...n)=>n.length>=e?t(...n):e=>t(e,...n))}const t=e=>e instanceof Error?{name:e.name,message:e.message,stack:e.stack}:e,n=e=>e instanceof Error&&`_tag`in e&&typeof e._tag==`string`,r=Object.assign(e=>()=>{class n extends Error{_tag=e;static is(e){return e instanceof n}constructor(t){let n=t&&`message`in t&&typeof t.message==`string`?t.message:void 0,r=t&&`cause`in t?t.cause:void 0;if(super(n,r===void 0?void 0:{cause:r}),t&&Object.assign(this,t),Object.setPrototypeOf(this,new.target.prototype),this.name=e,r instanceof Error&&r.stack){let e=r.stack.replace(/\n/g,`
`);this.stack=`${this.stack}\nCaused by: ${e}`}}toJSON(){return{...this,_tag:this._tag,name:this.name,message:this.message,cause:t(this.cause),stack:this.stack}}}return n},{is:n}),i=e(2,(e,t)=>{let n=t[e._tag];return n(e)}),a=e(3,(e,t,n)=>{let r=t[e._tag];return typeof r==`function`?r(e):n(e)}),o=n;var s=class extends r(`UnhandledException`)(){constructor(e){let t=e.cause instanceof Error?`Unhandled exception: ${e.cause.message}`:`Unhandled exception: ${String(e.cause)}`;super({message:t,cause:e.cause})}},c=class extends r(`Panic`)(){},l=class extends r(`ResultDeserializationError`)(){constructor(e){super({message:`Failed to deserialize value as Result: expected { status: "ok", value } or { status: "error", error }`,value:e.value})}};const u=e=>e instanceof c,d=(e,t)=>{throw new c({message:e,cause:t})},f=(e,t)=>{try{return e()}catch(e){throw d(t,e)}},p=async(e,t)=>{try{return await e()}catch(e){throw d(t,e)}};var m=class e{status=`ok`;constructor(e){this.value=e}isOk(){return!0}isErr(){return!1}map(t){return f(()=>new e(t(this.value)),`map callback threw`)}mapError(e){return this}tryRecover(e){return this}tryRecoverAsync(e){return Promise.resolve(this)}andThen(e){return f(()=>e(this.value),`andThen callback threw`)}andThenAsync(e){return p(()=>e(this.value),`andThenAsync callback threw`)}match(e){return f(()=>e.ok(this.value),`match ok handler threw`)}unwrap(e){return this.value}unwrapOr(e){return this.value}tap(e){return f(()=>(e(this.value),this),`tap callback threw`)}tapAsync(e){return p(async()=>(await e(this.value),this),`tapAsync callback threw`)}tapError(e){return this}tapErrorAsync(e){return Promise.resolve(this)}tapBoth(e){return f(()=>(e.ok(this.value),this),`tapBoth ok callback threw`)}tapBothAsync(e){return p(async()=>(await e.ok(this.value),this),`tapBothAsync ok callback threw`)}*[Symbol.iterator](){return this.value}},h=class e{status=`error`;constructor(e){this.error=e}isOk(){return!1}isErr(){return!0}map(e){return this}mapError(t){return f(()=>new e(t(this.error)),`mapError callback threw`)}tryRecover(e){return f(()=>e(this.error),`tryRecover callback threw`)}tryRecoverAsync(e){return p(()=>e(this.error),`tryRecoverAsync callback threw`)}andThen(e){return this}andThenAsync(e){return Promise.resolve(this)}match(e){return f(()=>e.err(this.error),`match err handler threw`)}unwrap(e){return d(e??`Unwrap called on Err: ${String(this.error)}`,this.error)}unwrapOr(e){return e}tap(e){return this}tapError(e){return f(()=>(e(this.error),this),`tapError callback threw`)}tapAsync(e){return Promise.resolve(this)}tapErrorAsync(e){return p(async()=>(await e(this.error),this),`tapErrorAsync callback threw`)}tapBoth(e){return f(()=>(e.err(this.error),this),`tapBoth err callback threw`)}tapBothAsync(e){return p(async()=>(await e.err(this.error),this),`tapBothAsync err callback threw`)}*[Symbol.iterator](){return yield this,d(`Unreachable: Err yielded in Result.gen but generator continued`,this.error)}};function g(e){return new m(e)}const _=e=>e.status===`ok`,v=e=>new h(e),y=e=>e.status===`error`,b=(e,t)=>{let n=()=>{if(typeof e==`function`)try{return g(e())}catch(e){return v(new s({cause:e}))}try{return g(e.try())}catch(t){try{return v(e.catch(t))}catch(e){throw d(`Result.try catch handler threw`,e)}}},r=t?.retry?.times??0,i=n();for(let e=0;e<r&&i.status===`error`;e++)i=n();return i},x=async(e,t)=>{let n=async()=>{if(typeof e==`function`)try{return g(await e())}catch(e){return v(new s({cause:e}))}try{return g(await e.try())}catch(t){try{return v(await e.catch(t))}catch(e){throw d(`Result.tryPromise catch handler threw`,e)}}},r=t?.retry;if(!r)return n();let i=e=>{switch(r.backoff){case`constant`:return r.delayMs;case`linear`:return r.delayMs*(e+1);case`exponential`:return r.delayMs*2**e}},a=e=>new Promise(t=>setTimeout(t,e)),o=await n(),c=r.shouldRetry??(()=>!0);for(let e=0;e<r.times&&o.status===`error`;e++){let t=o.error;if(!f(()=>c(t),`shouldRetry predicate threw`))break;await a(i(e)),o=await n()}return o},S=e(2,(e,t)=>e.map(t)),C=e(2,(e,t)=>e.mapError(t)),w=e(2,(e,t)=>e.tryRecover(t)),T=e(2,(e,t)=>e.andThen(t)),E=e(2,(e,t)=>e.tryRecoverAsync(t)),D=e(2,(e,t)=>e.andThenAsync(t)),O=e(2,(e,t)=>e.match(t)),k=e(2,(e,t)=>e.tap(t)),A=e(2,(e,t)=>e.tapAsync(t)),j=e(2,(e,t)=>e.tapError(t)),M=e(2,(e,t)=>e.tapErrorAsync(t)),N=e(2,(e,t)=>e.tapBoth(t)),P=e(2,(e,t)=>e.tapBothAsync(t)),F=(e,t)=>e.unwrap(t);function I(e){if(!(typeof e==`object`&&e&&`status`in e&&(e.status===`ok`||e.status===`error`)))return d(`Result.gen body must return Result.ok() or Result.err(), got: `+(e===null?`null`:typeof e==`object`?JSON.stringify(e):String(e)))}const L=e(2,(e,t)=>e.unwrapOr(t)),R=((e,t)=>{let n=e.call(t);if(Symbol.asyncIterator in n)return(async()=>{let e=n,t;try{t=await e.next()}catch(e){throw d(`generator body threw`,e)}if(I(t.value),!t.done)try{await e.return?.(void 0)}catch(e){throw d(`generator cleanup threw`,e)}return t.value})();let r=n,i;try{i=r.next()}catch(e){throw d(`generator body threw`,e)}if(I(i.value),!i.done)try{r.return?.(void 0)}catch(e){throw d(`generator cleanup threw`,e)}return i.value});async function*z(e){return yield*await e}function B(e){return typeof e==`object`&&!!e&&`status`in e&&(e.status===`ok`&&`value`in e||e.status===`error`&&`error`in e)}const V=e=>e.status===`ok`?{status:`ok`,value:e.value}:{status:`error`,error:e.error},H=e=>B(e)?e.status===`ok`?new m(e.value):new h(e.error):v(new l({value:e})),U={ok:g,isOk:_,err:v,isError:y,try:b,tryPromise:x,map:S,mapError:C,tryRecover:w,andThen:T,tryRecoverAsync:E,andThenAsync:D,match:O,tap:k,tapAsync:A,tapError:j,tapErrorAsync:M,tapBoth:N,tapBothAsync:P,unwrap:F,unwrapOr:L,gen:R,await:z,serialize:V,deserialize:H,hydrate:e=>H(e),partition:e=>{let t=[],n=[];for(let r of e)r.status===`ok`?t.push(r.value):n.push(r.error);return[t,n]},flatten:e=>e.status===`ok`?e.value:e};export{h as Err,m as Ok,c as Panic,U as Result,l as ResultDeserializationError,r as TaggedError,s as UnhandledException,u as isPanic,o as isTaggedError,i as matchError,a as matchErrorPartial,d as panic};
//# sourceMappingURL=index.mjs.map