functype 0.46.1 → 0.47.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
1
- import { mn as Doable, nn as Reshapeable, pn as DoResult } from "../Functype-Dc440LS5.js";
1
+ import { mn as Doable, nn as Reshapeable, pn as DoResult } from "../Functype-Boat1fLo.js";
2
2
  import { Try } from "../try/index.js";
3
3
  import { Option } from "../option/index.js";
4
4
  import { List } from "../list/index.js";
@@ -1,5 +1,5 @@
1
- import { an as AsyncMonad, dn as Extractable, mn as Doable, n as FunctypeBase, nn as Reshapeable, rn as Promisable } from "../Functype-Dc440LS5.js";
2
- import { l as Type } from "../Typeable-E4-aX9Gc.js";
1
+ import { an as AsyncMonad, dn as Extractable, mn as Doable, n as FunctypeBase, nn as Reshapeable, rn as Promisable } from "../Functype-Boat1fLo.js";
2
+ import { l as Type } from "../Typeable-lfO2nRVW.js";
3
3
  import { Option } from "../option/index.js";
4
4
  import { List } from "../list/index.js";
5
5
 
@@ -1,2 +1,2 @@
1
- import{rt as e}from"../Valuable-BlffnwkD.js";import{t}from"../Companion-VlxcFhzb.js";import{None as n,Some as r}from"../option/index.js";import{Try as i}from"../try/index.js";import{List as a}from"../list/index.js";import o from"safe-stable-stringify";const s=t=>({_tag:`Right`,value:t,isLeft(){return!1},isRight(){return!0},orElse:e=>t,orThrow:()=>t,or:e=>l(t),orNull:()=>t,orUndefined:()=>t,map:e=>l(e(t)),ap:e=>e._tag===`Right`?l(e.value(t)):u(e.value),mapAsync:e=>e(t).then(e=>l(e)).catch(e=>Promise.resolve(u(e))),merge:e=>e.isLeft()?u(e.value):l([t,e.value]),flatMap:e=>e(t),flatMapAsync:e=>e(t).catch(e=>u(e)),toOption:()=>r(t),toList:()=>a([t]),toEither:e=>l(t),toTry:()=>i(()=>t),toJSON(){return{_tag:`Right`,value:t}},toString:()=>`Right(${o(t)})`,*[Symbol.iterator](){yield t},*yield(){yield t},traverse:e=>{let n=e(t);return n.isLeft()?u(n.value):l([n.value])},*lazyMap(e){yield l(e(t))},tap:e=>(e(t),l(t)),tapLeft:e=>l(t),mapLeft:e=>l(t),bimap:(e,n)=>l(n(t)),fold:(e,n)=>n(t),foldLeft:e=>n=>n(e,t),foldRight:e=>n=>n(t,e),match:e=>e.Right(t),swap:()=>u(t),toPromise:()=>Promise.resolve(t),toValue:()=>({_tag:`Right`,value:t}),pipeEither:(e,n)=>n(t),pipe:e=>e(t),serialize:()=>e(`Right`,t),get size(){return 1},get isEmpty(){return!1},contains:e=>t===e,reduce:e=>t,reduceRight:e=>t,count:e=>e(t)?1:0,find:e=>e(t)?r(t):n(),exists:e=>e(t),forEach:e=>e(t),doUnwrap(){return{ok:!0,value:t}}}),c=t=>({_tag:`Left`,value:t,isLeft(){return!0},isRight(){return!1},orElse:e=>e,orThrow:e=>{throw e??t},or:e=>e,orNull:()=>null,orUndefined:()=>void 0,map:e=>u(t),ap:e=>u(t),mapAsync:e=>Promise.resolve(u(t)),merge:e=>u(t),flatMap:e=>u(t),flatMapAsync:e=>Promise.resolve(u(t)),toOption:()=>n(),toList:()=>a(),toEither:e=>u(e),toTry:()=>i(()=>{throw Error(String(t))}),toJSON(){return{_tag:`Left`,value:t}},toString:()=>`Left(${o(t)})`,*[Symbol.iterator](){},*yield(){},traverse:e=>u(t),*lazyMap(e){yield u(t)},tap:e=>u(t),tapLeft:e=>(e(t),u(t)),mapLeft:e=>u(e(t)),bimap:(e,n)=>u(e(t)),fold:(e,n)=>e(t),foldLeft:e=>t=>e,foldRight:e=>t=>e,match:e=>e.Left(t),swap:()=>l(t),toPromise:()=>Promise.reject(t),toValue:()=>({_tag:`Left`,value:t}),pipeEither:(e,n)=>e(t),pipe:e=>e(t),serialize:()=>e(`Left`,t),get size(){return 0},get isEmpty(){return!0},contains:e=>!1,reduce:e=>{throw Error(`Cannot reduce a Left`)},reduceRight:e=>{throw Error(`Cannot reduceRight a Left`)},count:e=>0,find:e=>n(),exists:e=>!1,forEach:e=>{},doUnwrap(){return{ok:!1,empty:!1,error:t}}}),l=e=>s(e),u=e=>c(e),d=e=>e.isRight(),f=e=>e.isLeft(),p=(e,t)=>{try{return l(e())}catch(e){return u(t(e))}},m=e=>s(e);console.assert(m);const h=e=>c(e);console.assert(h);const g=async(e,t)=>{try{return l(await e())}catch(e){return u(t(e))}},_=(e,t)=>t?l(e):u(e),v={left:e=>u(e),right:e=>l(e),isRight:e=>e.isRight(),isLeft:e=>e.isLeft(),sequence:e=>e.reduce((e,t)=>e.isLeft()?e:t.isLeft()?u(t.value):e.map(e=>[...e,t.value]),l([])),traverse:(e,t)=>v.sequence(e.map(t)),fromNullable:(e,t)=>e==null?u(t):l(e),fromPredicate:(e,t,n)=>t(e)?l(e):u(n),ap:(e,t)=>e.flatMap(e=>t.map(e)),fromPromise:async(e,t)=>{try{return l(await e)}catch(e){return u(t(e))}},fromJSON:e=>{let t=JSON.parse(e);return t._tag===`Right`?l(t.value):u(t.value)},fromYAML:e=>{let t=e.split(`
1
+ import{nt as e}from"../Valuable-DeccMyYD.js";import{t}from"../Companion-VlxcFhzb.js";import{None as n,Some as r}from"../option/index.js";import{Try as i}from"../try/index.js";import{List as a}from"../list/index.js";import o from"safe-stable-stringify";const s=t=>({_tag:`Right`,value:t,isLeft(){return!1},isRight(){return!0},orElse:e=>t,orThrow:()=>t,or:e=>l(t),orNull:()=>t,orUndefined:()=>t,map:e=>l(e(t)),ap:e=>e._tag===`Right`?l(e.value(t)):u(e.value),mapAsync:e=>e(t).then(e=>l(e)).catch(e=>Promise.resolve(u(e))),merge:e=>e.isLeft()?u(e.value):l([t,e.value]),flatMap:e=>e(t),flatMapAsync:e=>e(t).catch(e=>u(e)),toOption:()=>r(t),toList:()=>a([t]),toEither:e=>l(t),toTry:()=>i(()=>t),toJSON(){return{_tag:`Right`,value:t}},toString:()=>`Right(${o(t)})`,*[Symbol.iterator](){yield t},*yield(){yield t},traverse:e=>{let n=e(t);return n.isLeft()?u(n.value):l([n.value])},*lazyMap(e){yield l(e(t))},tap:e=>(e(t),l(t)),tapLeft:e=>l(t),mapLeft:e=>l(t),bimap:(e,n)=>l(n(t)),fold:(e,n)=>n(t),foldLeft:e=>n=>n(e,t),foldRight:e=>n=>n(t,e),match:e=>e.Right(t),swap:()=>u(t),toPromise:()=>Promise.resolve(t),toValue:()=>({_tag:`Right`,value:t}),pipeEither:(e,n)=>n(t),pipe:e=>e(t),serialize:()=>e(`Right`,t),get size(){return 1},get isEmpty(){return!1},contains:e=>t===e,reduce:e=>t,reduceRight:e=>t,count:e=>e(t)?1:0,find:e=>e(t)?r(t):n(),exists:e=>e(t),forEach:e=>e(t),doUnwrap(){return{ok:!0,value:t}}}),c=t=>({_tag:`Left`,value:t,isLeft(){return!0},isRight(){return!1},orElse:e=>e,orThrow:e=>{throw e??t},or:e=>e,orNull:()=>null,orUndefined:()=>void 0,map:e=>u(t),ap:e=>u(t),mapAsync:e=>Promise.resolve(u(t)),merge:e=>u(t),flatMap:e=>u(t),flatMapAsync:e=>Promise.resolve(u(t)),toOption:()=>n(),toList:()=>a(),toEither:e=>u(e),toTry:()=>i(()=>{throw Error(String(t))}),toJSON(){return{_tag:`Left`,value:t}},toString:()=>`Left(${o(t)})`,*[Symbol.iterator](){},*yield(){},traverse:e=>u(t),*lazyMap(e){yield u(t)},tap:e=>u(t),tapLeft:e=>(e(t),u(t)),mapLeft:e=>u(e(t)),bimap:(e,n)=>u(e(t)),fold:(e,n)=>e(t),foldLeft:e=>t=>e,foldRight:e=>t=>e,match:e=>e.Left(t),swap:()=>l(t),toPromise:()=>Promise.reject(t),toValue:()=>({_tag:`Left`,value:t}),pipeEither:(e,n)=>e(t),pipe:e=>e(t),serialize:()=>e(`Left`,t),get size(){return 0},get isEmpty(){return!0},contains:e=>!1,reduce:e=>{throw Error(`Cannot reduce a Left`)},reduceRight:e=>{throw Error(`Cannot reduceRight a Left`)},count:e=>0,find:e=>n(),exists:e=>!1,forEach:e=>{},doUnwrap(){return{ok:!1,empty:!1,error:t}}}),l=e=>s(e),u=e=>c(e),d=e=>e.isRight(),f=e=>e.isLeft(),p=(e,t)=>{try{return l(e())}catch(e){return u(t(e))}},m=e=>s(e);console.assert(m);const h=e=>c(e);console.assert(h);const g=async(e,t)=>{try{return l(await e())}catch(e){return u(t(e))}},_=(e,t)=>t?l(e):u(e),v={left:e=>u(e),right:e=>l(e),isRight:e=>e.isRight(),isLeft:e=>e.isLeft(),sequence:e=>e.reduce((e,t)=>e.isLeft()?e:t.isLeft()?u(t.value):e.map(e=>[...e,t.value]),l([])),traverse:(e,t)=>v.sequence(e.map(t)),fromNullable:(e,t)=>e==null?u(t):l(e),fromPredicate:(e,t,n)=>t(e)?l(e):u(n),ap:(e,t)=>e.flatMap(e=>t.map(e)),fromPromise:async(e,t)=>{try{return l(await e)}catch(e){return u(t(e))}},fromJSON:e=>{let t=JSON.parse(e);return t._tag===`Right`?l(t.value):u(t.value)},fromYAML:e=>{let t=e.split(`
2
2
  `),n=t[0]?.split(`: `)[1],r=t[1]?.split(`: `)[1];if(!n||!r)throw Error(`Invalid YAML format for Either`);let i=JSON.parse(r);return n===`Right`?l(i):u(i)},fromBinary:e=>{let t=Buffer.from(e,`base64`).toString();return v.fromJSON(t)}},y=t(_,v);export{y as Either,u as Left,l as Right,h as TypeCheckLeft,m as TypeCheckRight,f as isLeft,d as isRight,p as tryCatch,g as tryCatchAsync};