functype 0.8.3 → 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.
- package/README.md +21 -3
- package/dist/chunk-2ML63TYF.mjs +0 -0
- package/dist/{chunk-6GSI27WU.js → chunk-BEWBKRXZ.js} +1 -1
- package/dist/chunk-IETKPB7O.js +1 -0
- package/dist/{chunk-OWW7KOUW.mjs → chunk-IGMQOLSH.mjs} +1 -1
- package/dist/chunk-K3EKBPQE.js +1 -0
- package/dist/chunk-XZ7VRBBD.mjs +1 -0
- package/dist/collections/index.d.mts +2 -1
- package/dist/collections/index.d.ts +2 -1
- package/dist/either/Either.d.mts +2 -1
- package/dist/either/Either.d.ts +2 -1
- package/dist/identity/Identity.js +1 -1
- package/dist/identity/Identity.mjs +1 -0
- package/dist/{index-8YakfACG.d.ts → index-BB5BWdxR.d.ts} +2 -0
- package/dist/{index-5xp8zYMn.d.mts → index-BYj2UWRP.d.mts} +2 -0
- package/dist/index.d.mts +2 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js +1 -1
- package/dist/index.mjs +1 -1
- package/dist/iterable/Seq.d.mts +2 -1
- package/dist/iterable/Seq.d.ts +2 -1
- package/dist/iterable/index.d.mts +2 -1
- package/dist/iterable/index.d.ts +2 -1
- package/dist/list/List.d.mts +2 -1
- package/dist/list/List.d.ts +2 -1
- package/dist/map/Map.d.mts +2 -1
- package/dist/map/Map.d.ts +2 -1
- package/dist/map/Map.js +1 -1
- package/dist/map/Map.mjs +1 -1
- package/dist/option/Option.d.mts +2 -1
- package/dist/option/Option.d.ts +2 -1
- package/dist/serializable/Serializable.d.mts +16 -0
- package/dist/serializable/Serializable.d.ts +16 -0
- package/dist/serializable/Serializable.js +3 -0
- package/dist/serializable/Serializable.mjs +3 -0
- package/dist/set/Set.d.mts +2 -1
- package/dist/set/Set.d.ts +2 -1
- package/dist/try/Try.d.mts +2 -1
- package/dist/try/Try.d.ts +2 -1
- package/dist/try/Try.js +1 -1
- package/dist/try/Try.mjs +1 -1
- package/dist/util/index.d.mts +2 -1
- package/dist/util/index.d.ts +2 -1
- package/lib/index.d.ts +1 -0
- package/package.json +8 -3
- package/dist/chunk-JQ7HMWOT.mjs +0 -1
- package/dist/chunk-Q65ZRGZH.js +0 -1
- package/lib/either/index.d.ts +0 -4
- package/lib/list/index.d.ts +0 -4
- package/lib/map/index.d.ts +0 -1
- package/lib/option/index.d.ts +0 -6
- package/lib/set/index.d.ts +0 -1
- package/lib/try/index.d.ts +0 -1
- package/lib/tuple/index.d.ts +0 -5
package/README.md
CHANGED
|
@@ -1,3 +1,21 @@
|
|
|
1
|
-
|
|
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
|
+
[](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
|
+
```
|
|
File without changes
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var
|
|
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
|
|
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
|
+
"use strict";
|
|
@@ -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,5 @@
|
|
|
1
|
-
export { d as Collection, C as Converters } from '../index-
|
|
1
|
+
export { d as Collection, C as Converters } from '../index-BYj2UWRP.mjs';
|
|
2
2
|
import '../functor/index.mjs';
|
|
3
|
+
import '../identity/Identity.mjs';
|
|
3
4
|
import '../tuple/Tuple.mjs';
|
|
4
5
|
import '../typeable/Typeable.mjs';
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
export { d as Collection, C as Converters } from '../index-
|
|
1
|
+
export { d as Collection, C as Converters } from '../index-BB5BWdxR.js';
|
|
2
2
|
import '../functor/index.js';
|
|
3
|
+
import '../identity/Identity.js';
|
|
3
4
|
import '../tuple/Tuple.js';
|
|
4
5
|
import '../typeable/Typeable.js';
|
package/dist/either/Either.d.mts
CHANGED
|
@@ -1,4 +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-
|
|
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
|
+
import '../identity/Identity.mjs';
|
|
4
5
|
import '../tuple/Tuple.mjs';
|
package/dist/either/Either.d.ts
CHANGED
|
@@ -1,4 +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-
|
|
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
|
+
import '../identity/Identity.js';
|
|
4
5
|
import '../tuple/Tuple.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";
|
|
1
|
+
"use strict";require('../chunk-K3EKBPQE.js');
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import"../chunk-2ML63TYF.mjs";
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Type, Functor } from './functor/index.js';
|
|
2
|
+
import './identity/Identity.js';
|
|
2
3
|
import { Tuple } from './tuple/Tuple.js';
|
|
3
4
|
import { Typeable } from './typeable/Typeable.js';
|
|
4
5
|
|
|
@@ -159,6 +160,7 @@ type Try<T> = {
|
|
|
159
160
|
getOrElse: (defaultValue: T) => T;
|
|
160
161
|
orElse: (alternative: Try<T>) => Try<T>;
|
|
161
162
|
toEither: () => Either<Error, T>;
|
|
163
|
+
orThrow: () => T;
|
|
162
164
|
map: <U>(f: (value: T) => U) => Try<U>;
|
|
163
165
|
flatMap: <U>(f: (value: T) => Try<U>) => Try<U>;
|
|
164
166
|
valueOf: () => {
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Type, Functor } from './functor/index.mjs';
|
|
2
|
+
import './identity/Identity.mjs';
|
|
2
3
|
import { Tuple } from './tuple/Tuple.mjs';
|
|
3
4
|
import { Typeable } from './typeable/Typeable.mjs';
|
|
4
5
|
|
|
@@ -159,6 +160,7 @@ type Try<T> = {
|
|
|
159
160
|
getOrElse: (defaultValue: T) => T;
|
|
160
161
|
orElse: (alternative: Try<T>) => Try<T>;
|
|
161
162
|
toEither: () => Either<Error, T>;
|
|
163
|
+
orThrow: () => T;
|
|
162
164
|
map: <U>(f: (value: T) => U) => Try<U>;
|
|
163
165
|
flatMap: <U>(f: (value: T) => Try<U>) => Try<U>;
|
|
164
166
|
valueOf: () => {
|
package/dist/index.d.mts
CHANGED
|
@@ -1,4 +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-
|
|
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
|
+
export { Identity } from './identity/Identity.mjs';
|
|
3
4
|
export { Tuple } from './tuple/Tuple.mjs';
|
|
4
5
|
export { Typeable } from './typeable/Typeable.mjs';
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +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-
|
|
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
|
+
export { Identity } from './identity/Identity.js';
|
|
3
4
|
export { Tuple } from './tuple/Tuple.js';
|
|
4
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
|
|
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-
|
|
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};
|
package/dist/iterable/Seq.d.mts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
export { a as Seq, c as createSeq } from '../index-
|
|
1
|
+
export { a as Seq, c as createSeq } from '../index-BYj2UWRP.mjs';
|
|
2
2
|
import '../functor/index.mjs';
|
|
3
|
+
import '../identity/Identity.mjs';
|
|
3
4
|
import '../tuple/Tuple.mjs';
|
|
4
5
|
import '../typeable/Typeable.mjs';
|
package/dist/iterable/Seq.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import '../functor/index.mjs';
|
|
2
|
-
export { a as Seq, _ as _Iterable_ } from '../index-
|
|
2
|
+
export { a as Seq, _ as _Iterable_ } from '../index-BYj2UWRP.mjs';
|
|
3
|
+
import '../identity/Identity.mjs';
|
|
3
4
|
import '../tuple/Tuple.mjs';
|
|
4
5
|
import '../typeable/Typeable.mjs';
|
package/dist/iterable/index.d.ts
CHANGED
package/dist/list/List.d.mts
CHANGED
package/dist/list/List.d.ts
CHANGED
package/dist/map/Map.d.mts
CHANGED
package/dist/map/Map.d.ts
CHANGED
package/dist/map/Map.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var
|
|
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-
|
|
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};
|
package/dist/option/Option.d.mts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import '../functor/index.mjs';
|
|
2
|
-
export { N as None, O as Option, S as Some } from '../index-
|
|
2
|
+
export { N as None, O as Option, S as Some } from '../index-BYj2UWRP.mjs';
|
|
3
3
|
import '../typeable/Typeable.mjs';
|
|
4
|
+
import '../identity/Identity.mjs';
|
|
4
5
|
import '../tuple/Tuple.mjs';
|
package/dist/option/Option.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import '../functor/index.js';
|
|
2
|
-
export { N as None, O as Option, S as Some } from '../index-
|
|
2
|
+
export { N as None, O as Option, S as Some } from '../index-BB5BWdxR.js';
|
|
3
3
|
import '../typeable/Typeable.js';
|
|
4
|
+
import '../identity/Identity.js';
|
|
4
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};
|
package/dist/set/Set.d.mts
CHANGED
package/dist/set/Set.d.ts
CHANGED
package/dist/try/Try.d.mts
CHANGED
package/dist/try/Try.d.ts
CHANGED
package/dist/try/Try.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var
|
|
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-
|
|
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};
|
package/dist/util/index.d.mts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { E as Either } from '../index-
|
|
1
|
+
import { E as Either } from '../index-BYj2UWRP.mjs';
|
|
2
2
|
import { ParseError } from '../error/ParseError.mjs';
|
|
3
3
|
import '../functor/index.mjs';
|
|
4
|
+
import '../identity/Identity.mjs';
|
|
4
5
|
import '../tuple/Tuple.mjs';
|
|
5
6
|
import '../typeable/Typeable.mjs';
|
|
6
7
|
|
package/dist/util/index.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { E as Either } from '../index-
|
|
1
|
+
import { E as Either } from '../index-BB5BWdxR.js';
|
|
2
2
|
import { ParseError } from '../error/ParseError.js';
|
|
3
3
|
import '../functor/index.js';
|
|
4
|
+
import '../identity/Identity.js';
|
|
4
5
|
import '../tuple/Tuple.js';
|
|
5
6
|
import '../typeable/Typeable.js';
|
|
6
7
|
|
package/lib/index.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,12 +1,17 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "functype",
|
|
3
|
-
"version": "0.8.
|
|
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
|
+
"@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.
|
|
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"
|
package/dist/chunk-JQ7HMWOT.mjs
DELETED
|
@@ -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};
|
package/dist/chunk-Q65ZRGZH.js
DELETED
|
@@ -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;
|
package/lib/either/index.d.ts
DELETED
package/lib/list/index.d.ts
DELETED
package/lib/map/index.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { Map } from "./Map";
|
package/lib/option/index.d.ts
DELETED
|
@@ -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 };
|
package/lib/set/index.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { Set } from "./Set";
|
package/lib/try/index.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { Try } from "./Try";
|
package/lib/tuple/index.d.ts
DELETED