functype 0.0.4 → 0.0.6

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.
@@ -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,3 +1,2 @@
1
- export { L as Left } from '../index-402b9aa2.js';
2
- import '../index.cjs';
1
+ export { Left } from '../index.cjs';
3
2
  import '../error/ParseError.cjs';
@@ -1,3 +1,2 @@
1
- export { L as Left } from '../index-28de5927.js';
2
- import '../index.js';
1
+ export { Left } from '../index.js';
3
2
  import '../error/ParseError.js';
@@ -1,3 +1,2 @@
1
- export { R as Right } from '../index-402b9aa2.js';
2
- import '../index.cjs';
1
+ export { Right } from '../index.cjs';
3
2
  import '../error/ParseError.cjs';
@@ -1,3 +1,2 @@
1
- export { R as Right } from '../index-28de5927.js';
2
- import '../index.js';
1
+ export { Right } from '../index.js';
3
2
  import '../error/ParseError.js';
@@ -1 +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');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
+ "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,3 +1,2 @@
1
1
  import '../error/ParseError.cjs';
2
- export { E as Either, l as left, p as parseNumber, r as right } from '../index-402b9aa2.js';
3
- import '../index.cjs';
2
+ export { Either, left, parseNumber, right } from '../index.cjs';
@@ -1,3 +1,2 @@
1
1
  import '../error/ParseError.js';
2
- export { E as Either, l as left, p as parseNumber, r as right } from '../index-28de5927.js';
3
- import '../index.js';
2
+ export { Either, left, parseNumber, right } from '../index.js';
@@ -1 +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";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
+ 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};
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');var _chunk4EVP3IRIcjs = require('./chunk-4EVP3IRI.cjs');var _chunkCB3ZZ3RLcjs = require('./chunk-CB3ZZ3RL.cjs');require('./chunk-6VKVA3TK.cjs');var _chunkPXY4XULGcjs = require('./chunk-PXY4XULG.cjs');require('./chunk-GWLTG6GZ.cjs');exports.Left = _chunk4EVP3IRIcjs.a; exports.List = _chunkPXY4XULGcjs.a; exports.Right = _chunkCB3ZZ3RLcjs.a; exports.left = _chunkHWJMIJH6cjs.a; exports.parseNumber = _chunkHWJMIJH6cjs.c; exports.right = _chunkHWJMIJH6cjs.b;
package/dist/index.d.cts CHANGED
@@ -1,3 +1,57 @@
1
+ import { ParseError } from './error/ParseError.cjs';
2
+
3
+ declare class Right<L, R> implements Either<L, R> {
4
+ value: R;
5
+ constructor(value: R);
6
+ isLeft(): this is Left<L, R>;
7
+ isRight(): this is Right<L, R>;
8
+ map<U>(f: (value: R) => U): Either<L, U>;
9
+ flatMap<U>(f: (value: R) => Either<L, U>): Either<L, U>;
10
+ reduce<U>(f: (acc: U, value: R) => U): IFunctor<U>;
11
+ foldLeft<U>(initialValue: U, f: (acc: U, value: R) => U): U;
12
+ foldRight<U>(initialValue: U, f: (value: R, acc: U) => U): U;
13
+ }
14
+
15
+ declare class Left<L, R> implements Either<L, R> {
16
+ value: L;
17
+ constructor(value: L);
18
+ isLeft(): this is Left<L, R>;
19
+ isRight(): this is Right<L, R>;
20
+ map<U>(_f: (value: R) => U): Either<L, U>;
21
+ flatMap<U>(_f: (value: R) => Either<L, U>): Either<L, U>;
22
+ reduce<U>(_f: (acc: U, value: R) => U): IFunctor<U>;
23
+ foldLeft<U>(initialValue: U, _f: (acc: U, value: R) => U): U;
24
+ foldRight<U>(initialValue: U, _f: (value: R, acc: U) => U): U;
25
+ }
26
+
27
+ interface Either<L, R> extends IFunctor<R> {
28
+ value: L | R;
29
+ isLeft(): this is Left<L, R>;
30
+ isRight(): this is Right<L, R>;
31
+ map<U>(f: (value: R) => U): Either<L, U>;
32
+ flatMap<U>(f: (value: R) => Either<L, U>): Either<L, U>;
33
+ }
34
+ declare const left: <L, R>(value: L) => Either<L, R>;
35
+ declare const right: <L, R>(value: R) => Either<L, R>;
36
+ declare const parseNumber: (input: string) => Either<ParseError, number>;
37
+
38
+ declare class List<T> implements IFunctor<T> {
39
+ private readonly items;
40
+ constructor(items?: T[]);
41
+ get length(): number;
42
+ add(item: T): List<T>;
43
+ removeAt(index: number): List<T>;
44
+ get(index: number): T | undefined;
45
+ toArray(): readonly T[];
46
+ map<U>(f: (value: T) => U): List<U>;
47
+ flatMap<U>(f: (value: T) => List<U>): List<U>;
48
+ reduce<U>(f: (acc: U, value: T) => U): List<U>;
49
+ foldLeft<U>(initialValue: U, f: (acc: U, value: T) => U): U;
50
+ foldRight<U>(initialValue: U, f: (value: T, acc: U) => U): U;
51
+ concat(other: List<T>): List<T>;
52
+ toString(): string;
53
+ }
54
+
1
55
  interface IFunctor<T> {
2
56
  map<U>(f: (value: T) => U): IFunctor<U>;
3
57
  flatMap<U>(f: (value: T) => IFunctor<U>): IFunctor<U>;
@@ -6,4 +60,4 @@ interface IFunctor<T> {
6
60
  foldRight<U>(initialValue: U, f: (value: T, acc: U) => U): U;
7
61
  }
8
62
 
9
- export { IFunctor };
63
+ export { Either, IFunctor, Left, List, Right, left, parseNumber, right };
package/dist/index.d.ts CHANGED
@@ -1,3 +1,57 @@
1
+ import { ParseError } from './error/ParseError.js';
2
+
3
+ declare class Right<L, R> implements Either<L, R> {
4
+ value: R;
5
+ constructor(value: R);
6
+ isLeft(): this is Left<L, R>;
7
+ isRight(): this is Right<L, R>;
8
+ map<U>(f: (value: R) => U): Either<L, U>;
9
+ flatMap<U>(f: (value: R) => Either<L, U>): Either<L, U>;
10
+ reduce<U>(f: (acc: U, value: R) => U): IFunctor<U>;
11
+ foldLeft<U>(initialValue: U, f: (acc: U, value: R) => U): U;
12
+ foldRight<U>(initialValue: U, f: (value: R, acc: U) => U): U;
13
+ }
14
+
15
+ declare class Left<L, R> implements Either<L, R> {
16
+ value: L;
17
+ constructor(value: L);
18
+ isLeft(): this is Left<L, R>;
19
+ isRight(): this is Right<L, R>;
20
+ map<U>(_f: (value: R) => U): Either<L, U>;
21
+ flatMap<U>(_f: (value: R) => Either<L, U>): Either<L, U>;
22
+ reduce<U>(_f: (acc: U, value: R) => U): IFunctor<U>;
23
+ foldLeft<U>(initialValue: U, _f: (acc: U, value: R) => U): U;
24
+ foldRight<U>(initialValue: U, _f: (value: R, acc: U) => U): U;
25
+ }
26
+
27
+ interface Either<L, R> extends IFunctor<R> {
28
+ value: L | R;
29
+ isLeft(): this is Left<L, R>;
30
+ isRight(): this is Right<L, R>;
31
+ map<U>(f: (value: R) => U): Either<L, U>;
32
+ flatMap<U>(f: (value: R) => Either<L, U>): Either<L, U>;
33
+ }
34
+ declare const left: <L, R>(value: L) => Either<L, R>;
35
+ declare const right: <L, R>(value: R) => Either<L, R>;
36
+ declare const parseNumber: (input: string) => Either<ParseError, number>;
37
+
38
+ declare class List<T> implements IFunctor<T> {
39
+ private readonly items;
40
+ constructor(items?: T[]);
41
+ get length(): number;
42
+ add(item: T): List<T>;
43
+ removeAt(index: number): List<T>;
44
+ get(index: number): T | undefined;
45
+ toArray(): readonly T[];
46
+ map<U>(f: (value: T) => U): List<U>;
47
+ flatMap<U>(f: (value: T) => List<U>): List<U>;
48
+ reduce<U>(f: (acc: U, value: T) => U): List<U>;
49
+ foldLeft<U>(initialValue: U, f: (acc: U, value: T) => U): U;
50
+ foldRight<U>(initialValue: U, f: (value: T, acc: U) => U): U;
51
+ concat(other: List<T>): List<T>;
52
+ toString(): string;
53
+ }
54
+
1
55
  interface IFunctor<T> {
2
56
  map<U>(f: (value: T) => U): IFunctor<U>;
3
57
  flatMap<U>(f: (value: T) => IFunctor<U>): IFunctor<U>;
@@ -6,4 +60,4 @@ interface IFunctor<T> {
6
60
  foldRight<U>(initialValue: U, f: (value: T, acc: U) => U): U;
7
61
  }
8
62
 
9
- export { IFunctor };
63
+ export { Either, IFunctor, Left, List, Right, left, parseNumber, right };
package/dist/index.js CHANGED
@@ -0,0 +1 @@
1
+ import{a,b as o,c as r}from"./chunk-QK5JVYJ3.js";import{a as U}from"./chunk-ABUN2GHU.js";import{a as e}from"./chunk-CN6MP6AJ.js";import"./chunk-ZTL76QDL.js";import{a as t}from"./chunk-E4GBAXJ4.js";import"./chunk-VTKL7OQI.js";export{U as Left,t as List,e as Right,a as left,r as parseNumber,o as right};
@@ -1 +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.List = n;
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkPXY4XULGcjs = require('../chunk-PXY4XULG.cjs');require('../chunk-GWLTG6GZ.cjs');exports.List = _chunkPXY4XULGcjs.a;
@@ -1,20 +1,2 @@
1
- import { IFunctor } from '../index.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
- export { List };
1
+ export { List } from '../index.cjs';
2
+ import '../error/ParseError.cjs';
@@ -1,20 +1,2 @@
1
- import { IFunctor } from '../index.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
- export { List };
1
+ export { List } from '../index.js';
2
+ import '../error/ParseError.js';
package/dist/list/List.js CHANGED
@@ -1 +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 List};
1
+ import{a}from"../chunk-E4GBAXJ4.js";import"../chunk-VTKL7OQI.js";export{a as List};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "functype",
3
- "version": "0.0.4",
3
+ "version": "0.0.6",
4
4
  "description": "A small functional library for TypeScript",
5
5
  "author": "jordan.burke@gmail.com",
6
6
  "license": "MIT",
@@ -1,39 +0,0 @@
1
- import { ParseError } from './error/ParseError.js';
2
- import { IFunctor } from './index.js';
3
-
4
- declare class Right<L, R> implements Either<L, R> {
5
- value: R;
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
- 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;
14
- }
15
-
16
- declare class Left<L, R> implements Either<L, R> {
17
- value: L;
18
- constructor(value: L);
19
- isLeft(): this is Left<L, R>;
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>;
32
- map<U>(f: (value: R) => U): Either<L, U>;
33
- flatMap<U>(f: (value: R) => Either<L, U>): Either<L, U>;
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>;
38
-
39
- export { Either as E, Left as L, Right as R, left as l, parseNumber as p, right as r };
@@ -1,39 +0,0 @@
1
- import { ParseError } from './error/ParseError.cjs';
2
- import { IFunctor } from './index.cjs';
3
-
4
- declare class Right<L, R> implements Either<L, R> {
5
- value: R;
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
- 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;
14
- }
15
-
16
- declare class Left<L, R> implements Either<L, R> {
17
- value: L;
18
- constructor(value: L);
19
- isLeft(): this is Left<L, R>;
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>;
32
- map<U>(f: (value: R) => U): Either<L, U>;
33
- flatMap<U>(f: (value: R) => Either<L, U>): Either<L, U>;
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>;
38
-
39
- export { Either as E, Left as L, Right as R, left as l, parseNumber as p, right as r };