functype 0.0.1 → 0.0.2

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 (49) 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/either/Left.cjs +1 -1
  7. package/dist/either/Left.d.cts +2 -1
  8. package/dist/either/Left.d.ts +2 -1
  9. package/dist/either/Left.js +1 -1
  10. package/dist/either/Right.cjs +1 -1
  11. package/dist/either/Right.d.cts +2 -1
  12. package/dist/either/Right.d.ts +2 -1
  13. package/dist/either/Right.js +1 -1
  14. package/dist/either/index.cjs +1 -1
  15. package/dist/either/index.d.cts +2 -1
  16. package/dist/either/index.d.ts +2 -1
  17. package/dist/either/index.js +1 -1
  18. package/dist/{Left-876f22af.d.ts → index-28de5927.d.ts} +20 -9
  19. package/dist/{Left-7cd8288c.d.ts → index-402b9aa2.d.ts} +20 -9
  20. package/dist/index.d.cts +8 -1
  21. package/dist/index.d.ts +8 -1
  22. package/dist/list/List.cjs +1 -1
  23. package/dist/list/List.d.cts +10 -1
  24. package/dist/list/List.d.ts +10 -1
  25. package/dist/list/List.js +1 -1
  26. package/package.json +24 -23
  27. package/dist/chunk-FA5LZ3YI.cjs +0 -1
  28. package/dist/chunk-IDDQN36F.js +0 -1
  29. package/dist/chunk-TH2FAVW2.cjs +0 -1
  30. package/dist/chunk-ZPTW4ENU.js +0 -1
  31. package/lib/Left-916151dc.d.ts +0 -23
  32. package/lib/chunk-GAPG2VLO.cjs +0 -10
  33. package/lib/chunk-KMAXXKJT.js +0 -10
  34. package/lib/either/Left.cjs +0 -26
  35. package/lib/either/Left.d.cts +0 -1
  36. package/lib/either/Left.d.ts +0 -1
  37. package/lib/either/Left.js +0 -26
  38. package/lib/either/Right.cjs +0 -24
  39. package/lib/either/Right.d.cts +0 -1
  40. package/lib/either/Right.d.ts +0 -1
  41. package/lib/either/Right.js +0 -24
  42. package/lib/either/index.cjs +0 -11
  43. package/lib/either/index.d.cts +0 -1
  44. package/lib/either/index.d.ts +0 -1
  45. package/lib/either/index.js +0 -11
  46. package/lib/index.cjs +0 -1
  47. package/lib/index.d.cts +0 -2
  48. package/lib/index.d.ts +0 -1
  49. 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};
@@ -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,3 @@
1
- export { L as Left } from '../Left-7cd8288c.js';
1
+ export { L as Left } from '../index-402b9aa2.js';
2
+ import '../index.cjs';
2
3
  import '../error/ParseError.cjs';
@@ -1,2 +1,3 @@
1
- export { L as Left } from '../Left-876f22af.js';
1
+ export { L as Left } from '../index-28de5927.js';
2
+ import '../index.js';
2
3
  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,3 @@
1
- export { R as Right } from '../Left-7cd8288c.js';
1
+ export { R as Right } from '../index-402b9aa2.js';
2
+ import '../index.cjs';
2
3
  import '../error/ParseError.cjs';
@@ -1,2 +1,3 @@
1
- export { R as Right } from '../Left-876f22af.js';
1
+ export { R as Right } from '../index-28de5927.js';
2
+ import '../index.js';
2
3
  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 _chunk4EVP3IRIcjs = require('../chunk-4EVP3IRI.cjs');var _chunkCB3ZZ3RLcjs = require('../chunk-CB3ZZ3RL.cjs');var _chunk6VKVA3TKcjs = require('../chunk-6VKVA3TK.cjs');require('../chunk-GWLTG6GZ.cjs');var s=r=>new (0, _chunk4EVP3IRIcjs.a)(r),n= exports.right =r=>new (0, _chunkCB3ZZ3RLcjs.a)(r),h= exports.parseNumber =r=>{let t=parseInt(r,10);return isNaN(t)?s(new (0, _chunk6VKVA3TKcjs.a)(`${t}`)):n(t)};exports.left = s; exports.parseNumber = h; exports.right = n;
@@ -1,2 +1,3 @@
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-402b9aa2.js';
3
+ import '../index.cjs';
@@ -1,2 +1,3 @@
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-28de5927.js';
3
+ import '../index.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 as i}from"../chunk-ABUN2GHU.js";import{a as o}from"../chunk-CN6MP6AJ.js";import{a as e}from"../chunk-ZTL76QDL.js";import"../chunk-VTKL7OQI.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 left,h as parseNumber,n as right};
@@ -1,28 +1,39 @@
1
1
  import { ParseError } from './error/ParseError.js';
2
+ import { IFunctor } from './index.js';
2
3
 
3
- declare class Right<L, R> {
4
+ declare class Right<L, R> implements Either<L, R> {
4
5
  value: R;
5
- readonly tag = "Right";
6
6
  constructor(value: R);
7
7
  isLeft(): this is Left<L, R>;
8
8
  isRight(): this is Right<L, R>;
9
9
  map<U>(f: (value: R) => U): Either<L, U>;
10
10
  flatMap<U>(f: (value: R) => Either<L, U>): Either<L, U>;
11
+ reduce<U>(f: (acc: U, value: R) => U): IFunctor<U>;
12
+ foldLeft<U>(initialValue: U, f: (acc: U, value: R) => U): U;
13
+ foldRight<U>(initialValue: U, f: (value: R, acc: U) => U): U;
11
14
  }
12
15
 
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> {
16
+ declare class Left<L, R> implements Either<L, R> {
19
17
  value: L;
20
- readonly tag = "Left";
21
18
  constructor(value: L);
22
19
  isLeft(): this is Left<L, R>;
23
20
  isRight(): this is Right<L, R>;
21
+ map<U>(_f: (value: R) => U): Either<L, U>;
22
+ flatMap<U>(_f: (value: R) => Either<L, U>): Either<L, U>;
23
+ reduce<U>(_f: (acc: U, value: R) => U): IFunctor<U>;
24
+ foldLeft<U>(initialValue: U, _f: (acc: U, value: R) => U): U;
25
+ foldRight<U>(initialValue: U, _f: (value: R, acc: U) => U): U;
26
+ }
27
+
28
+ interface Either<L, R> extends IFunctor<R> {
29
+ value: L | R;
30
+ isLeft(): this is Left<L, R>;
31
+ isRight(): this is Right<L, R>;
24
32
  map<U>(f: (value: R) => U): Either<L, U>;
25
33
  flatMap<U>(f: (value: R) => Either<L, U>): Either<L, U>;
26
34
  }
35
+ declare const left: <L, R>(value: L) => Either<L, R>;
36
+ declare const right: <L, R>(value: R) => Either<L, R>;
37
+ declare const parseNumber: (input: string) => Either<ParseError, number>;
27
38
 
28
39
  export { Either as E, Left as L, Right as R, left as l, parseNumber as p, right as r };
@@ -1,28 +1,39 @@
1
1
  import { ParseError } from './error/ParseError.cjs';
2
+ import { IFunctor } from './index.cjs';
2
3
 
3
- declare class Right<L, R> {
4
+ declare class Right<L, R> implements Either<L, R> {
4
5
  value: R;
5
- readonly tag = "Right";
6
6
  constructor(value: R);
7
7
  isLeft(): this is Left<L, R>;
8
8
  isRight(): this is Right<L, R>;
9
9
  map<U>(f: (value: R) => U): Either<L, U>;
10
10
  flatMap<U>(f: (value: R) => Either<L, U>): Either<L, U>;
11
+ reduce<U>(f: (acc: U, value: R) => U): IFunctor<U>;
12
+ foldLeft<U>(initialValue: U, f: (acc: U, value: R) => U): U;
13
+ foldRight<U>(initialValue: U, f: (value: R, acc: U) => U): U;
11
14
  }
12
15
 
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> {
16
+ declare class Left<L, R> implements Either<L, R> {
19
17
  value: L;
20
- readonly tag = "Left";
21
18
  constructor(value: L);
22
19
  isLeft(): this is Left<L, R>;
23
20
  isRight(): this is Right<L, R>;
21
+ map<U>(_f: (value: R) => U): Either<L, U>;
22
+ flatMap<U>(_f: (value: R) => Either<L, U>): Either<L, U>;
23
+ reduce<U>(_f: (acc: U, value: R) => U): IFunctor<U>;
24
+ foldLeft<U>(initialValue: U, _f: (acc: U, value: R) => U): U;
25
+ foldRight<U>(initialValue: U, _f: (value: R, acc: U) => U): U;
26
+ }
27
+
28
+ interface Either<L, R> extends IFunctor<R> {
29
+ value: L | R;
30
+ isLeft(): this is Left<L, R>;
31
+ isRight(): this is Right<L, R>;
24
32
  map<U>(f: (value: R) => U): Either<L, U>;
25
33
  flatMap<U>(f: (value: R) => Either<L, U>): Either<L, U>;
26
34
  }
35
+ declare const left: <L, R>(value: L) => Either<L, R>;
36
+ declare const right: <L, R>(value: R) => Either<L, R>;
37
+ declare const parseNumber: (input: string) => Either<ParseError, number>;
27
38
 
28
39
  export { Either as E, Left as L, Right as R, left as l, parseNumber as p, right as r };
package/dist/index.d.cts CHANGED
@@ -1,2 +1,9 @@
1
+ interface IFunctor<T> {
2
+ map<U>(f: (value: T) => U): IFunctor<U>;
3
+ flatMap<U>(f: (value: T) => IFunctor<U>): IFunctor<U>;
4
+ reduce<U>(f: (acc: U, value: T) => U): IFunctor<U>;
5
+ foldLeft<U>(initialValue: U, f: (acc: U, value: T) => U): U;
6
+ foldRight<U>(initialValue: U, f: (value: T, acc: U) => U): U;
7
+ }
1
8
 
2
- export { }
9
+ export { IFunctor };
package/dist/index.d.ts CHANGED
@@ -1,2 +1,9 @@
1
+ interface IFunctor<T> {
2
+ map<U>(f: (value: T) => U): IFunctor<U>;
3
+ flatMap<U>(f: (value: T) => IFunctor<U>): IFunctor<U>;
4
+ reduce<U>(f: (acc: U, value: T) => U): IFunctor<U>;
5
+ foldLeft<U>(initialValue: U, f: (acc: U, value: T) => U): U;
6
+ foldRight<U>(initialValue: U, f: (value: T, acc: U) => U): U;
7
+ }
1
8
 
2
- export { }
9
+ export { IFunctor };
@@ -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 _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.List = n;
@@ -1,4 +1,6 @@
1
- declare class List<T> {
1
+ import { IFunctor } from '../index.cjs';
2
+
3
+ declare class List<T> implements IFunctor<T> {
2
4
  private readonly items;
3
5
  constructor(items?: T[]);
4
6
  get length(): number;
@@ -6,6 +8,13 @@ declare class List<T> {
6
8
  removeAt(index: number): List<T>;
7
9
  get(index: number): T | undefined;
8
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;
9
18
  }
10
19
 
11
20
  export { List };
@@ -1,4 +1,6 @@
1
- declare class List<T> {
1
+ import { IFunctor } from '../index.js';
2
+
3
+ declare class List<T> implements IFunctor<T> {
2
4
  private readonly items;
3
5
  constructor(items?: T[]);
4
6
  get length(): number;
@@ -6,6 +8,13 @@ declare class List<T> {
6
8
  removeAt(index: number): List<T>;
7
9
  get(index: number): T | undefined;
8
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;
9
18
  }
10
19
 
11
20
  export { List };
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 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 List};
package/package.json CHANGED
@@ -1,35 +1,23 @@
1
1
  {
2
2
  "name": "functype",
3
- "version": "0.0.1",
3
+ "version": "0.0.2",
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 +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