functype 0.8.4 → 0.8.5

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.
Files changed (52) hide show
  1. package/README.md +21 -3
  2. package/dist/{chunk-6GSI27WU.js → chunk-BEWBKRXZ.js} +1 -1
  3. package/dist/chunk-IETKPB7O.js +1 -0
  4. package/dist/{chunk-OWW7KOUW.mjs → chunk-IGMQOLSH.mjs} +1 -1
  5. package/dist/chunk-XZ7VRBBD.mjs +1 -0
  6. package/dist/collections/index.d.mts +1 -1
  7. package/dist/collections/index.d.ts +1 -1
  8. package/dist/either/Either.d.mts +1 -1
  9. package/dist/either/Either.d.ts +1 -1
  10. package/dist/{index-CVgnoS8m.d.ts → index-BB5BWdxR.d.ts} +1 -0
  11. package/dist/{index-sX_FBeu-.d.mts → index-BYj2UWRP.d.mts} +1 -0
  12. package/dist/index.d.mts +1 -1
  13. package/dist/index.d.ts +1 -1
  14. package/dist/index.js +1 -1
  15. package/dist/index.mjs +1 -1
  16. package/dist/iterable/Seq.d.mts +1 -1
  17. package/dist/iterable/Seq.d.ts +1 -1
  18. package/dist/iterable/index.d.mts +1 -1
  19. package/dist/iterable/index.d.ts +1 -1
  20. package/dist/list/List.d.mts +1 -1
  21. package/dist/list/List.d.ts +1 -1
  22. package/dist/map/Map.d.mts +1 -1
  23. package/dist/map/Map.d.ts +1 -1
  24. package/dist/map/Map.js +1 -1
  25. package/dist/map/Map.mjs +1 -1
  26. package/dist/option/Option.d.mts +1 -1
  27. package/dist/option/Option.d.ts +1 -1
  28. package/dist/serializable/Serializable.d.mts +16 -0
  29. package/dist/serializable/Serializable.d.ts +16 -0
  30. package/dist/serializable/Serializable.js +3 -0
  31. package/dist/serializable/Serializable.mjs +3 -0
  32. package/dist/set/Set.d.mts +1 -1
  33. package/dist/set/Set.d.ts +1 -1
  34. package/dist/try/Try.d.mts +1 -1
  35. package/dist/try/Try.d.ts +1 -1
  36. package/dist/try/Try.js +1 -1
  37. package/dist/try/Try.mjs +1 -1
  38. package/dist/util/index.d.mts +1 -1
  39. package/dist/util/index.d.ts +1 -1
  40. package/dist/util/index.js +1 -1
  41. package/dist/util/index.mjs +1 -1
  42. package/lib/index.d.ts +1 -0
  43. package/package.json +8 -3
  44. package/dist/chunk-JQ7HMWOT.mjs +0 -1
  45. package/dist/chunk-Q65ZRGZH.js +0 -1
  46. package/lib/either/index.d.ts +0 -4
  47. package/lib/list/index.d.ts +0 -4
  48. package/lib/map/index.d.ts +0 -1
  49. package/lib/option/index.d.ts +0 -6
  50. package/lib/set/index.d.ts +0 -1
  51. package/lib/try/index.d.ts +0 -1
  52. package/lib/tuple/index.d.ts +0 -5
package/README.md CHANGED
@@ -1,3 +1,21 @@
1
- ## functype
2
-
3
- A small functional library for TypeScript
1
+ # functype
2
+
3
+ A small functional library for TypeScript inspired by Scala Standard Library.
4
+
5
+ [![Node.js Build](https://github.com/jordanburke/functype/actions/workflows/pnpm-build.yml/badge.svg)](https://github.com/jordanburke/functype/actions/workflows/pnpm-build.yml)
6
+
7
+ ## Installation
8
+
9
+ You can install `functype` using any package manager:
10
+
11
+ ```bash
12
+ npm install functype
13
+ ```
14
+
15
+ ```bash
16
+ pnpm install functype
17
+ ```
18
+
19
+ ```bash
20
+ yarn install functype
21
+ ```
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunk5VTXJIR3js = require('./chunk-5VTXJIR3.js');var _chunkOXLZ6UIZjs = require('./chunk-OXLZ6UIZ.js');var _chunkN3GTVYCOjs = require('./chunk-N3GTVYCO.js');var _chunkAB3QRD66js = require('./chunk-AB3QRD66.js');var o=n=>{let a={values:new (0, _chunk5VTXJIR3js.a)(n)},r=()=>Array.from(a.values.entries()).map(([e,t])=>_chunkOXLZ6UIZjs.a.call(void 0, [e,t])),i=e=>o(new (0, _chunk5VTXJIR3js.a)(a.values).set(e.toArray()[0],e.toArray()[1]).entries()),c=e=>{let t=new (0, _chunk5VTXJIR3js.a)(a.values);return t.delete(e)?o(t.entries()):o(a.values.entries())},m=e=>a.values.get(e[0])===e[1],f=()=>a.values.size,v=e=>o(Array.from(a.values.entries()).map(([t,O])=>[t,e(O)])),M=e=>{let t=o(a.values.entries()).toList();return o(t.flatMap(e).toArray())},T=e=>_chunkAB3QRD66js.e.call(void 0, r()).reduce(e),g=e=>_chunkAB3QRD66js.e.call(void 0, r()).reduceRight(e),y=e=>t=>_chunkAB3QRD66js.e.call(void 0, r()).foldLeft(e)(t),d=e=>t=>_chunkAB3QRD66js.e.call(void 0, r()).foldRight(e)(t),S=e=>_chunkAB3QRD66js.c.call(void 0, a.values.get(e)),b=(e,t)=>_chunkAB3QRD66js.c.call(void 0, a.values.get(e)).getOrElse(t),E=()=>a.values.size===0;return{add:i,remove:c,contains:m,get size(){return f()},map:v,flatMap:M,reduce:T,reduceRight:g,foldLeft:y,foldRight:d,get:S,getOrElse:b,get isEmpty(){return E()},orElse:(e,t)=>_chunkAB3QRD66js.c.call(void 0, a.values.get(e)).orElse(t),toList:()=>_chunkN3GTVYCOjs.b.call(void 0, r()),toSet:()=>_chunkN3GTVYCOjs.a.call(void 0, r()),toString:()=>`Map(${r().toString()})`}},C= exports.a =n=>o(n);exports.a = C;
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkOXLZ6UIZjs = require('./chunk-OXLZ6UIZ.js');var _chunk5VTXJIR3js = require('./chunk-5VTXJIR3.js');var _chunkN3GTVYCOjs = require('./chunk-N3GTVYCO.js');var _chunkAB3QRD66js = require('./chunk-AB3QRD66.js');var o=n=>{let a={values:new (0, _chunk5VTXJIR3js.a)(n)},r=()=>Array.from(a.values.entries()).map(([e,t])=>_chunkOXLZ6UIZjs.a.call(void 0, [e,t])),i=e=>o(new (0, _chunk5VTXJIR3js.a)(a.values).set(e.toArray()[0],e.toArray()[1]).entries()),c=e=>{let t=new (0, _chunk5VTXJIR3js.a)(a.values);return t.delete(e)?o(t.entries()):o(a.values.entries())},m=e=>a.values.get(e[0])===e[1],f=()=>a.values.size,v=e=>o(Array.from(a.values.entries()).map(([t,O])=>[t,e(O)])),M=e=>{let t=o(a.values.entries()).toList();return o(t.flatMap(e).toArray())},T=e=>_chunkAB3QRD66js.e.call(void 0, r()).reduce(e),g=e=>_chunkAB3QRD66js.e.call(void 0, r()).reduceRight(e),y=e=>t=>_chunkAB3QRD66js.e.call(void 0, r()).foldLeft(e)(t),d=e=>t=>_chunkAB3QRD66js.e.call(void 0, r()).foldRight(e)(t),S=e=>_chunkAB3QRD66js.c.call(void 0, a.values.get(e)),b=(e,t)=>_chunkAB3QRD66js.c.call(void 0, a.values.get(e)).getOrElse(t),E=()=>a.values.size===0;return{add:i,remove:c,contains:m,get size(){return f()},map:v,flatMap:M,reduce:T,reduceRight:g,foldLeft:y,foldRight:d,get:S,getOrElse:b,get isEmpty(){return E()},orElse:(e,t)=>_chunkAB3QRD66js.c.call(void 0, a.values.get(e)).orElse(t),toList:()=>_chunkN3GTVYCOjs.b.call(void 0, r()),toSet:()=>_chunkN3GTVYCOjs.a.call(void 0, r()),toString:()=>`Map(${r().toString()})`}},C= exports.a =n=>o(n);exports.a = C;
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkBSQMHA7Ajs = require('./chunk-BSQMHA7A.js');var s=r=>({_tag:"Success",value:r,error:void 0,isSuccess:()=>!0,isFailure:()=>!1,getOrElse:e=>r,orElse:e=>s(r),toEither:()=>_chunkBSQMHA7Ajs.a.call(void 0, r),orThrow:()=>r,map:e=>o(()=>e(r)),flatMap:e=>e(r),valueOf:()=>({_tag:"Success",value:r}),toString:()=>`Success(${JSON.stringify(r)})`}),t=r=>({_tag:"Failure",value:void 0,error:r,isSuccess:()=>!1,isFailure:()=>!0,getOrElse:e=>e,orElse:e=>e,toEither:()=>_chunkBSQMHA7Ajs.b.call(void 0, r),orThrow:()=>{throw r},map:e=>t(r),flatMap:e=>t(r),valueOf:()=>({_tag:"Failure",error:r}),toString:()=>`Failure(${r.message})`}),o= exports.a =r=>{try{return s(r())}catch(e){return t(e instanceof Error?e:new Error(String(e)))}};exports.a = o;
@@ -1 +1 @@
1
- import{a as s}from"./chunk-377WQNCB.mjs";import{a as u}from"./chunk-2I2NKDFN.mjs";import{a as V,b as K}from"./chunk-I7TGEFK5.mjs";import{c as p,e as l}from"./chunk-O7DO2OKU.mjs";var o=n=>{let a={values:new s(n)},r=()=>Array.from(a.values.entries()).map(([e,t])=>u([e,t])),i=e=>o(new s(a.values).set(e.toArray()[0],e.toArray()[1]).entries()),c=e=>{let t=new s(a.values);return t.delete(e)?o(t.entries()):o(a.values.entries())},m=e=>a.values.get(e[0])===e[1],f=()=>a.values.size,v=e=>o(Array.from(a.values.entries()).map(([t,O])=>[t,e(O)])),M=e=>{let t=o(a.values.entries()).toList();return o(t.flatMap(e).toArray())},T=e=>l(r()).reduce(e),g=e=>l(r()).reduceRight(e),y=e=>t=>l(r()).foldLeft(e)(t),d=e=>t=>l(r()).foldRight(e)(t),S=e=>p(a.values.get(e)),b=(e,t)=>p(a.values.get(e)).getOrElse(t),E=()=>a.values.size===0;return{add:i,remove:c,contains:m,get size(){return f()},map:v,flatMap:M,reduce:T,reduceRight:g,foldLeft:y,foldRight:d,get:S,getOrElse:b,get isEmpty(){return E()},orElse:(e,t)=>p(a.values.get(e)).orElse(t),toList:()=>K(r()),toSet:()=>V(r()),toString:()=>`Map(${r().toString()})`}},C=n=>o(n);export{C as a};
1
+ import{a as u}from"./chunk-2I2NKDFN.mjs";import{a as s}from"./chunk-377WQNCB.mjs";import{a as V,b as K}from"./chunk-I7TGEFK5.mjs";import{c as p,e as l}from"./chunk-O7DO2OKU.mjs";var o=n=>{let a={values:new s(n)},r=()=>Array.from(a.values.entries()).map(([e,t])=>u([e,t])),i=e=>o(new s(a.values).set(e.toArray()[0],e.toArray()[1]).entries()),c=e=>{let t=new s(a.values);return t.delete(e)?o(t.entries()):o(a.values.entries())},m=e=>a.values.get(e[0])===e[1],f=()=>a.values.size,v=e=>o(Array.from(a.values.entries()).map(([t,O])=>[t,e(O)])),M=e=>{let t=o(a.values.entries()).toList();return o(t.flatMap(e).toArray())},T=e=>l(r()).reduce(e),g=e=>l(r()).reduceRight(e),y=e=>t=>l(r()).foldLeft(e)(t),d=e=>t=>l(r()).foldRight(e)(t),S=e=>p(a.values.get(e)),b=(e,t)=>p(a.values.get(e)).getOrElse(t),E=()=>a.values.size===0;return{add:i,remove:c,contains:m,get size(){return f()},map:v,flatMap:M,reduce:T,reduceRight:g,foldLeft:y,foldRight:d,get:S,getOrElse:b,get isEmpty(){return E()},orElse:(e,t)=>p(a.values.get(e)).orElse(t),toList:()=>K(r()),toSet:()=>V(r()),toString:()=>`Map(${r().toString()})`}},C=n=>o(n);export{C as a};
@@ -0,0 +1 @@
1
+ import{a,b as T}from"./chunk-PJIXAQSQ.mjs";var s=r=>({_tag:"Success",value:r,error:void 0,isSuccess:()=>!0,isFailure:()=>!1,getOrElse:e=>r,orElse:e=>s(r),toEither:()=>a(r),orThrow:()=>r,map:e=>o(()=>e(r)),flatMap:e=>e(r),valueOf:()=>({_tag:"Success",value:r}),toString:()=>`Success(${JSON.stringify(r)})`}),t=r=>({_tag:"Failure",value:void 0,error:r,isSuccess:()=>!1,isFailure:()=>!0,getOrElse:e=>e,orElse:e=>e,toEither:()=>T(r),orThrow:()=>{throw r},map:e=>t(r),flatMap:e=>t(r),valueOf:()=>({_tag:"Failure",error:r}),toString:()=>`Failure(${r.message})`}),o=r=>{try{return s(r())}catch(e){return t(e instanceof Error?e:new Error(String(e)))}};export{o as a};
@@ -1,4 +1,4 @@
1
- export { d as Collection, C as Converters } from '../index-sX_FBeu-.mjs';
1
+ export { d as Collection, C as Converters } from '../index-BYj2UWRP.mjs';
2
2
  import '../functor/index.mjs';
3
3
  import '../identity/Identity.mjs';
4
4
  import '../tuple/Tuple.mjs';
@@ -1,4 +1,4 @@
1
- export { d as Collection, C as Converters } from '../index-CVgnoS8m.js';
1
+ export { d as Collection, C as Converters } from '../index-BB5BWdxR.js';
2
2
  import '../functor/index.js';
3
3
  import '../identity/Identity.js';
4
4
  import '../tuple/Tuple.js';
@@ -1,5 +1,5 @@
1
1
  import '../functor/index.mjs';
2
- export { E as Either, e as Left, R as Right, f as isLeft, i as isRight, t as tryCatch } from '../index-sX_FBeu-.mjs';
2
+ export { E as Either, e as Left, R as Right, f as isLeft, i as isRight, t as tryCatch } from '../index-BYj2UWRP.mjs';
3
3
  import '../typeable/Typeable.mjs';
4
4
  import '../identity/Identity.mjs';
5
5
  import '../tuple/Tuple.mjs';
@@ -1,5 +1,5 @@
1
1
  import '../functor/index.js';
2
- export { E as Either, e as Left, R as Right, f as isLeft, i as isRight, t as tryCatch } from '../index-CVgnoS8m.js';
2
+ export { E as Either, e as Left, R as Right, f as isLeft, i as isRight, t as tryCatch } from '../index-BB5BWdxR.js';
3
3
  import '../typeable/Typeable.js';
4
4
  import '../identity/Identity.js';
5
5
  import '../tuple/Tuple.js';
@@ -160,6 +160,7 @@ type Try<T> = {
160
160
  getOrElse: (defaultValue: T) => T;
161
161
  orElse: (alternative: Try<T>) => Try<T>;
162
162
  toEither: () => Either<Error, T>;
163
+ orThrow: () => T;
163
164
  map: <U>(f: (value: T) => U) => Try<U>;
164
165
  flatMap: <U>(f: (value: T) => Try<U>) => Try<U>;
165
166
  valueOf: () => {
@@ -160,6 +160,7 @@ type Try<T> = {
160
160
  getOrElse: (defaultValue: T) => T;
161
161
  orElse: (alternative: Try<T>) => Try<T>;
162
162
  toEither: () => Either<Error, T>;
163
+ orThrow: () => T;
163
164
  map: <U>(f: (value: T) => U) => Try<U>;
164
165
  flatMap: <U>(f: (value: T) => Try<U>) => Try<U>;
165
166
  valueOf: () => {
package/dist/index.d.mts CHANGED
@@ -1,5 +1,5 @@
1
1
  export { AbstractFunctor, ArrayFunctor, ArrayType, Functor, SingleType, Type } from './functor/index.mjs';
2
- export { E as Either, e as Left, L as List, M as Map, N as None, O as Option, R as Right, a as Seq, b as Set, S as Some, g as Traversable, T as Try, _ as _Iterable_, f as isLeft, i as isRight, t as tryCatch } from './index-sX_FBeu-.mjs';
2
+ export { E as Either, e as Left, L as List, M as Map, N as None, O as Option, R as Right, a as Seq, b as Set, S as Some, g as Traversable, T as Try, _ as _Iterable_, f as isLeft, i as isRight, t as tryCatch } from './index-BYj2UWRP.mjs';
3
3
  export { Identity } from './identity/Identity.mjs';
4
4
  export { Tuple } from './tuple/Tuple.mjs';
5
5
  export { Typeable } from './typeable/Typeable.mjs';
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  export { AbstractFunctor, ArrayFunctor, ArrayType, Functor, SingleType, Type } from './functor/index.js';
2
- export { E as Either, e as Left, L as List, M as Map, N as None, O as Option, R as Right, a as Seq, b as Set, S as Some, g as Traversable, T as Try, _ as _Iterable_, f as isLeft, i as isRight, t as tryCatch } from './index-CVgnoS8m.js';
2
+ export { E as Either, e as Left, L as List, M as Map, N as None, O as Option, R as Right, a as Seq, b as Set, S as Some, g as Traversable, T as Try, _ as _Iterable_, f as isLeft, i as isRight, t as tryCatch } from './index-BB5BWdxR.js';
3
3
  export { Identity } from './identity/Identity.js';
4
4
  export { Tuple } from './tuple/Tuple.js';
5
5
  export { Typeable } from './typeable/Typeable.js';
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunk5O6YELD3js = require('./chunk-5O6YELD3.js');var _chunk6GSI27WUjs = require('./chunk-6GSI27WU.js');require('./chunk-5VTXJIR3.js');require('./chunk-K3EKBPQE.js');var _chunkQ65ZRGZHjs = require('./chunk-Q65ZRGZH.js');var _chunkOXLZ6UIZjs = require('./chunk-OXLZ6UIZ.js');require('./chunk-XORABVON.js');var _chunkBSQMHA7Ajs = require('./chunk-BSQMHA7A.js');var _chunkN3GTVYCOjs = require('./chunk-N3GTVYCO.js');require('./chunk-3VJERXBP.js');var _chunkAB3QRD66js = require('./chunk-AB3QRD66.js');require('./chunk-BNNK42JC.js');exports.Left = _chunkBSQMHA7Ajs.b; exports.List = _chunkN3GTVYCOjs.b; exports.Map = _chunk6GSI27WUjs.a; exports.None = _chunkAB3QRD66js.b; exports.Option = _chunkAB3QRD66js.c; exports.Right = _chunkBSQMHA7Ajs.a; exports.Seq = _chunkAB3QRD66js.e; exports.Set = _chunkN3GTVYCOjs.a; exports.Some = _chunkAB3QRD66js.a; exports.Try = _chunkQ65ZRGZHjs.a; exports.Tuple = _chunkOXLZ6UIZjs.a; exports.Typeable = _chunk5O6YELD3js.a; exports.isLeft = _chunkBSQMHA7Ajs.d; exports.isRight = _chunkBSQMHA7Ajs.c; exports.tryCatch = _chunkBSQMHA7Ajs.e;
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunk5O6YELD3js = require('./chunk-5O6YELD3.js');var _chunkBEWBKRXZjs = require('./chunk-BEWBKRXZ.js');var _chunkOXLZ6UIZjs = require('./chunk-OXLZ6UIZ.js');require('./chunk-5VTXJIR3.js');var _chunkIETKPB7Ojs = require('./chunk-IETKPB7O.js');var _chunkBSQMHA7Ajs = require('./chunk-BSQMHA7A.js');var _chunkN3GTVYCOjs = require('./chunk-N3GTVYCO.js');require('./chunk-3VJERXBP.js');require('./chunk-XORABVON.js');require('./chunk-K3EKBPQE.js');var _chunkAB3QRD66js = require('./chunk-AB3QRD66.js');require('./chunk-BNNK42JC.js');exports.Left = _chunkBSQMHA7Ajs.b; exports.List = _chunkN3GTVYCOjs.b; exports.Map = _chunkBEWBKRXZjs.a; exports.None = _chunkAB3QRD66js.b; exports.Option = _chunkAB3QRD66js.c; exports.Right = _chunkBSQMHA7Ajs.a; exports.Seq = _chunkAB3QRD66js.e; exports.Set = _chunkN3GTVYCOjs.a; exports.Some = _chunkAB3QRD66js.a; exports.Try = _chunkIETKPB7Ojs.a; exports.Tuple = _chunkOXLZ6UIZjs.a; exports.Typeable = _chunk5O6YELD3js.a; exports.isLeft = _chunkBSQMHA7Ajs.d; exports.isRight = _chunkBSQMHA7Ajs.c; exports.tryCatch = _chunkBSQMHA7Ajs.e;
package/dist/index.mjs CHANGED
@@ -1 +1 @@
1
- import{a as l}from"./chunk-V7DKESTM.mjs";import{a as n}from"./chunk-OWW7KOUW.mjs";import"./chunk-377WQNCB.mjs";import"./chunk-2ML63TYF.mjs";import{a as i}from"./chunk-JQ7HMWOT.mjs";import{a as b}from"./chunk-2I2NKDFN.mjs";import"./chunk-V2J3R5IU.mjs";import{a as m,b as x,c as A,d as a,e as B}from"./chunk-PJIXAQSQ.mjs";import{a as p,b as f}from"./chunk-I7TGEFK5.mjs";import"./chunk-HA5XD5KC.mjs";import{a as o,b as r,c as e,e as t}from"./chunk-O7DO2OKU.mjs";import"./chunk-RRAIFS3D.mjs";export{x as Left,f as List,n as Map,r as None,e as Option,m as Right,t as Seq,p as Set,o as Some,i as Try,b as Tuple,l as Typeable,a as isLeft,A as isRight,B as tryCatch};
1
+ import{a as l}from"./chunk-V7DKESTM.mjs";import{a as n}from"./chunk-IGMQOLSH.mjs";import{a as b}from"./chunk-2I2NKDFN.mjs";import"./chunk-377WQNCB.mjs";import{a as i}from"./chunk-XZ7VRBBD.mjs";import{a as m,b as x,c as A,d as a,e as B}from"./chunk-PJIXAQSQ.mjs";import{a as p,b as f}from"./chunk-I7TGEFK5.mjs";import"./chunk-HA5XD5KC.mjs";import"./chunk-V2J3R5IU.mjs";import"./chunk-2ML63TYF.mjs";import{a as o,b as r,c as e,e as t}from"./chunk-O7DO2OKU.mjs";import"./chunk-RRAIFS3D.mjs";export{x as Left,f as List,n as Map,r as None,e as Option,m as Right,t as Seq,p as Set,o as Some,i as Try,b as Tuple,l as Typeable,a as isLeft,A as isRight,B as tryCatch};
@@ -1,4 +1,4 @@
1
- export { a as Seq, c as createSeq } from '../index-sX_FBeu-.mjs';
1
+ export { a as Seq, c as createSeq } from '../index-BYj2UWRP.mjs';
2
2
  import '../functor/index.mjs';
3
3
  import '../identity/Identity.mjs';
4
4
  import '../tuple/Tuple.mjs';
@@ -1,4 +1,4 @@
1
- export { a as Seq, c as createSeq } from '../index-CVgnoS8m.js';
1
+ export { a as Seq, c as createSeq } from '../index-BB5BWdxR.js';
2
2
  import '../functor/index.js';
3
3
  import '../identity/Identity.js';
4
4
  import '../tuple/Tuple.js';
@@ -1,5 +1,5 @@
1
1
  import '../functor/index.mjs';
2
- export { a as Seq, _ as _Iterable_ } from '../index-sX_FBeu-.mjs';
2
+ export { a as Seq, _ as _Iterable_ } from '../index-BYj2UWRP.mjs';
3
3
  import '../identity/Identity.mjs';
4
4
  import '../tuple/Tuple.mjs';
5
5
  import '../typeable/Typeable.mjs';
@@ -1,5 +1,5 @@
1
1
  import '../functor/index.js';
2
- export { a as Seq, _ as _Iterable_ } from '../index-CVgnoS8m.js';
2
+ export { a as Seq, _ as _Iterable_ } from '../index-BB5BWdxR.js';
3
3
  import '../identity/Identity.js';
4
4
  import '../tuple/Tuple.js';
5
5
  import '../typeable/Typeable.js';
@@ -1,4 +1,4 @@
1
- export { L as List } from '../index-sX_FBeu-.mjs';
1
+ export { L as List } from '../index-BYj2UWRP.mjs';
2
2
  import '../functor/index.mjs';
3
3
  import '../identity/Identity.mjs';
4
4
  import '../tuple/Tuple.mjs';
@@ -1,4 +1,4 @@
1
- export { L as List } from '../index-CVgnoS8m.js';
1
+ export { L as List } from '../index-BB5BWdxR.js';
2
2
  import '../functor/index.js';
3
3
  import '../identity/Identity.js';
4
4
  import '../tuple/Tuple.js';
@@ -1,4 +1,4 @@
1
- export { M as Map } from '../index-sX_FBeu-.mjs';
1
+ export { M as Map } from '../index-BYj2UWRP.mjs';
2
2
  import '../tuple/Tuple.mjs';
3
3
  import '../functor/index.mjs';
4
4
  import '../identity/Identity.mjs';
package/dist/map/Map.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- export { M as Map } from '../index-CVgnoS8m.js';
1
+ export { M as Map } from '../index-BB5BWdxR.js';
2
2
  import '../tuple/Tuple.js';
3
3
  import '../functor/index.js';
4
4
  import '../identity/Identity.js';
package/dist/map/Map.js CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunk6GSI27WUjs = require('../chunk-6GSI27WU.js');require('../chunk-5VTXJIR3.js');require('../chunk-OXLZ6UIZ.js');require('../chunk-N3GTVYCO.js');require('../chunk-3VJERXBP.js');require('../chunk-AB3QRD66.js');require('../chunk-BNNK42JC.js');exports.Map = _chunk6GSI27WUjs.a;
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkBEWBKRXZjs = require('../chunk-BEWBKRXZ.js');require('../chunk-OXLZ6UIZ.js');require('../chunk-5VTXJIR3.js');require('../chunk-N3GTVYCO.js');require('../chunk-3VJERXBP.js');require('../chunk-AB3QRD66.js');require('../chunk-BNNK42JC.js');exports.Map = _chunkBEWBKRXZjs.a;
package/dist/map/Map.mjs CHANGED
@@ -1 +1 @@
1
- import{a}from"../chunk-OWW7KOUW.mjs";import"../chunk-377WQNCB.mjs";import"../chunk-2I2NKDFN.mjs";import"../chunk-I7TGEFK5.mjs";import"../chunk-HA5XD5KC.mjs";import"../chunk-O7DO2OKU.mjs";import"../chunk-RRAIFS3D.mjs";export{a as Map};
1
+ import{a}from"../chunk-IGMQOLSH.mjs";import"../chunk-2I2NKDFN.mjs";import"../chunk-377WQNCB.mjs";import"../chunk-I7TGEFK5.mjs";import"../chunk-HA5XD5KC.mjs";import"../chunk-O7DO2OKU.mjs";import"../chunk-RRAIFS3D.mjs";export{a as Map};
@@ -1,5 +1,5 @@
1
1
  import '../functor/index.mjs';
2
- export { N as None, O as Option, S as Some } from '../index-sX_FBeu-.mjs';
2
+ export { N as None, O as Option, S as Some } from '../index-BYj2UWRP.mjs';
3
3
  import '../typeable/Typeable.mjs';
4
4
  import '../identity/Identity.mjs';
5
5
  import '../tuple/Tuple.mjs';
@@ -1,5 +1,5 @@
1
1
  import '../functor/index.js';
2
- export { N as None, O as Option, S as Some } from '../index-CVgnoS8m.js';
2
+ export { N as None, O as Option, S as Some } from '../index-BB5BWdxR.js';
3
3
  import '../typeable/Typeable.js';
4
4
  import '../identity/Identity.js';
5
5
  import '../tuple/Tuple.js';
@@ -0,0 +1,16 @@
1
+ type SerializableTypes = "json" | "yaml";
2
+ type SerializationMethods<T> = {
3
+ json: {
4
+ toJSON(): string;
5
+ fromJSON(json: string): T;
6
+ };
7
+ yaml: {
8
+ toYAML(): string;
9
+ fromYAML(yaml: string): T;
10
+ };
11
+ };
12
+ type Serializable<STypes extends SerializableTypes[], T> = T & (STypes extends [] ? NonNullable<unknown> : STypes extends [infer First, ...infer Rest] ? First extends keyof SerializationMethods<T> ? SerializationMethods<T>[First] & Serializable<Rest extends SerializableTypes[] ? Rest : [], T> : never : never);
13
+ type SupportedSerializationTypes<T> = T extends Serializable<infer Types, never> ? Types : never;
14
+ declare function createSerializable<STypes extends SerializableTypes[], T>(obj: T, serializationMethods: Pick<SerializationMethods<T>, STypes[number]>): Serializable<STypes, T>;
15
+
16
+ export { type Serializable, type SerializableTypes, type SupportedSerializationTypes, createSerializable };
@@ -0,0 +1,16 @@
1
+ type SerializableTypes = "json" | "yaml";
2
+ type SerializationMethods<T> = {
3
+ json: {
4
+ toJSON(): string;
5
+ fromJSON(json: string): T;
6
+ };
7
+ yaml: {
8
+ toYAML(): string;
9
+ fromYAML(yaml: string): T;
10
+ };
11
+ };
12
+ type Serializable<STypes extends SerializableTypes[], T> = T & (STypes extends [] ? NonNullable<unknown> : STypes extends [infer First, ...infer Rest] ? First extends keyof SerializationMethods<T> ? SerializationMethods<T>[First] & Serializable<Rest extends SerializableTypes[] ? Rest : [], T> : never : never);
13
+ type SupportedSerializationTypes<T> = T extends Serializable<infer Types, never> ? Types : never;
14
+ declare function createSerializable<STypes extends SerializableTypes[], T>(obj: T, serializationMethods: Pick<SerializationMethods<T>, STypes[number]>): Serializable<STypes, T>;
15
+
16
+ export { type Serializable, type SerializableTypes, type SupportedSerializationTypes, createSerializable };
@@ -0,0 +1,3 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});function r(e,t){return{...e,...t}}var i=r({name:"John",age:30},{json:{toJSON(){return JSON.stringify(this)},fromJSON(e){return JSON.parse(e)}},yaml:{toYAML(){return Object.entries(this).map(([e,t])=>`${e}: ${t}`).join(`
2
+ `)},fromYAML(e){return Object.fromEntries(e.split(`
3
+ `).map(t=>t.split(": ")))}}});console.log(i.toJSON());console.log(i.toYAML());exports.createSerializable = r;
@@ -0,0 +1,3 @@
1
+ function r(e,t){return{...e,...t}}var i=r({name:"John",age:30},{json:{toJSON(){return JSON.stringify(this)},fromJSON(e){return JSON.parse(e)}},yaml:{toYAML(){return Object.entries(this).map(([e,t])=>`${e}: ${t}`).join(`
2
+ `)},fromYAML(e){return Object.fromEntries(e.split(`
3
+ `).map(t=>t.split(": ")))}}});console.log(i.toJSON());console.log(i.toYAML());export{r as createSerializable};
@@ -1,4 +1,4 @@
1
- export { b as Set } from '../index-sX_FBeu-.mjs';
1
+ export { b as Set } from '../index-BYj2UWRP.mjs';
2
2
  import '../functor/index.mjs';
3
3
  import '../identity/Identity.mjs';
4
4
  import '../tuple/Tuple.mjs';
package/dist/set/Set.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- export { b as Set } from '../index-CVgnoS8m.js';
1
+ export { b as Set } from '../index-BB5BWdxR.js';
2
2
  import '../functor/index.js';
3
3
  import '../identity/Identity.js';
4
4
  import '../tuple/Tuple.js';
@@ -1,4 +1,4 @@
1
- export { T as Try } from '../index-sX_FBeu-.mjs';
1
+ export { T as Try } from '../index-BYj2UWRP.mjs';
2
2
  import '../typeable/Typeable.mjs';
3
3
  import '../functor/index.mjs';
4
4
  import '../identity/Identity.mjs';
package/dist/try/Try.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- export { T as Try } from '../index-CVgnoS8m.js';
1
+ export { T as Try } from '../index-BB5BWdxR.js';
2
2
  import '../typeable/Typeable.js';
3
3
  import '../functor/index.js';
4
4
  import '../identity/Identity.js';
package/dist/try/Try.js CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkQ65ZRGZHjs = require('../chunk-Q65ZRGZH.js');require('../chunk-BSQMHA7A.js');require('../chunk-N3GTVYCO.js');require('../chunk-3VJERXBP.js');require('../chunk-AB3QRD66.js');require('../chunk-BNNK42JC.js');exports.Try = _chunkQ65ZRGZHjs.a;
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkIETKPB7Ojs = require('../chunk-IETKPB7O.js');require('../chunk-BSQMHA7A.js');require('../chunk-N3GTVYCO.js');require('../chunk-3VJERXBP.js');require('../chunk-AB3QRD66.js');require('../chunk-BNNK42JC.js');exports.Try = _chunkIETKPB7Ojs.a;
package/dist/try/Try.mjs CHANGED
@@ -1 +1 @@
1
- import{a}from"../chunk-JQ7HMWOT.mjs";import"../chunk-PJIXAQSQ.mjs";import"../chunk-I7TGEFK5.mjs";import"../chunk-HA5XD5KC.mjs";import"../chunk-O7DO2OKU.mjs";import"../chunk-RRAIFS3D.mjs";export{a as Try};
1
+ import{a}from"../chunk-XZ7VRBBD.mjs";import"../chunk-PJIXAQSQ.mjs";import"../chunk-I7TGEFK5.mjs";import"../chunk-HA5XD5KC.mjs";import"../chunk-O7DO2OKU.mjs";import"../chunk-RRAIFS3D.mjs";export{a as Try};
@@ -1,4 +1,4 @@
1
- import { E as Either } from '../index-sX_FBeu-.mjs';
1
+ import { E as Either } from '../index-BYj2UWRP.mjs';
2
2
  import { ParseError } from '../error/ParseError.mjs';
3
3
  import '../functor/index.mjs';
4
4
  import '../identity/Identity.mjs';
@@ -1,4 +1,4 @@
1
- import { E as Either } from '../index-CVgnoS8m.js';
1
+ import { E as Either } from '../index-BB5BWdxR.js';
2
2
  import { ParseError } from '../error/ParseError.js';
3
3
  import '../functor/index.js';
4
4
  import '../identity/Identity.js';
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkBSQMHA7Ajs = require('../chunk-BSQMHA7A.js');var _chunkE6RS47F7js = require('../chunk-E6RS47F7.js');require('../chunk-N3GTVYCO.js');require('../chunk-3VJERXBP.js');require('../chunk-AB3QRD66.js');require('../chunk-BNNK42JC.js');var a=o=>{let r=parseInt(o,10);return isNaN(r)?_chunkBSQMHA7Ajs.b.call(void 0, _chunkE6RS47F7js.a.call(void 0, `${r}`)):_chunkBSQMHA7Ajs.a.call(void 0, r)};exports.parseNumber = a;
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkBSQMHA7Ajs = require('../chunk-BSQMHA7A.js');require('../chunk-N3GTVYCO.js');require('../chunk-3VJERXBP.js');var _chunkE6RS47F7js = require('../chunk-E6RS47F7.js');require('../chunk-AB3QRD66.js');require('../chunk-BNNK42JC.js');var a=o=>{let r=parseInt(o,10);return isNaN(r)?_chunkBSQMHA7Ajs.b.call(void 0, _chunkE6RS47F7js.a.call(void 0, `${r}`)):_chunkBSQMHA7Ajs.a.call(void 0, r)};exports.parseNumber = a;
@@ -1 +1 @@
1
- import{a as e,b as t}from"../chunk-PJIXAQSQ.mjs";import{a as s}from"../chunk-VK5GL6NM.mjs";import"../chunk-I7TGEFK5.mjs";import"../chunk-HA5XD5KC.mjs";import"../chunk-O7DO2OKU.mjs";import"../chunk-RRAIFS3D.mjs";var a=o=>{let r=parseInt(o,10);return isNaN(r)?t(s(`${r}`)):e(r)};export{a as parseNumber};
1
+ import{a as e,b as t}from"../chunk-PJIXAQSQ.mjs";import"../chunk-I7TGEFK5.mjs";import"../chunk-HA5XD5KC.mjs";import{a as s}from"../chunk-VK5GL6NM.mjs";import"../chunk-O7DO2OKU.mjs";import"../chunk-RRAIFS3D.mjs";var a=o=>{let r=parseInt(o,10);return isNaN(r)?t(s(`${r}`)):e(r)};export{a as parseNumber};
package/lib/index.d.ts CHANGED
@@ -10,6 +10,7 @@ export type Traversable<A extends Type> = Functor<A> & {
10
10
  };
11
11
  export * from "./either/Either";
12
12
  export * from "./functor";
13
+ export * from "./identity/Identity";
13
14
  export * from "./iterable";
14
15
  export * from "./list/List";
15
16
  export * from "./map/Map";
package/package.json CHANGED
@@ -1,12 +1,17 @@
1
1
  {
2
2
  "name": "functype",
3
- "version": "0.8.4",
3
+ "version": "0.8.5",
4
4
  "description": "A smallish functional library for TypeScript",
5
5
  "author": "jordan.burke@gmail.com",
6
6
  "license": "MIT",
7
+ "repository": {
8
+ "type": "git",
9
+ "url": "git+https://github.com/jordanburke/functype.git"
10
+ },
11
+ "homepage": "https://github.com/jordanburke/functype#readme",
7
12
  "url": "https://github.com/jordanburke/functype",
8
13
  "devDependencies": {
9
- "@types/node": "^20.14.15",
14
+ "@types/node": "^20.16.5",
10
15
  "@typescript-eslint/eslint-plugin": "^7.5.0",
11
16
  "@typescript-eslint/parser": "^7.5.0",
12
17
  "@types/jest": "29.5.13",
@@ -19,7 +24,7 @@
19
24
  "jest": "^29.7.0",
20
25
  "prettier": "^3.3.3",
21
26
  "rimraf": "^6.0.1",
22
- "tsup": "^8.2.4",
27
+ "tsup": "^8.3.0",
23
28
  "ts-jest": "^29.2.5",
24
29
  "ts-node": "^10.9.2",
25
30
  "typescript": "^5.6.2"
@@ -1 +0,0 @@
1
- import{a,b as T}from"./chunk-PJIXAQSQ.mjs";var s=r=>({_tag:"Success",value:r,error:void 0,isSuccess:()=>!0,isFailure:()=>!1,getOrElse:e=>r,orElse:e=>s(r),toEither:()=>a(r),map:e=>l(()=>e(r)),flatMap:e=>e(r),valueOf:()=>({_tag:"Success",value:r}),toString:()=>`Success(${JSON.stringify(r)})`}),t=r=>({_tag:"Failure",value:void 0,error:r,isSuccess:()=>!1,isFailure:()=>!0,getOrElse:e=>e,orElse:e=>e,toEither:()=>T(r),map:e=>t(r),flatMap:e=>t(r),valueOf:()=>({_tag:"Failure",error:r}),toString:()=>`Failure(${r.message})`}),l=r=>{try{return s(r())}catch(e){return t(e instanceof Error?e:new Error(String(e)))}};export{l as a};
@@ -1 +0,0 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkBSQMHA7Ajs = require('./chunk-BSQMHA7A.js');var s=r=>({_tag:"Success",value:r,error:void 0,isSuccess:()=>!0,isFailure:()=>!1,getOrElse:e=>r,orElse:e=>s(r),toEither:()=>_chunkBSQMHA7Ajs.a.call(void 0, r),map:e=>l(()=>e(r)),flatMap:e=>e(r),valueOf:()=>({_tag:"Success",value:r}),toString:()=>`Success(${JSON.stringify(r)})`}),t=r=>({_tag:"Failure",value:void 0,error:r,isSuccess:()=>!1,isFailure:()=>!0,getOrElse:e=>e,orElse:e=>e,toEither:()=>_chunkBSQMHA7Ajs.b.call(void 0, r),map:e=>t(r),flatMap:e=>t(r),valueOf:()=>({_tag:"Failure",error:r}),toString:()=>`Failure(${r.message})`}),l= exports.a =r=>{try{return s(r())}catch(e){return t(e instanceof Error?e:new Error(String(e)))}};exports.a = l;
@@ -1,4 +0,0 @@
1
- import { Either, Left, Right } from "./Either";
2
- export declare const left: <L, R>(value: L) => Either<L, R>;
3
- export declare const right: <L, R>(value: R) => Either<L, R>;
4
- export { Either, Left, Right };
@@ -1,4 +0,0 @@
1
- import { Type } from "../functor";
2
- import { List } from "./List";
3
- declare const list: <T extends Type>(items: T[] | undefined) => List<T>;
4
- export { list, List };
@@ -1 +0,0 @@
1
- export { Map } from "./Map";
@@ -1,6 +0,0 @@
1
- import { Type } from "../functor";
2
- import { None, Option, Some } from "./Option";
3
- export declare const option: <T extends Type>(value?: T) => Option<T>;
4
- export declare const some: <T extends Type>(value: T) => Option<T>;
5
- export declare const none: <T extends Type>() => Option<T>;
6
- export { None, Option, Some };
@@ -1 +0,0 @@
1
- export { Set } from "./Set";
@@ -1 +0,0 @@
1
- export { Try } from "./Try";
@@ -1,5 +0,0 @@
1
- import { ArrayType } from "../functor";
2
- import { Tuple } from "./Tuple";
3
- export { Tuple } from "./Tuple";
4
- export declare const t: <T extends ArrayType>(values: T) => Tuple<T>;
5
- export declare const tuple: <T extends ArrayType>(values: T) => Tuple<T>;