functype 0.0.1 → 0.0.3

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 (57) hide show
  1. package/README.md +3 -3
  2. package/dist/chunk-4EVP3IRI.cjs +1 -0
  3. package/dist/chunk-ABUN2GHU.js +1 -0
  4. package/dist/chunk-CB3ZZ3RL.cjs +1 -0
  5. package/dist/chunk-CN6MP6AJ.js +1 -0
  6. package/dist/chunk-E4GBAXJ4.js +1 -0
  7. package/dist/chunk-HWJMIJH6.cjs +1 -0
  8. package/dist/chunk-PXY4XULG.cjs +1 -0
  9. package/dist/chunk-QK5JVYJ3.js +1 -0
  10. package/dist/either/Left.cjs +1 -1
  11. package/dist/either/Left.d.cts +1 -1
  12. package/dist/either/Left.d.ts +1 -1
  13. package/dist/either/Left.js +1 -1
  14. package/dist/either/Right.cjs +1 -1
  15. package/dist/either/Right.d.cts +1 -1
  16. package/dist/either/Right.d.ts +1 -1
  17. package/dist/either/Right.js +1 -1
  18. package/dist/either/index.cjs +1 -1
  19. package/dist/either/index.d.cts +1 -1
  20. package/dist/either/index.d.ts +1 -1
  21. package/dist/either/index.js +1 -1
  22. package/dist/index-7c5c3a08.d.ts +63 -0
  23. package/dist/index-92d6660e.d.ts +63 -0
  24. package/dist/index.cjs +1 -1
  25. package/dist/index.d.cts +2 -2
  26. package/dist/index.d.ts +2 -2
  27. package/dist/index.js +1 -0
  28. package/dist/list/List.cjs +1 -1
  29. package/dist/list/List.d.cts +2 -11
  30. package/dist/list/List.d.ts +2 -11
  31. package/dist/list/List.js +1 -1
  32. package/package.json +24 -23
  33. package/dist/Left-7cd8288c.d.ts +0 -28
  34. package/dist/Left-876f22af.d.ts +0 -28
  35. package/dist/chunk-FA5LZ3YI.cjs +0 -1
  36. package/dist/chunk-IDDQN36F.js +0 -1
  37. package/dist/chunk-TH2FAVW2.cjs +0 -1
  38. package/dist/chunk-ZPTW4ENU.js +0 -1
  39. package/lib/Left-916151dc.d.ts +0 -23
  40. package/lib/chunk-GAPG2VLO.cjs +0 -10
  41. package/lib/chunk-KMAXXKJT.js +0 -10
  42. package/lib/either/Left.cjs +0 -26
  43. package/lib/either/Left.d.cts +0 -1
  44. package/lib/either/Left.d.ts +0 -1
  45. package/lib/either/Left.js +0 -26
  46. package/lib/either/Right.cjs +0 -24
  47. package/lib/either/Right.d.cts +0 -1
  48. package/lib/either/Right.d.ts +0 -1
  49. package/lib/either/Right.js +0 -24
  50. package/lib/either/index.cjs +0 -11
  51. package/lib/either/index.d.cts +0 -1
  52. package/lib/either/index.d.ts +0 -1
  53. package/lib/either/index.js +0 -11
  54. package/lib/index.cjs +0 -1
  55. package/lib/index.d.cts +0 -2
  56. package/lib/index.d.ts +0 -1
  57. package/lib/index.js +0 -0
package/README.md CHANGED
@@ -1,3 +1,3 @@
1
- ## functype
2
-
3
- A small functional library for TypeScript
1
+ ## functype
2
+
3
+ A small functional library for TypeScript
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});var r=class e{constructor(t){this.value=t}isLeft(){return!0}isRight(){return!1}map(t){return new e(this.value)}flatMap(t){return new e(this.value)}reduce(t){return new e(this.value)}foldLeft(t,i){return t}foldRight(t,i){return t}};exports.a = r;
@@ -0,0 +1 @@
1
+ var r=class e{constructor(t){this.value=t}isLeft(){return!0}isRight(){return!1}map(t){return new e(this.value)}flatMap(t){return new e(this.value)}reduce(t){return new e(this.value)}foldLeft(t,i){return t}foldRight(t,i){return t}};export{r as a};
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});var u=class r{constructor(e){this.value=e}isLeft(){return!1}isRight(){return!0}map(e){return new r(e(this.value))}flatMap(e){return e(this.value)}reduce(e){return new r(e(void 0,this.value))}foldLeft(e,t){return t(e,this.value)}foldRight(e,t){return t(this.value,e)}};exports.a = u;
@@ -0,0 +1 @@
1
+ var u=class r{constructor(e){this.value=e}isLeft(){return!1}isRight(){return!0}map(e){return new r(e(this.value))}flatMap(e){return e(this.value)}reduce(e){return new r(e(void 0,this.value))}foldLeft(e,t){return t(e,this.value)}foldRight(e,t){return t(this.value,e)}};export{u as a};
@@ -0,0 +1 @@
1
+ import{a as i}from"./chunk-VTKL7OQI.js";var n=class r{constructor(t){i(this,"items");this.items=t?[...t]:[]}get length(){return this.items.length}add(t){return new r([...this.items,t])}removeAt(t){if(t<0||t>=this.items.length)return this;let e=[...this.items.slice(0,t),...this.items.slice(t+1)];return new r(e)}get(t){return this.items[t]}toArray(){return this.items}map(t){return new r(this.items.map(t))}flatMap(t){return this.items.reduce((e,s)=>e.concat(t(s)),new r)}reduce(t){let e=this.items.reduce(t,void 0);return new r([e])}foldLeft(t,e){return this.items.reduce(e,t)}foldRight(t,e){return this.items.reduceRight((s,u)=>e(u,s),t)}concat(t){return new r([...this.items,...t.items])}toString(){return`List(${this.items.toString()})`}};export{n as a};
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunk4EVP3IRIcjs = require('./chunk-4EVP3IRI.cjs');var _chunkCB3ZZ3RLcjs = require('./chunk-CB3ZZ3RL.cjs');var _chunk6VKVA3TKcjs = require('./chunk-6VKVA3TK.cjs');var s=r=>new (0, _chunk4EVP3IRIcjs.a)(r),n= exports.b =r=>new (0, _chunkCB3ZZ3RLcjs.a)(r),h= exports.c =r=>{let t=parseInt(r,10);return isNaN(t)?s(new (0, _chunk6VKVA3TKcjs.a)(`${t}`)):n(t)};exports.a = s; exports.b = n; exports.c = h;
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkGWLTG6GZcjs = require('./chunk-GWLTG6GZ.cjs');var n=class r{constructor(t){_chunkGWLTG6GZcjs.a.call(void 0, this,"items");this.items=t?[...t]:[]}get length(){return this.items.length}add(t){return new r([...this.items,t])}removeAt(t){if(t<0||t>=this.items.length)return this;let e=[...this.items.slice(0,t),...this.items.slice(t+1)];return new r(e)}get(t){return this.items[t]}toArray(){return this.items}map(t){return new r(this.items.map(t))}flatMap(t){return this.items.reduce((e,s)=>e.concat(t(s)),new r)}reduce(t){let e=this.items.reduce(t,void 0);return new r([e])}foldLeft(t,e){return this.items.reduce(e,t)}foldRight(t,e){return this.items.reduceRight((s,u)=>e(u,s),t)}concat(t){return new r([...this.items,...t.items])}toString(){return`List(${this.items.toString()})`}};exports.a = n;
@@ -0,0 +1 @@
1
+ import{a as i}from"./chunk-ABUN2GHU.js";import{a as o}from"./chunk-CN6MP6AJ.js";import{a as e}from"./chunk-ZTL76QDL.js";var s=r=>new i(r),n=r=>new o(r),h=r=>{let t=parseInt(r,10);return isNaN(t)?s(new e(`${t}`)):n(t)};export{s as a,n as b,h as c};
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkTH2FAVW2cjs = require('../chunk-TH2FAVW2.cjs');require('../chunk-GWLTG6GZ.cjs');exports.Left = _chunkTH2FAVW2cjs.a;
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunk4EVP3IRIcjs = require('../chunk-4EVP3IRI.cjs');require('../chunk-GWLTG6GZ.cjs');exports.Left = _chunk4EVP3IRIcjs.a;
@@ -1,2 +1,2 @@
1
- export { L as Left } from '../Left-7cd8288c.js';
1
+ export { a as Left } from '../index-7c5c3a08.js';
2
2
  import '../error/ParseError.cjs';
@@ -1,2 +1,2 @@
1
- export { L as Left } from '../Left-876f22af.js';
1
+ export { a as Left } from '../index-92d6660e.js';
2
2
  import '../error/ParseError.js';
@@ -1 +1 @@
1
- import{a}from"../chunk-ZPTW4ENU.js";import"../chunk-VTKL7OQI.js";export{a as Left};
1
+ import{a}from"../chunk-ABUN2GHU.js";import"../chunk-VTKL7OQI.js";export{a as Left};
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkFA5LZ3YIcjs = require('../chunk-FA5LZ3YI.cjs');require('../chunk-GWLTG6GZ.cjs');exports.Right = _chunkFA5LZ3YIcjs.a;
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkCB3ZZ3RLcjs = require('../chunk-CB3ZZ3RL.cjs');require('../chunk-GWLTG6GZ.cjs');exports.Right = _chunkCB3ZZ3RLcjs.a;
@@ -1,2 +1,2 @@
1
- export { R as Right } from '../Left-7cd8288c.js';
1
+ export { R as Right } from '../index-7c5c3a08.js';
2
2
  import '../error/ParseError.cjs';
@@ -1,2 +1,2 @@
1
- export { R as Right } from '../Left-876f22af.js';
1
+ export { R as Right } from '../index-92d6660e.js';
2
2
  import '../error/ParseError.js';
@@ -1 +1 @@
1
- import{a}from"../chunk-IDDQN36F.js";import"../chunk-VTKL7OQI.js";export{a as Right};
1
+ import{a}from"../chunk-CN6MP6AJ.js";import"../chunk-VTKL7OQI.js";export{a as Right};
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkTH2FAVW2cjs = require('../chunk-TH2FAVW2.cjs');var _chunkFA5LZ3YIcjs = require('../chunk-FA5LZ3YI.cjs');var _chunk6VKVA3TKcjs = require('../chunk-6VKVA3TK.cjs');require('../chunk-GWLTG6GZ.cjs');var n=r=>new (0, _chunkTH2FAVW2cjs.a)(r),s= exports.right =r=>new (0, _chunkFA5LZ3YIcjs.a)(r),m= exports.parseNumber =r=>{let t=parseInt(r,10);return isNaN(t)?n(new (0, _chunk6VKVA3TKcjs.a)(`${t}`)):s(t)};exports.left = n; exports.parseNumber = m; exports.right = s;
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkHWJMIJH6cjs = require('../chunk-HWJMIJH6.cjs');require('../chunk-4EVP3IRI.cjs');require('../chunk-CB3ZZ3RL.cjs');require('../chunk-6VKVA3TK.cjs');require('../chunk-GWLTG6GZ.cjs');exports.left = _chunkHWJMIJH6cjs.a; exports.parseNumber = _chunkHWJMIJH6cjs.c; exports.right = _chunkHWJMIJH6cjs.b;
@@ -1,2 +1,2 @@
1
1
  import '../error/ParseError.cjs';
2
- export { E as Either, l as left, p as parseNumber, r as right } from '../Left-7cd8288c.js';
2
+ export { E as Either, l as left, p as parseNumber, r as right } from '../index-7c5c3a08.js';
@@ -1,2 +1,2 @@
1
1
  import '../error/ParseError.js';
2
- export { E as Either, l as left, p as parseNumber, r as right } from '../Left-876f22af.js';
2
+ export { E as Either, l as left, p as parseNumber, r as right } from '../index-92d6660e.js';
@@ -1 +1 @@
1
- import{a as e}from"../chunk-ZPTW4ENU.js";import{a as o}from"../chunk-IDDQN36F.js";import{a as i}from"../chunk-ZTL76QDL.js";import"../chunk-VTKL7OQI.js";var n=r=>new e(r),s=r=>new o(r),m=r=>{let t=parseInt(r,10);return isNaN(t)?n(new i(`${t}`)):s(t)};export{n as left,m as parseNumber,s as right};
1
+ import{a,b,c}from"../chunk-QK5JVYJ3.js";import"../chunk-ABUN2GHU.js";import"../chunk-CN6MP6AJ.js";import"../chunk-ZTL76QDL.js";import"../chunk-VTKL7OQI.js";export{a as left,c as parseNumber,b as right};
@@ -0,0 +1,63 @@
1
+ import { ParseError } from './error/ParseError.cjs';
2
+
3
+ declare class List<T> implements IFunctor<T> {
4
+ private readonly items;
5
+ constructor(items?: T[]);
6
+ get length(): number;
7
+ add(item: T): List<T>;
8
+ removeAt(index: number): List<T>;
9
+ get(index: number): T | undefined;
10
+ toArray(): readonly T[];
11
+ map<U>(f: (value: T) => U): List<U>;
12
+ flatMap<U>(f: (value: T) => List<U>): List<U>;
13
+ reduce<U>(f: (acc: U, value: T) => U): List<U>;
14
+ foldLeft<U>(initialValue: U, f: (acc: U, value: T) => U): U;
15
+ foldRight<U>(initialValue: U, f: (value: T, acc: U) => U): U;
16
+ concat(other: List<T>): List<T>;
17
+ toString(): string;
18
+ }
19
+
20
+ declare class Right<L, R> implements Either<L, R> {
21
+ value: R;
22
+ constructor(value: R);
23
+ isLeft(): this is Left<L, R>;
24
+ isRight(): this is Right<L, R>;
25
+ map<U>(f: (value: R) => U): Either<L, U>;
26
+ flatMap<U>(f: (value: R) => Either<L, U>): Either<L, U>;
27
+ reduce<U>(f: (acc: U, value: R) => U): IFunctor<U>;
28
+ foldLeft<U>(initialValue: U, f: (acc: U, value: R) => U): U;
29
+ foldRight<U>(initialValue: U, f: (value: R, acc: U) => U): U;
30
+ }
31
+
32
+ declare class Left<L, R> implements Either<L, R> {
33
+ value: L;
34
+ constructor(value: L);
35
+ isLeft(): this is Left<L, R>;
36
+ isRight(): this is Right<L, R>;
37
+ map<U>(_f: (value: R) => U): Either<L, U>;
38
+ flatMap<U>(_f: (value: R) => Either<L, U>): Either<L, U>;
39
+ reduce<U>(_f: (acc: U, value: R) => U): IFunctor<U>;
40
+ foldLeft<U>(initialValue: U, _f: (acc: U, value: R) => U): U;
41
+ foldRight<U>(initialValue: U, _f: (value: R, acc: U) => U): U;
42
+ }
43
+
44
+ interface Either<L, R> extends IFunctor<R> {
45
+ value: L | R;
46
+ isLeft(): this is Left<L, R>;
47
+ isRight(): this is Right<L, R>;
48
+ map<U>(f: (value: R) => U): Either<L, U>;
49
+ flatMap<U>(f: (value: R) => Either<L, U>): Either<L, U>;
50
+ }
51
+ declare const left: <L, R>(value: L) => Either<L, R>;
52
+ declare const right: <L, R>(value: R) => Either<L, R>;
53
+ declare const parseNumber: (input: string) => Either<ParseError, number>;
54
+
55
+ interface IFunctor<T> {
56
+ map<U>(f: (value: T) => U): IFunctor<U>;
57
+ flatMap<U>(f: (value: T) => IFunctor<U>): IFunctor<U>;
58
+ reduce<U>(f: (acc: U, value: T) => U): IFunctor<U>;
59
+ foldLeft<U>(initialValue: U, f: (acc: U, value: T) => U): U;
60
+ foldRight<U>(initialValue: U, f: (value: T, acc: U) => U): U;
61
+ }
62
+
63
+ export { Either as E, IFunctor as I, List as L, Right as R, Left as a, left as l, parseNumber as p, right as r };
@@ -0,0 +1,63 @@
1
+ import { ParseError } from './error/ParseError.js';
2
+
3
+ declare class List<T> implements IFunctor<T> {
4
+ private readonly items;
5
+ constructor(items?: T[]);
6
+ get length(): number;
7
+ add(item: T): List<T>;
8
+ removeAt(index: number): List<T>;
9
+ get(index: number): T | undefined;
10
+ toArray(): readonly T[];
11
+ map<U>(f: (value: T) => U): List<U>;
12
+ flatMap<U>(f: (value: T) => List<U>): List<U>;
13
+ reduce<U>(f: (acc: U, value: T) => U): List<U>;
14
+ foldLeft<U>(initialValue: U, f: (acc: U, value: T) => U): U;
15
+ foldRight<U>(initialValue: U, f: (value: T, acc: U) => U): U;
16
+ concat(other: List<T>): List<T>;
17
+ toString(): string;
18
+ }
19
+
20
+ declare class Right<L, R> implements Either<L, R> {
21
+ value: R;
22
+ constructor(value: R);
23
+ isLeft(): this is Left<L, R>;
24
+ isRight(): this is Right<L, R>;
25
+ map<U>(f: (value: R) => U): Either<L, U>;
26
+ flatMap<U>(f: (value: R) => Either<L, U>): Either<L, U>;
27
+ reduce<U>(f: (acc: U, value: R) => U): IFunctor<U>;
28
+ foldLeft<U>(initialValue: U, f: (acc: U, value: R) => U): U;
29
+ foldRight<U>(initialValue: U, f: (value: R, acc: U) => U): U;
30
+ }
31
+
32
+ declare class Left<L, R> implements Either<L, R> {
33
+ value: L;
34
+ constructor(value: L);
35
+ isLeft(): this is Left<L, R>;
36
+ isRight(): this is Right<L, R>;
37
+ map<U>(_f: (value: R) => U): Either<L, U>;
38
+ flatMap<U>(_f: (value: R) => Either<L, U>): Either<L, U>;
39
+ reduce<U>(_f: (acc: U, value: R) => U): IFunctor<U>;
40
+ foldLeft<U>(initialValue: U, _f: (acc: U, value: R) => U): U;
41
+ foldRight<U>(initialValue: U, _f: (value: R, acc: U) => U): U;
42
+ }
43
+
44
+ interface Either<L, R> extends IFunctor<R> {
45
+ value: L | R;
46
+ isLeft(): this is Left<L, R>;
47
+ isRight(): this is Right<L, R>;
48
+ map<U>(f: (value: R) => U): Either<L, U>;
49
+ flatMap<U>(f: (value: R) => Either<L, U>): Either<L, U>;
50
+ }
51
+ declare const left: <L, R>(value: L) => Either<L, R>;
52
+ declare const right: <L, R>(value: R) => Either<L, R>;
53
+ declare const parseNumber: (input: string) => Either<ParseError, number>;
54
+
55
+ interface IFunctor<T> {
56
+ map<U>(f: (value: T) => U): IFunctor<U>;
57
+ flatMap<U>(f: (value: T) => IFunctor<U>): IFunctor<U>;
58
+ reduce<U>(f: (acc: U, value: T) => U): IFunctor<U>;
59
+ foldLeft<U>(initialValue: U, f: (acc: U, value: T) => U): U;
60
+ foldRight<U>(initialValue: U, f: (value: T, acc: U) => U): U;
61
+ }
62
+
63
+ export { Either as E, IFunctor as I, List as L, Right as R, Left as a, left as l, parseNumber as p, right as r };
package/dist/index.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkHWJMIJH6cjs = require('./chunk-HWJMIJH6.cjs');require('./chunk-4EVP3IRI.cjs');require('./chunk-CB3ZZ3RL.cjs');require('./chunk-6VKVA3TK.cjs');var _chunkPXY4XULGcjs = require('./chunk-PXY4XULG.cjs');require('./chunk-GWLTG6GZ.cjs');exports.List = _chunkPXY4XULGcjs.a; exports.left = _chunkHWJMIJH6cjs.a; exports.parseNumber = _chunkHWJMIJH6cjs.c; exports.right = _chunkHWJMIJH6cjs.b;
package/dist/index.d.cts CHANGED
@@ -1,2 +1,2 @@
1
-
2
- export { }
1
+ export { E as Either, I as IFunctor, L as List, l as left, p as parseNumber, r as right } from './index-7c5c3a08.js';
2
+ import './error/ParseError.cjs';
package/dist/index.d.ts CHANGED
@@ -1,2 +1,2 @@
1
-
2
- export { }
1
+ export { E as Either, I as IFunctor, L as List, l as left, p as parseNumber, r as right } from './index-92d6660e.js';
2
+ import './error/ParseError.js';
package/dist/index.js CHANGED
@@ -0,0 +1 @@
1
+ import{a,b as t,c as e}from"./chunk-QK5JVYJ3.js";import"./chunk-ABUN2GHU.js";import"./chunk-CN6MP6AJ.js";import"./chunk-ZTL76QDL.js";import{a as U}from"./chunk-E4GBAXJ4.js";import"./chunk-VTKL7OQI.js";export{U as List,a as left,e as parseNumber,t as right};
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkGWLTG6GZcjs = require('../chunk-GWLTG6GZ.cjs');var r=class e{constructor(t){_chunkGWLTG6GZcjs.a.call(void 0, this,"items");this.items=t?[...t]:[]}get length(){return this.items.length}add(t){return new e([...this.items,t])}removeAt(t){if(t<0||t>=this.items.length)return this;let i=[...this.items.slice(0,t),...this.items.slice(t+1)];return new e(i)}get(t){return this.items[t]}toArray(){return this.items}};exports.List = r;
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkPXY4XULGcjs = require('../chunk-PXY4XULG.cjs');require('../chunk-GWLTG6GZ.cjs');exports.List = _chunkPXY4XULGcjs.a;
@@ -1,11 +1,2 @@
1
- declare class List<T> {
2
- private readonly items;
3
- constructor(items?: T[]);
4
- get length(): number;
5
- add(item: T): List<T>;
6
- removeAt(index: number): List<T>;
7
- get(index: number): T | undefined;
8
- toArray(): readonly T[];
9
- }
10
-
11
- export { List };
1
+ export { L as List } from '../index-7c5c3a08.js';
2
+ import '../error/ParseError.cjs';
@@ -1,11 +1,2 @@
1
- declare class List<T> {
2
- private readonly items;
3
- constructor(items?: T[]);
4
- get length(): number;
5
- add(item: T): List<T>;
6
- removeAt(index: number): List<T>;
7
- get(index: number): T | undefined;
8
- toArray(): readonly T[];
9
- }
10
-
11
- export { List };
1
+ export { L as List } from '../index-92d6660e.js';
2
+ import '../error/ParseError.js';
package/dist/list/List.js CHANGED
@@ -1 +1 @@
1
- import{a as s}from"../chunk-VTKL7OQI.js";var r=class e{constructor(t){s(this,"items");this.items=t?[...t]:[]}get length(){return this.items.length}add(t){return new e([...this.items,t])}removeAt(t){if(t<0||t>=this.items.length)return this;let i=[...this.items.slice(0,t),...this.items.slice(t+1)];return new e(i)}get(t){return this.items[t]}toArray(){return this.items}};export{r as List};
1
+ import{a}from"../chunk-E4GBAXJ4.js";import"../chunk-VTKL7OQI.js";export{a as List};
package/package.json CHANGED
@@ -1,35 +1,23 @@
1
1
  {
2
2
  "name": "functype",
3
- "version": "0.0.1",
3
+ "version": "0.0.3",
4
4
  "description": "A small functional library for TypeScript",
5
5
  "author": "jordan.burke@gmail.com",
6
6
  "license": "MIT",
7
7
  "url": "https://github.com/jordanburke/TypeScript/tree/main/functype",
8
- "scripts": {
9
- "ts-types": "tsc",
10
- "build:dev": "rimraf lib && tsup --watch",
11
- "build:prod": "rimraf dist && cross-env NODE_ENV=production tsup",
12
- "build:watch": "tsup --watch",
13
- "lint:fix": "eslint ./src --ext .ts,.tsx --quiet --fix --ignore-path ./.gitignore",
14
- "lint:format": "prettier --loglevel warn --write \"./**/*.{ts,tsx,css,md,json}\" ",
15
- "lint": "pnpm lint:format && pnpm lint:fix ",
16
- "test": "jest",
17
- "test:watch": "jest --watch",
18
- "test:cov": "jest --coverage"
19
- },
20
8
  "devDependencies": {
21
9
  "@types/node": "^18.17.5",
22
- "@typescript-eslint/eslint-plugin": "^6.4.0",
23
- "@typescript-eslint/parser": "^6.4.0",
24
- "@types/jest": "29.5.3",
10
+ "@typescript-eslint/eslint-plugin": "^6.5.0",
11
+ "@typescript-eslint/parser": "^6.5.0",
12
+ "@types/jest": "29.5.4",
25
13
  "cross-env": "^7.0.3",
26
- "eslint": "^8.47.0",
27
- "eslint-config-prettier": "^8.10.0",
28
- "eslint-plugin-import": "^2.28.0",
14
+ "eslint": "^8.48.0",
15
+ "eslint-config-prettier": "^9.0.0",
16
+ "eslint-plugin-import": "^2.28.1",
29
17
  "eslint-plugin-prettier": "^5.0.0",
30
18
  "eslint-plugin-simple-import-sort": "^10.0.0",
31
- "jest": "29.6.2",
32
- "prettier": "^3.0.2",
19
+ "jest": "29.6.4",
20
+ "prettier": "^3.0.3",
33
21
  "rimraf": "^5.0.1",
34
22
  "tsup": "^7.2.0",
35
23
  "ts-jest": "^29.1.1"
@@ -44,5 +32,18 @@
44
32
  "files": [
45
33
  "lib",
46
34
  "dist"
47
- ]
48
- }
35
+ ],
36
+ "scripts": {
37
+ "ts-types": "tsc",
38
+ "build:dev": "rimraf lib && tsup --watch",
39
+ "build:prod": "rimraf dist && cross-env NODE_ENV=production tsup",
40
+ "build:watch": "tsup --watch",
41
+ "build:publish": "pnpm build:prod && pnpm publish --access public",
42
+ "lint:fix": "eslint ./src --ext .ts,.tsx --quiet --fix --ignore-path ./.gitignore",
43
+ "lint:format": "prettier --loglevel warn --write \"./**/*.{ts,tsx,css,md,json}\" ",
44
+ "lint": "pnpm lint:format && pnpm lint:fix ",
45
+ "test": "jest",
46
+ "test:watch": "jest --watch",
47
+ "test:cov": "jest --coverage"
48
+ }
49
+ }
@@ -1,28 +0,0 @@
1
- import { ParseError } from './error/ParseError.cjs';
2
-
3
- declare class Right<L, R> {
4
- value: R;
5
- readonly tag = "Right";
6
- constructor(value: R);
7
- isLeft(): this is Left<L, R>;
8
- isRight(): this is Right<L, R>;
9
- map<U>(f: (value: R) => U): Either<L, U>;
10
- flatMap<U>(f: (value: R) => Either<L, U>): Either<L, U>;
11
- }
12
-
13
- type Either<L, R> = Left<L, R> | Right<L, R>;
14
- declare const left: <L, R>(value: L) => Either<L, R>;
15
- declare const right: <L, R>(value: R) => Either<L, R>;
16
- declare const parseNumber: (input: string) => Either<ParseError, number>;
17
-
18
- declare class Left<L, R> {
19
- value: L;
20
- readonly tag = "Left";
21
- constructor(value: L);
22
- isLeft(): this is Left<L, R>;
23
- isRight(): this is Right<L, R>;
24
- map<U>(f: (value: R) => U): Either<L, U>;
25
- flatMap<U>(f: (value: R) => Either<L, U>): Either<L, U>;
26
- }
27
-
28
- export { Either as E, Left as L, Right as R, left as l, parseNumber as p, right as r };
@@ -1,28 +0,0 @@
1
- import { ParseError } from './error/ParseError.js';
2
-
3
- declare class Right<L, R> {
4
- value: R;
5
- readonly tag = "Right";
6
- constructor(value: R);
7
- isLeft(): this is Left<L, R>;
8
- isRight(): this is Right<L, R>;
9
- map<U>(f: (value: R) => U): Either<L, U>;
10
- flatMap<U>(f: (value: R) => Either<L, U>): Either<L, U>;
11
- }
12
-
13
- type Either<L, R> = Left<L, R> | Right<L, R>;
14
- declare const left: <L, R>(value: L) => Either<L, R>;
15
- declare const right: <L, R>(value: R) => Either<L, R>;
16
- declare const parseNumber: (input: string) => Either<ParseError, number>;
17
-
18
- declare class Left<L, R> {
19
- value: L;
20
- readonly tag = "Left";
21
- constructor(value: L);
22
- isLeft(): this is Left<L, R>;
23
- isRight(): this is Right<L, R>;
24
- map<U>(f: (value: R) => U): Either<L, U>;
25
- flatMap<U>(f: (value: R) => Either<L, U>): Either<L, U>;
26
- }
27
-
28
- export { Either as E, Left as L, Right as R, left as l, parseNumber as p, right as r };
@@ -1 +0,0 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkGWLTG6GZcjs = require('./chunk-GWLTG6GZ.cjs');var r=class i{constructor(t){this.value=t;_chunkGWLTG6GZcjs.a.call(void 0, this,"tag","Right")}isLeft(){return!1}isRight(){return!0}map(t){return new i(t(this.value))}flatMap(t){return t(this.value)}};exports.a = r;
@@ -1 +0,0 @@
1
- import{a as e}from"./chunk-VTKL7OQI.js";var r=class i{constructor(t){this.value=t;e(this,"tag","Right")}isLeft(){return!1}isRight(){return!0}map(t){return new i(t(this.value))}flatMap(t){return t(this.value)}};export{r as a};
@@ -1 +0,0 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkGWLTG6GZcjs = require('./chunk-GWLTG6GZ.cjs');var i=class t{constructor(e){this.value=e;_chunkGWLTG6GZcjs.a.call(void 0, this,"tag","Left")}isLeft(){return!0}isRight(){return!1}map(e){return new t(this.value)}flatMap(e){return new t(this.value)}};exports.a = i;
@@ -1 +0,0 @@
1
- import{a as r}from"./chunk-VTKL7OQI.js";var i=class t{constructor(e){this.value=e;r(this,"tag","Left")}isLeft(){return!0}isRight(){return!1}map(e){return new t(this.value)}flatMap(e){return new t(this.value)}};export{i as a};
@@ -1,23 +0,0 @@
1
- type Either<L, R> = Left<L, R> | Right<L, R>
2
-
3
- declare class Right<L, R> {
4
- value: R
5
- readonly tag = "Right"
6
- constructor(value: R)
7
- isLeft(): this is Left<L, R>
8
- isRight(): this is Right<L, R>
9
- map<U>(f: (value: R) => U): Either<L, U>
10
- flatMap<U>(f: (value: R) => Either<L, U>): Either<L, U>
11
- }
12
-
13
- declare class Left<L, R> {
14
- value: L
15
- readonly tag = "Left"
16
- constructor(value: L)
17
- isLeft(): this is Left<L, R>
18
- isRight(): this is Right<L, R>
19
- map<U>(f: (value: R) => U): Either<L, U>
20
- flatMap<U>(f: (value: R) => Either<L, U>): Either<L, U>
21
- }
22
-
23
- export { Either as E, Left as L, Right as R }
@@ -1,10 +0,0 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});var __defProp = Object.defineProperty;
2
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
3
- var __publicField = (obj, key, value) => {
4
- __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
5
- return value;
6
- };
7
-
8
-
9
-
10
- exports.__publicField = __publicField;
@@ -1,10 +0,0 @@
1
- var __defProp = Object.defineProperty;
2
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
3
- var __publicField = (obj, key, value) => {
4
- __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
5
- return value;
6
- };
7
-
8
- export {
9
- __publicField
10
- };
@@ -1,26 +0,0 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
-
3
- var _chunkGAPG2VLOcjs = require('../chunk-GAPG2VLO.cjs');
4
- class Left {
5
- constructor(value) {
6
- this.value = value;
7
- _chunkGAPG2VLOcjs.__publicField.call(void 0, this, "tag", "Left");
8
- }
9
- isLeft() {
10
- return true;
11
- }
12
- isRight() {
13
- return false;
14
- }
15
- // Transform only the Right value
16
- map(f) {
17
- return new Left(this.value);
18
- }
19
- // Chain functions that return an Either
20
- flatMap(f) {
21
- return new Left(this.value);
22
- }
23
- }
24
-
25
-
26
- exports.Left = Left;
@@ -1 +0,0 @@
1
- export { L as Left } from '../Left-916151dc.js';
@@ -1 +0,0 @@
1
- export { L as Left } from "../Left-916151dc.js"
@@ -1,26 +0,0 @@
1
- import {
2
- __publicField
3
- } from "../chunk-KMAXXKJT.js";
4
- class Left {
5
- constructor(value) {
6
- this.value = value;
7
- __publicField(this, "tag", "Left");
8
- }
9
- isLeft() {
10
- return true;
11
- }
12
- isRight() {
13
- return false;
14
- }
15
- // Transform only the Right value
16
- map(f) {
17
- return new Left(this.value);
18
- }
19
- // Chain functions that return an Either
20
- flatMap(f) {
21
- return new Left(this.value);
22
- }
23
- }
24
- export {
25
- Left
26
- };
@@ -1,24 +0,0 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
-
3
- var _chunkGAPG2VLOcjs = require('../chunk-GAPG2VLO.cjs');
4
- class Right {
5
- constructor(value) {
6
- this.value = value;
7
- _chunkGAPG2VLOcjs.__publicField.call(void 0, this, "tag", "Right");
8
- }
9
- isLeft() {
10
- return false;
11
- }
12
- isRight() {
13
- return true;
14
- }
15
- map(f) {
16
- return new Right(f(this.value));
17
- }
18
- flatMap(f) {
19
- return f(this.value);
20
- }
21
- }
22
-
23
-
24
- exports.Right = Right;
@@ -1 +0,0 @@
1
- export { R as Right } from '../Left-916151dc.js';
@@ -1 +0,0 @@
1
- export { R as Right } from "../Left-916151dc.js"
@@ -1,24 +0,0 @@
1
- import {
2
- __publicField
3
- } from "../chunk-KMAXXKJT.js";
4
- class Right {
5
- constructor(value) {
6
- this.value = value;
7
- __publicField(this, "tag", "Right");
8
- }
9
- isLeft() {
10
- return false;
11
- }
12
- isRight() {
13
- return true;
14
- }
15
- map(f) {
16
- return new Right(f(this.value));
17
- }
18
- flatMap(f) {
19
- return f(this.value);
20
- }
21
- }
22
- export {
23
- Right
24
- };
@@ -1,11 +0,0 @@
1
- "use strict";var _Left = require('./Left');
2
- var _Right = require('./Right');
3
- const left = (value) => new (0, _Left.Left)(value);
4
- const right = (value) => new (0, _Right.Right)(value);
5
- const parseNumber = (input) => {
6
- const result = parseInt(input, 10);
7
- if (isNaN(result)) {
8
- return left("Invalid number");
9
- }
10
- return right(result);
11
- };
@@ -1 +0,0 @@
1
- export { E as Either } from '../Left-916151dc.js';
@@ -1 +0,0 @@
1
- export { E as Either } from "../Left-916151dc.js"
@@ -1,11 +0,0 @@
1
- import { Left } from "./Left";
2
- import { Right } from "./Right";
3
- const left = (value) => new Left(value);
4
- const right = (value) => new Right(value);
5
- const parseNumber = (input) => {
6
- const result = parseInt(input, 10);
7
- if (isNaN(result)) {
8
- return left("Invalid number");
9
- }
10
- return right(result);
11
- };
package/lib/index.cjs DELETED
@@ -1 +0,0 @@
1
- "use strict";
package/lib/index.d.cts DELETED
@@ -1,2 +0,0 @@
1
-
2
- export { }
package/lib/index.d.ts DELETED
@@ -1 +0,0 @@
1
- export {}
package/lib/index.js DELETED
File without changes