functype 0.4.0 → 0.4.1

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 (132) hide show
  1. package/dist/{chunk-LO5XBCIY.js → chunk-3APFKSCC.js} +1 -1
  2. package/dist/chunk-63PL65AF.js +1 -0
  3. package/dist/chunk-6FZZWNOL.js +1 -0
  4. package/dist/{chunk-UVR6IELR.mjs → chunk-E35CYHY2.mjs} +1 -1
  5. package/dist/chunk-HH4VYR73.js +1 -0
  6. package/dist/chunk-HOO2EPER.mjs +1 -0
  7. package/dist/{chunk-OLJYBLCT.js → chunk-I4BEM5D2.js} +1 -1
  8. package/dist/chunk-J4OZ7K3I.mjs +1 -0
  9. package/dist/{chunk-U37JTC3U.mjs → chunk-JR557W27.mjs} +1 -1
  10. package/dist/{chunk-D22QKJZO.js → chunk-O2XFH626.js} +1 -1
  11. package/dist/chunk-R7GOBZSO.mjs +1 -0
  12. package/dist/{chunk-SPNWCOGV.mjs → chunk-RLT5VF56.mjs} +1 -1
  13. package/dist/chunk-SKJIJETA.js +1 -0
  14. package/dist/{chunk-WMSIRQ3W.mjs → chunk-TYHKMGLC.mjs} +1 -1
  15. package/dist/{chunk-CPB6NX2S.js → chunk-XKON5UBC.js} +1 -1
  16. package/dist/{chunk-S5YAJ7CP.mjs → chunk-Z2XAS3AB.mjs} +1 -1
  17. package/dist/collections/index.d.mts +2 -1
  18. package/dist/collections/index.d.ts +2 -1
  19. package/dist/either/Either.d.mts +2 -1
  20. package/dist/either/Either.d.ts +2 -1
  21. package/dist/either/Either.js +1 -1
  22. package/dist/either/Either.mjs +1 -1
  23. package/dist/either/index.d.mts +2 -1
  24. package/dist/either/index.d.ts +2 -1
  25. package/dist/either/index.js +1 -1
  26. package/dist/either/index.mjs +1 -1
  27. package/dist/error/ParseError.js +1 -1
  28. package/dist/error/ParseError.mjs +1 -1
  29. package/dist/{index-BSx1ncJ9.d.ts → index-BIu07QR3.d.ts} +5 -4
  30. package/dist/{index-uP_Hoh2D.d.mts → index-DC8arpKk.d.mts} +5 -4
  31. package/dist/index.d.mts +2 -1
  32. package/dist/index.d.ts +2 -1
  33. package/dist/index.js +1 -1
  34. package/dist/index.mjs +1 -1
  35. package/dist/iterable/Seq.d.mts +2 -1
  36. package/dist/iterable/Seq.d.ts +2 -1
  37. package/dist/iterable/Seq.js +1 -1
  38. package/dist/iterable/Seq.mjs +1 -1
  39. package/dist/iterable/index.d.mts +2 -1
  40. package/dist/iterable/index.d.ts +2 -1
  41. package/dist/iterable/index.js +1 -1
  42. package/dist/iterable/index.mjs +1 -1
  43. package/dist/list/List.d.mts +2 -1
  44. package/dist/list/List.d.ts +2 -1
  45. package/dist/list/List.js +1 -1
  46. package/dist/list/List.mjs +1 -1
  47. package/dist/list/index.d.mts +2 -1
  48. package/dist/list/index.d.ts +2 -1
  49. package/dist/list/index.js +1 -1
  50. package/dist/list/index.mjs +1 -1
  51. package/dist/map/Map.d.mts +2 -1
  52. package/dist/map/Map.d.ts +2 -1
  53. package/dist/map/Map.js +1 -1
  54. package/dist/map/Map.mjs +1 -1
  55. package/dist/map/index.d.mts +2 -1
  56. package/dist/map/index.d.ts +2 -1
  57. package/dist/map/index.js +1 -1
  58. package/dist/map/index.mjs +1 -1
  59. package/dist/map/shim.js +1 -1
  60. package/dist/map/shim.mjs +1 -1
  61. package/dist/option/Option.d.mts +2 -1
  62. package/dist/option/Option.d.ts +2 -1
  63. package/dist/option/Option.js +1 -1
  64. package/dist/option/Option.mjs +1 -1
  65. package/dist/option/index.d.mts +2 -1
  66. package/dist/option/index.d.ts +2 -1
  67. package/dist/option/index.js +1 -1
  68. package/dist/option/index.mjs +1 -1
  69. package/dist/set/Set.d.mts +2 -1
  70. package/dist/set/Set.d.ts +2 -1
  71. package/dist/set/Set.js +1 -1
  72. package/dist/set/Set.mjs +1 -1
  73. package/dist/set/index.d.mts +2 -1
  74. package/dist/set/index.d.ts +2 -1
  75. package/dist/set/index.js +1 -1
  76. package/dist/set/index.mjs +1 -1
  77. package/dist/set/shim.js +1 -1
  78. package/dist/set/shim.mjs +1 -1
  79. package/dist/try/Try.d.mts +2 -1
  80. package/dist/try/Try.d.ts +2 -1
  81. package/dist/try/Try.js +1 -1
  82. package/dist/try/Try.mjs +1 -1
  83. package/dist/try/index.d.mts +2 -1
  84. package/dist/try/index.d.ts +2 -1
  85. package/dist/try/index.js +1 -1
  86. package/dist/try/index.mjs +1 -1
  87. package/dist/tuple/Tuple.d.mts +1 -0
  88. package/dist/tuple/Tuple.d.ts +1 -0
  89. package/dist/tuple/Tuple.js +1 -1
  90. package/dist/tuple/Tuple.mjs +1 -1
  91. package/dist/tuple/index.d.mts +8 -2
  92. package/dist/tuple/index.d.ts +8 -2
  93. package/dist/tuple/index.js +1 -1
  94. package/dist/tuple/index.mjs +1 -1
  95. package/dist/util/index.d.mts +2 -1
  96. package/dist/util/index.d.ts +2 -1
  97. package/dist/util/index.js +1 -1
  98. package/dist/util/index.mjs +1 -1
  99. package/dist/util/isIterable.js +1 -1
  100. package/dist/util/isIterable.mjs +1 -1
  101. package/lib/collections/index.d.ts +8 -0
  102. package/lib/either/Either.d.ts +32 -0
  103. package/lib/either/index.d.ts +4 -0
  104. package/lib/error/ParseError.d.ts +2 -0
  105. package/lib/functor/index.d.ts +15 -0
  106. package/lib/index.d.ts +19 -0
  107. package/lib/iterable/Seq.d.ts +25 -0
  108. package/lib/iterable/index.d.ts +22 -0
  109. package/lib/list/List.d.ts +23 -0
  110. package/lib/list/index.d.ts +3 -0
  111. package/lib/map/Map.d.ts +37 -0
  112. package/lib/map/index.d.ts +1 -0
  113. package/lib/map/shim.d.ts +2 -0
  114. package/lib/option/Option.d.ts +44 -0
  115. package/lib/option/index.d.ts +5 -0
  116. package/lib/set/Set.d.ts +18 -0
  117. package/lib/set/index.d.ts +1 -0
  118. package/lib/set/shim.d.ts +2 -0
  119. package/lib/try/Try.d.ts +19 -0
  120. package/lib/try/index.d.ts +1 -0
  121. package/lib/tuple/Tuple.d.ts +16 -0
  122. package/lib/tuple/index.d.ts +1 -0
  123. package/lib/util/index.d.ts +3 -0
  124. package/lib/util/isIterable.d.ts +1 -0
  125. package/package.json +12 -12
  126. package/dist/chunk-4P46BMZQ.js +0 -1
  127. package/dist/chunk-7JTQ2BTE.mjs +0 -1
  128. package/dist/chunk-GZIDEEAG.mjs +0 -1
  129. package/dist/chunk-HF33BEHO.js +0 -1
  130. package/dist/chunk-LBQXRIXP.mjs +0 -0
  131. package/dist/chunk-LLZGG3YT.js +0 -1
  132. package/dist/chunk-TVZBBVEV.js +0 -1
package/dist/try/Try.d.ts CHANGED
@@ -1,3 +1,4 @@
1
- export { T as Try, j as _Try_ } from '../index-BSx1ncJ9.js';
1
+ export { T as Try, k as _Try_ } from '../index-BIu07QR3.js';
2
2
  import '../functor/index.js';
3
3
  import '../tuple/Tuple.js';
4
+ import '../tuple/index.js';
package/dist/try/Try.js CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkOLJYBLCTjs = require('../chunk-OLJYBLCT.js');require('../chunk-LLZGG3YT.js');require('../chunk-HF33BEHO.js');require('../chunk-CPB6NX2S.js');require('../chunk-3VJERXBP.js');require('../chunk-XVHCBGUW.js');require('../chunk-LO5XBCIY.js');require('../chunk-BNNK42JC.js');require('../chunk-D22QKJZO.js');exports.Try = _chunkOLJYBLCTjs.a;
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkI4BEM5D2js = require('../chunk-I4BEM5D2.js');require('../chunk-63PL65AF.js');require('../chunk-HH4VYR73.js');require('../chunk-XKON5UBC.js');require('../chunk-3VJERXBP.js');require('../chunk-XVHCBGUW.js');require('../chunk-3APFKSCC.js');require('../chunk-BNNK42JC.js');require('../chunk-O2XFH626.js');exports.Try = _chunkI4BEM5D2js.a;
package/dist/try/Try.mjs CHANGED
@@ -1 +1 @@
1
- import{a}from"../chunk-SPNWCOGV.mjs";import"../chunk-GZIDEEAG.mjs";import"../chunk-S5YAJ7CP.mjs";import"../chunk-UVR6IELR.mjs";import"../chunk-HA5XD5KC.mjs";import"../chunk-74TKYQJS.mjs";import"../chunk-WMSIRQ3W.mjs";import"../chunk-RRAIFS3D.mjs";import"../chunk-U37JTC3U.mjs";export{a as Try};
1
+ import{a}from"../chunk-RLT5VF56.mjs";import"../chunk-J4OZ7K3I.mjs";import"../chunk-Z2XAS3AB.mjs";import"../chunk-E35CYHY2.mjs";import"../chunk-HA5XD5KC.mjs";import"../chunk-74TKYQJS.mjs";import"../chunk-TYHKMGLC.mjs";import"../chunk-RRAIFS3D.mjs";import"../chunk-JR557W27.mjs";export{a as Try};
@@ -1,3 +1,4 @@
1
- export { T as Try, j as _Try_ } from '../index-uP_Hoh2D.mjs';
1
+ export { T as Try, k as _Try_ } from '../index-DC8arpKk.mjs';
2
2
  import '../functor/index.mjs';
3
3
  import '../tuple/Tuple.mjs';
4
+ import '../tuple/index.mjs';
@@ -1,3 +1,4 @@
1
- export { T as Try, j as _Try_ } from '../index-BSx1ncJ9.js';
1
+ export { T as Try, k as _Try_ } from '../index-BIu07QR3.js';
2
2
  import '../functor/index.js';
3
3
  import '../tuple/Tuple.js';
4
+ import '../tuple/index.js';
package/dist/try/index.js CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});require('../chunk-6BEXQNLZ.js');var _chunkOLJYBLCTjs = require('../chunk-OLJYBLCT.js');require('../chunk-LLZGG3YT.js');require('../chunk-HF33BEHO.js');require('../chunk-CPB6NX2S.js');require('../chunk-3VJERXBP.js');require('../chunk-XVHCBGUW.js');require('../chunk-LO5XBCIY.js');require('../chunk-BNNK42JC.js');require('../chunk-D22QKJZO.js');exports.Try = _chunkOLJYBLCTjs.a;
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});require('../chunk-6BEXQNLZ.js');var _chunkI4BEM5D2js = require('../chunk-I4BEM5D2.js');require('../chunk-63PL65AF.js');require('../chunk-HH4VYR73.js');require('../chunk-XKON5UBC.js');require('../chunk-3VJERXBP.js');require('../chunk-XVHCBGUW.js');require('../chunk-3APFKSCC.js');require('../chunk-BNNK42JC.js');require('../chunk-O2XFH626.js');exports.Try = _chunkI4BEM5D2js.a;
@@ -1 +1 @@
1
- import"../chunk-Q4H3PCBH.mjs";import{a}from"../chunk-SPNWCOGV.mjs";import"../chunk-GZIDEEAG.mjs";import"../chunk-S5YAJ7CP.mjs";import"../chunk-UVR6IELR.mjs";import"../chunk-HA5XD5KC.mjs";import"../chunk-74TKYQJS.mjs";import"../chunk-WMSIRQ3W.mjs";import"../chunk-RRAIFS3D.mjs";import"../chunk-U37JTC3U.mjs";export{a as Try};
1
+ import"../chunk-Q4H3PCBH.mjs";import{a}from"../chunk-RLT5VF56.mjs";import"../chunk-J4OZ7K3I.mjs";import"../chunk-Z2XAS3AB.mjs";import"../chunk-E35CYHY2.mjs";import"../chunk-HA5XD5KC.mjs";import"../chunk-74TKYQJS.mjs";import"../chunk-TYHKMGLC.mjs";import"../chunk-RRAIFS3D.mjs";import"../chunk-JR557W27.mjs";export{a as Try};
@@ -5,6 +5,7 @@ type _Tuple_<T extends ArrayType> = _ArrayFunctor_<T> & {
5
5
  getAs<U>(index: number, f?: (item: T) => boolean): U;
6
6
  map<U extends any[]>(f: (value: T) => U): _Tuple_<U>;
7
7
  flatMap<U extends any[]>(f: (value: T) => _Tuple_<U>): _Tuple_<U>;
8
+ toArray(): T;
8
9
  };
9
10
  declare class Tuple<T extends ArrayType> implements _Tuple_<T> {
10
11
  private readonly values;
@@ -5,6 +5,7 @@ type _Tuple_<T extends ArrayType> = _ArrayFunctor_<T> & {
5
5
  getAs<U>(index: number, f?: (item: T) => boolean): U;
6
6
  map<U extends any[]>(f: (value: T) => U): _Tuple_<U>;
7
7
  flatMap<U extends any[]>(f: (value: T) => _Tuple_<U>): _Tuple_<U>;
8
+ toArray(): T;
8
9
  };
9
10
  declare class Tuple<T extends ArrayType> implements _Tuple_<T> {
10
11
  private readonly values;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkV5UFW2E4js = require('../chunk-V5UFW2E4.js');require('../chunk-D22QKJZO.js');exports.Tuple = _chunkV5UFW2E4js.a;
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkV5UFW2E4js = require('../chunk-V5UFW2E4.js');require('../chunk-O2XFH626.js');exports.Tuple = _chunkV5UFW2E4js.a;
@@ -1 +1 @@
1
- import{a}from"../chunk-2XH6TPQK.mjs";import"../chunk-U37JTC3U.mjs";export{a as Tuple};
1
+ import{a}from"../chunk-2XH6TPQK.mjs";import"../chunk-JR557W27.mjs";export{a as Tuple};
@@ -1,2 +1,8 @@
1
- export { Tuple, _Tuple_ } from './Tuple.mjs';
2
- import '../functor/index.mjs';
1
+ import { ArrayType } from '../functor/index.mjs';
2
+ import { Tuple } from './Tuple.mjs';
3
+ export { _Tuple_ } from './Tuple.mjs';
4
+
5
+ declare const t: <T extends ArrayType>(values: T) => Tuple<T>;
6
+ declare const tuple: <T extends ArrayType>(values: T) => Tuple<T>;
7
+
8
+ export { Tuple, t, tuple };
@@ -1,2 +1,8 @@
1
- export { Tuple, _Tuple_ } from './Tuple.js';
2
- import '../functor/index.js';
1
+ import { ArrayType } from '../functor/index.js';
2
+ import { Tuple } from './Tuple.js';
3
+ export { _Tuple_ } from './Tuple.js';
4
+
5
+ declare const t: <T extends ArrayType>(values: T) => Tuple<T>;
6
+ declare const tuple: <T extends ArrayType>(values: T) => Tuple<T>;
7
+
8
+ export { Tuple, t, tuple };
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});require('../chunk-TVZBBVEV.js');var _chunkV5UFW2E4js = require('../chunk-V5UFW2E4.js');require('../chunk-D22QKJZO.js');exports.Tuple = _chunkV5UFW2E4js.a;
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkSKJIJETAjs = require('../chunk-SKJIJETA.js');var _chunkV5UFW2E4js = require('../chunk-V5UFW2E4.js');require('../chunk-O2XFH626.js');exports.Tuple = _chunkV5UFW2E4js.a; exports.t = _chunkSKJIJETAjs.a; exports.tuple = _chunkSKJIJETAjs.b;
@@ -1 +1 @@
1
- import"../chunk-LBQXRIXP.mjs";import{a}from"../chunk-2XH6TPQK.mjs";import"../chunk-U37JTC3U.mjs";export{a as Tuple};
1
+ import{a as b,b as c}from"../chunk-HOO2EPER.mjs";import{a}from"../chunk-2XH6TPQK.mjs";import"../chunk-JR557W27.mjs";export{a as Tuple,b as t,c as tuple};
@@ -1,7 +1,8 @@
1
1
  import { ParseError } from '../error/ParseError.mjs';
2
- import { E as Either } from '../index-uP_Hoh2D.mjs';
2
+ import { E as Either } from '../index-DC8arpKk.mjs';
3
3
  import '../functor/index.mjs';
4
4
  import '../tuple/Tuple.mjs';
5
+ import '../tuple/index.mjs';
5
6
 
6
7
  declare const parseNumber: (input: string) => Either<ParseError, number>;
7
8
 
@@ -1,7 +1,8 @@
1
1
  import { ParseError } from '../error/ParseError.js';
2
- import { E as Either } from '../index-BSx1ncJ9.js';
2
+ import { E as Either } from '../index-BIu07QR3.js';
3
3
  import '../functor/index.js';
4
4
  import '../tuple/Tuple.js';
5
+ import '../tuple/index.js';
5
6
 
6
7
  declare const parseNumber: (input: string) => Either<ParseError, number>;
7
8
 
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkLLZGG3YTjs = require('../chunk-LLZGG3YT.js');require('../chunk-HF33BEHO.js');require('../chunk-CPB6NX2S.js');require('../chunk-3VJERXBP.js');require('../chunk-XVHCBGUW.js');require('../chunk-LO5XBCIY.js');require('../chunk-BNNK42JC.js');var _chunkZTL76QDLjs = require('../chunk-ZTL76QDL.js');require('../chunk-D22QKJZO.js');var n=s=>{let r=parseInt(s,10);return isNaN(r)?_chunkLLZGG3YTjs.a.call(void 0, new (0, _chunkZTL76QDLjs.a)(`${r}`)):_chunkLLZGG3YTjs.b.call(void 0, r)};exports.parseNumber = n;
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunk63PL65AFjs = require('../chunk-63PL65AF.js');require('../chunk-HH4VYR73.js');require('../chunk-XKON5UBC.js');require('../chunk-3VJERXBP.js');var _chunkZTL76QDLjs = require('../chunk-ZTL76QDL.js');require('../chunk-XVHCBGUW.js');require('../chunk-3APFKSCC.js');require('../chunk-BNNK42JC.js');require('../chunk-O2XFH626.js');var n=s=>{let r=parseInt(s,10);return isNaN(r)?_chunk63PL65AFjs.a.call(void 0, new (0, _chunkZTL76QDLjs.a)(`${r}`)):_chunk63PL65AFjs.b.call(void 0, r)};exports.parseNumber = n;
@@ -1 +1 @@
1
- import{a as e,b as t}from"../chunk-GZIDEEAG.mjs";import"../chunk-S5YAJ7CP.mjs";import"../chunk-UVR6IELR.mjs";import"../chunk-HA5XD5KC.mjs";import"../chunk-74TKYQJS.mjs";import"../chunk-WMSIRQ3W.mjs";import"../chunk-RRAIFS3D.mjs";import{a as o}from"../chunk-CFYIJKWF.mjs";import"../chunk-U37JTC3U.mjs";var n=s=>{let r=parseInt(s,10);return isNaN(r)?e(new o(`${r}`)):t(r)};export{n as parseNumber};
1
+ import{a as e,b as t}from"../chunk-J4OZ7K3I.mjs";import"../chunk-Z2XAS3AB.mjs";import"../chunk-E35CYHY2.mjs";import"../chunk-HA5XD5KC.mjs";import{a as o}from"../chunk-CFYIJKWF.mjs";import"../chunk-74TKYQJS.mjs";import"../chunk-TYHKMGLC.mjs";import"../chunk-RRAIFS3D.mjs";import"../chunk-JR557W27.mjs";var n=s=>{let r=parseInt(s,10);return isNaN(r)?e(new o(`${r}`)):t(r)};export{n as parseNumber};
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkBNNK42JCjs = require('../chunk-BNNK42JC.js');require('../chunk-D22QKJZO.js');exports.isIterable = _chunkBNNK42JCjs.a;
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkBNNK42JCjs = require('../chunk-BNNK42JC.js');require('../chunk-O2XFH626.js');exports.isIterable = _chunkBNNK42JCjs.a;
@@ -1 +1 @@
1
- import{a}from"../chunk-RRAIFS3D.mjs";import"../chunk-U37JTC3U.mjs";export{a as isIterable};
1
+ import{a}from"../chunk-RRAIFS3D.mjs";import"../chunk-JR557W27.mjs";export{a as isIterable};
@@ -0,0 +1,8 @@
1
+ import { _Set_ } from "../set";
2
+ import { _List_ } from "../list";
3
+ export type IConverters<A> = {
4
+ toList(): _List_<A>;
5
+ toSet(): _Set_<A>;
6
+ toString(): string;
7
+ };
8
+ export type _Collection<A> = IConverters<A>;
@@ -0,0 +1,32 @@
1
+ import { _Option_ } from "../option";
2
+ import { List } from "../list";
3
+ import { _Functor_ } from "../functor";
4
+ export type Either<L, R> = {
5
+ value: L | R;
6
+ isLeft(): boolean;
7
+ isRight(): boolean;
8
+ map<U>(f: (value: R) => U): Either<L, U>;
9
+ flatMap<U>(f: (value: R) => Either<L, U>): Either<L, U>;
10
+ toOption(): _Option_<R>;
11
+ toList(): List<R>;
12
+ } & _Functor_<R>;
13
+ export declare class Right<L, R> implements Either<L, R> {
14
+ value: R;
15
+ constructor(value: R);
16
+ isLeft(): this is Left<L, R>;
17
+ isRight(): this is Right<L, R>;
18
+ map<U>(f: (value: R) => U): Either<L, U>;
19
+ flatMap<U>(f: (value: R) => Either<L, U>): Either<L, U>;
20
+ toOption(): _Option_<R>;
21
+ toList(): List<R>;
22
+ }
23
+ export declare class Left<L, R> implements Either<L, R> {
24
+ value: L;
25
+ constructor(value: L);
26
+ isLeft(): this is Left<L, R>;
27
+ isRight(): this is Right<L, R>;
28
+ map<U>(_f: (value: R) => U): Either<L, U>;
29
+ flatMap<U>(_f: (value: R) => Either<L, U>): Either<L, U>;
30
+ toOption(): _Option_<R>;
31
+ toList(): List<R>;
32
+ }
@@ -0,0 +1,4 @@
1
+ import { Either, Left, Right } from "./Either";
2
+ export declare const left: <L, R>(value: L) => Either<L, R>;
3
+ export declare const right: <L, R>(value: R) => Either<L, R>;
4
+ export { Left, Right, Either };
@@ -0,0 +1,2 @@
1
+ export declare class ParseError extends Error {
2
+ }
@@ -0,0 +1,15 @@
1
+ export type SingleType = any;
2
+ export type ArrayType = SingleType[];
3
+ export type Type = SingleType | ArrayType;
4
+ export type _AbstractFunctor_<A extends Type> = {
5
+ map(f: (value: A) => Type): _AbstractFunctor_<Type>;
6
+ flatMap(f: (value: A) => _AbstractFunctor_<Type>): _AbstractFunctor_<Type>;
7
+ };
8
+ export type _Functor_<A extends Type> = _AbstractFunctor_<A> & {
9
+ map<B extends Type>(f: (value: A) => B): _Functor_<B>;
10
+ flatMap<B extends Type>(f: (value: A) => _Functor_<B>): _Functor_<B>;
11
+ };
12
+ export type _ArrayFunctor_<A extends ArrayType> = _AbstractFunctor_<A> & {
13
+ map<U extends ArrayType>(f: (value: A) => U): _ArrayFunctor_<U>;
14
+ flatMap<U extends ArrayType>(f: (value: A) => _ArrayFunctor_<U>): _ArrayFunctor_<U>;
15
+ };
package/lib/index.d.ts ADDED
@@ -0,0 +1,19 @@
1
+ import { _Functor_, Type } from "./functor";
2
+ export type _Traversable_<A extends Type> = _Functor_<A> & {
3
+ get size(): number;
4
+ get isEmpty(): boolean;
5
+ contains(value: A): boolean;
6
+ reduce(f: (b: A, a: A) => A): A;
7
+ reduceRight(f: (b: A, a: A) => A): A;
8
+ foldLeft<B>(z: B): (op: (b: B, a: A) => B) => B;
9
+ foldRight<B>(z: B): (op: (a: A, b: B) => B) => B;
10
+ };
11
+ export * from "./functor";
12
+ export * from "./iterable";
13
+ export * from "./list";
14
+ export * from "./map";
15
+ export * from "./option";
16
+ export * from "./either";
17
+ export * from "./set";
18
+ export * from "./tuple";
19
+ export * from "./try";
@@ -0,0 +1,25 @@
1
+ import { _Iterable_ } from "./index";
2
+ import { _Option_ } from "../option";
3
+ export declare class Seq<A> implements _Iterable_<A> {
4
+ protected readonly values: Iterable<A>;
5
+ constructor(values?: Iterable<A> | _Iterable_<A>);
6
+ readonly [n: number]: A;
7
+ get length(): number;
8
+ map<B>(f: (a: A) => B): _Iterable_<B>;
9
+ flatMap<B>(f: (a: A) => _Iterable_<B>): _Iterable_<B>;
10
+ forEach(f: (a: A) => void): void;
11
+ count(p: (x: A) => boolean): number;
12
+ exists(p: (a: A) => boolean): Boolean;
13
+ filter(p: (a: A) => boolean): _Iterable_<A>;
14
+ filterNot(p: (a: A) => boolean): _Iterable_<A>;
15
+ find(p: (a: A) => boolean): _Option_<A>;
16
+ get head(): A;
17
+ get headOption(): _Option_<A>;
18
+ get isEmpty(): boolean;
19
+ get size(): number;
20
+ toArray(): A[];
21
+ reduce(f: (prev: A, curr: A) => A): A;
22
+ reduceRight(f: (prev: A, curr: A) => A): A;
23
+ foldLeft<B>(z: B): (op: (b: B, a: A) => B) => B;
24
+ foldRight<B>(z: B): (op: (a: A, b: B) => B) => B;
25
+ }
@@ -0,0 +1,22 @@
1
+ import { _Functor_, Type } from "../functor";
2
+ import { _Option_ } from "../option";
3
+ export type _Iterable_<A extends Type> = {
4
+ count(p: (x: A) => boolean): number;
5
+ find(p: (a: A) => boolean): _Option_<A>;
6
+ forEach(f: (a: A) => void): void;
7
+ exists(p: (a: A) => boolean): Boolean;
8
+ filter(p: (a: A) => boolean): _Iterable_<A>;
9
+ filterNot(p: (a: A) => boolean): _Iterable_<A>;
10
+ reduce(f: (b: A, a: A) => A): A;
11
+ reduceRight(f: (b: A, a: A) => A): A;
12
+ foldLeft<B>(z: B): (op: (b: B, a: A) => B) => B;
13
+ foldRight<B>(z: B): (op: (a: A, b: B) => B) => B;
14
+ get head(): A;
15
+ get headOption(): _Option_<A>;
16
+ get isEmpty(): boolean;
17
+ map<B extends Type>(f: (a: A) => B): _Iterable_<B>;
18
+ flatMap<B extends Type>(f: (a: A) => _Iterable_<B>): _Iterable_<B>;
19
+ get size(): number;
20
+ toArray(): readonly A[];
21
+ } & _Functor_<A>;
22
+ export { Seq } from "./Seq";
@@ -0,0 +1,23 @@
1
+ import { _Iterable_ } from "../iterable";
2
+ import { Seq } from "../iterable";
3
+ import { _Collection } from "../collections";
4
+ import { Set } from "../set";
5
+ import { _Option_ } from "../option";
6
+ export interface _List_<T> extends _Iterable_<T>, ArrayLike<T> {
7
+ add(item: T): _List_<T>;
8
+ }
9
+ export declare class List<A> extends Seq<A> implements _List_<A>, _Collection<A> {
10
+ constructor(values?: Iterable<A> | _Iterable_<A>);
11
+ readonly [n: number]: A;
12
+ map<B>(f: (a: A) => B): List<B>;
13
+ flatMap<B>(f: (a: A) => _Iterable_<B>): List<B>;
14
+ remove(value: A): List<A>;
15
+ contains(value: A): boolean;
16
+ add(item: A): List<A>;
17
+ removeAt(index: number): List<A>;
18
+ get(index: number): _Option_<A>;
19
+ concat(other: List<A>): List<A>;
20
+ toList(): _List_<A>;
21
+ toSet(): Set<A>;
22
+ toString(): string;
23
+ }
@@ -0,0 +1,3 @@
1
+ import { List, _List_ } from "./List";
2
+ declare const list: <T extends unknown>(items: T[] | undefined) => List<T>;
3
+ export { list, List, _List_ };
@@ -0,0 +1,37 @@
1
+ import { _Tuple_, Tuple } from "../tuple";
2
+ import { _Set_ } from "../set";
3
+ import { _Option_ } from "../option";
4
+ import { _List_ } from "../list";
5
+ import { _Traversable_ } from "../index";
6
+ import { _Collection } from "../collections";
7
+ type SafeTraversable<K, V> = Omit<_Traversable_<_Tuple_<[K, V]>>, "map" | "flatMap">;
8
+ export type _Map_<K, V> = {
9
+ map<U>(f: (value: any) => U): _Map_<K, U>;
10
+ flatMap<U>(f: (value: any) => _Map_<K, U>): _Map_<K, U>;
11
+ get(key: K): _Option_<V>;
12
+ getOrElse(key: K, defaultValue: V): V;
13
+ orElse(key: K, alternative: _Option_<V>): _Option_<V>;
14
+ } & SafeTraversable<K, V> & _Collection<_Tuple_<[K, V]>>;
15
+ export declare class Map<K, V> implements _Map_<K, V> {
16
+ private values;
17
+ private get entries();
18
+ constructor(entries?: readonly (readonly [K, V])[] | IterableIterator<[K, V]> | null);
19
+ add(item: _Tuple_<[K, V]>): Map<K, V>;
20
+ remove(value: _Tuple_<[K, V]>): Map<K, V>;
21
+ contains(value: _Tuple_<[K, V]>): boolean;
22
+ get size(): number;
23
+ map<U>(f: (value: V) => U): _Map_<K, U>;
24
+ flatMap<U>(f: (value: V) => _Map_<K, U>): _Map_<K, U>;
25
+ reduce(f: (acc: Tuple<[K, V]>, value: Tuple<[K, V]>) => Tuple<[K, V]>): Tuple<[K, V]>;
26
+ reduceRight(f: (acc: Tuple<[K, V]>, value: Tuple<[K, V]>) => Tuple<[K, V]>): Tuple<[K, V]>;
27
+ foldLeft<B>(z: B): (op: (b: B, a: _Tuple_<[K, V]>) => B) => B;
28
+ foldRight<B>(z: B): (op: (a: _Tuple_<[K, V]>, b: B) => B) => B;
29
+ get(key: K): _Option_<V>;
30
+ getOrElse(key: K, defaultValue: V): V;
31
+ get isEmpty(): boolean;
32
+ orElse(key: K, alternative: _Option_<V>): _Option_<V>;
33
+ toList(): _List_<Tuple<[K, V]>>;
34
+ toSet(): _Set_<Tuple<[K, V]>>;
35
+ toString(): string;
36
+ }
37
+ export {};
@@ -0,0 +1 @@
1
+ export { Map, _Map_ } from "./Map";
@@ -0,0 +1,2 @@
1
+ export type IESMap<K, V> = Map<K, V>;
2
+ export declare const ESMap: MapConstructor;
@@ -0,0 +1,44 @@
1
+ import { _Functor_, Type } from "../functor";
2
+ import { _Traversable_ } from "../index";
3
+ import { _Iterable_ } from "../iterable";
4
+ export type _Option_<T extends Type> = {
5
+ get(): T;
6
+ getOrElse(defaultValue: T): T;
7
+ orElse(alternative: _Option_<T>): _Option_<T>;
8
+ map<U extends Type>(f: (value: T) => U): _Option_<U>;
9
+ flatMap<U extends Type>(f: (value: T) => _Option_<U>): _Option_<U>;
10
+ toList(): _Iterable_<T>;
11
+ valueOf(): Object;
12
+ } & _Traversable_<T> & _Functor_<T>;
13
+ export declare class Some<A extends Type> implements _Option_<A> {
14
+ private value;
15
+ constructor(value: A);
16
+ get isEmpty(): boolean;
17
+ get(): A;
18
+ getOrElse(defaultValue: A): A;
19
+ orElse(alternative: _Option_<A>): _Option_<A>;
20
+ map<U extends Type>(f: (value: A) => U): _Option_<U>;
21
+ flatMap<U extends Type>(f: (value: A) => _Option_<U>): _Option_<U>;
22
+ reduce<U>(f: (acc: U, value: A) => U): U;
23
+ reduceRight<U>(f: (acc: U, value: A) => U): U;
24
+ foldLeft<B>(z: B): (op: (b: B, a: A) => B) => B;
25
+ foldRight<B>(z: B): (op: (a: A, b: B) => B) => B;
26
+ toList(): _Iterable_<A>;
27
+ contains(value: A): boolean;
28
+ get size(): number;
29
+ }
30
+ export declare class None<A extends Type> implements _Option_<A> {
31
+ get isEmpty(): boolean;
32
+ get(): A;
33
+ getOrElse(defaultValue: A): A;
34
+ orElse(alternative: _Option_<A>): _Option_<A>;
35
+ map<U extends Type>(f: (value: A) => U): _Option_<U>;
36
+ flatMap<U extends Type>(f: (value: A) => _Option_<U>): _Option_<U>;
37
+ reduce(f: (acc: A, value: A) => A): A;
38
+ reduceRight(f: (b: A, a: A) => A): A;
39
+ foldLeft<B>(z: B): (op: (b: B, a: A) => B) => B;
40
+ foldRight<B>(z: B): (op: (a: A, b: B) => B) => B;
41
+ toList(): _Iterable_<A>;
42
+ contains(value: A): boolean;
43
+ get size(): number;
44
+ }
@@ -0,0 +1,5 @@
1
+ import { None, _Option_, Some } from "./Option";
2
+ export declare const option: <T extends unknown>(value?: T) => _Option_<T>;
3
+ export declare const some: <T extends unknown>(value: T) => _Option_<T>;
4
+ export declare const none: <T extends unknown>() => _Option_<T>;
5
+ export { _Option_, Some, None };
@@ -0,0 +1,18 @@
1
+ import { _Iterable_, Seq } from "../iterable";
2
+ import { _List_ } from "../list";
3
+ import { _Collection } from "../collections";
4
+ export type _Set_<T> = {
5
+ has(value: T): boolean;
6
+ } & _Iterable_<T> & _Collection<T>;
7
+ export declare class Set<A> extends Seq<A> implements _Set_<A> {
8
+ constructor(iterable?: Iterable<A> | _Iterable_<A>);
9
+ add(value: A): Set<A>;
10
+ remove(value: A): Set<A>;
11
+ contains(value: A): boolean;
12
+ has(value: A): boolean;
13
+ map<B>(f: (a: A) => B): Set<B>;
14
+ flatMap<B>(f: (a: A) => _Iterable_<B>): Set<B>;
15
+ toList(): _List_<A>;
16
+ toSet(): _Set_<A>;
17
+ toString(): string;
18
+ }
@@ -0,0 +1 @@
1
+ export { Set, _Set_ } from "./Set";
@@ -0,0 +1,2 @@
1
+ export type IESSet<T> = Set<T>;
2
+ export declare const ESSet: SetConstructor;
@@ -0,0 +1,19 @@
1
+ import { Either } from "../either";
2
+ export type _Try_<T> = {
3
+ isSuccess(): boolean;
4
+ isFailure(): boolean;
5
+ getOrElse(defaultValue: T): T;
6
+ orElse(alternative: _Try_<T>): _Try_<T>;
7
+ toEither(): Either<Error, T>;
8
+ };
9
+ export declare class Try<T> implements _Try_<T> {
10
+ private readonly value;
11
+ private readonly error;
12
+ private constructor();
13
+ static of<T>(f: () => T): _Try_<T>;
14
+ isSuccess(): boolean;
15
+ isFailure(): boolean;
16
+ getOrElse(defaultValue: T): T;
17
+ orElse(alternative: _Try_<T>): _Try_<T>;
18
+ toEither(): Either<Error, T>;
19
+ }
@@ -0,0 +1 @@
1
+ export { _Try_, Try } from "./Try";
@@ -0,0 +1,16 @@
1
+ import { ArrayType, _ArrayFunctor_ } from "../functor";
2
+ export type _Tuple_<T extends ArrayType> = _ArrayFunctor_<T> & {
3
+ get(index: number): T[number];
4
+ getAs<U>(index: number, f?: (item: T) => boolean): U;
5
+ map<U extends any[]>(f: (value: T) => U): _Tuple_<U>;
6
+ flatMap<U extends any[]>(f: (value: T) => _Tuple_<U>): _Tuple_<U>;
7
+ };
8
+ export declare class Tuple<T extends ArrayType> implements _Tuple_<T> {
9
+ private readonly values;
10
+ constructor(values: T);
11
+ map<U extends ArrayType>(f: (value: T) => U): Tuple<U>;
12
+ flatMap<U extends ArrayType>(f: (value: T) => Tuple<U>): Tuple<U>;
13
+ get(index: number): T[number];
14
+ getAs<U>(index: number, f?: (item: T) => boolean): U;
15
+ toArray(): T;
16
+ }
@@ -0,0 +1 @@
1
+ export { Tuple, _Tuple_ } from "./Tuple";
@@ -0,0 +1,3 @@
1
+ import { ParseError } from "../error/ParseError";
2
+ import { Either } from "../either";
3
+ export declare const parseNumber: (input: string) => Either<ParseError, number>;
@@ -0,0 +1 @@
1
+ export declare const isIterable: <T>(value: any) => value is Iterable<T>;
package/package.json CHANGED
@@ -1,28 +1,28 @@
1
1
  {
2
2
  "name": "functype",
3
- "version": "0.4.0",
3
+ "version": "0.4.1",
4
4
  "description": "A smallish functional library for TypeScript",
5
5
  "author": "jordan.burke@gmail.com",
6
6
  "license": "MIT",
7
- "url": "https://github.com/jordanburke/TypeScript/tree/main/functype",
7
+ "url": "https://github.com/jordanburke/functype",
8
8
  "devDependencies": {
9
- "@types/node": "^20.12.8",
9
+ "@types/node": "^20.14.15",
10
10
  "@typescript-eslint/eslint-plugin": "^7.5.0",
11
11
  "@typescript-eslint/parser": "^7.5.0",
12
12
  "@types/jest": "29.5.12",
13
13
  "cross-env": "^7.0.3",
14
- "eslint": "^8.57.0",
14
+ "eslint": "^9.9.0",
15
15
  "eslint-config-prettier": "^9.1.0",
16
16
  "eslint-plugin-import": "^2.29.1",
17
- "eslint-plugin-prettier": "^5.1.3",
18
- "eslint-plugin-simple-import-sort": "^12.0.0",
19
- "jest": "29.7.0",
20
- "prettier": "^3.2.5",
21
- "rimraf": "^5.0.5",
22
- "tsup": "^8.0.2",
23
- "ts-jest": "^29.1.2",
17
+ "eslint-plugin-prettier": "^5.2.1",
18
+ "eslint-plugin-simple-import-sort": "^12.1.1",
19
+ "jest": "^29.7.0",
20
+ "prettier": "^3.3.3",
21
+ "rimraf": "^6.0.1",
22
+ "tsup": "^8.2.4",
23
+ "ts-jest": "^29.2.4",
24
24
  "ts-node": "^10.9.2",
25
- "typescript": "^5.4.5"
25
+ "typescript": "^5.5.4"
26
26
  },
27
27
  "main": "./dist/index.js",
28
28
  "module": "./dist/index.mjs",
@@ -1 +0,0 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkV5UFW2E4js = require('./chunk-V5UFW2E4.js');var _chunk5VTXJIR3js = require('./chunk-5VTXJIR3.js');var _chunkCPB6NX2Sjs = require('./chunk-CPB6NX2S.js');var _chunkLO5XBCIYjs = require('./chunk-LO5XBCIY.js');var _chunkD22QKJZOjs = require('./chunk-D22QKJZO.js');var i=class r{constructor(e){_chunkD22QKJZOjs.a.call(void 0, this,"values");this.values=new (0, _chunk5VTXJIR3js.a)(e)}get entries(){return Array.from(this.values.entries()).map(([e,t])=>new (0, _chunkV5UFW2E4js.a)([e,t]))}add(e){return new r(this.values.set(e[0],e[1]).entries())}remove(e){let t=new r([...this.values.entries()]);return t.values.delete(e[0])?t:this}contains(e){return this.values.get(e[0])===e[1]}get size(){return this.values.size}map(e){return new r(Array.from(this.values.entries()).map(t=>[t[0],e(t[1])]))}flatMap(e){let t=[];for(let[n,V]of this.values.entries()){let l=e(V);if(l instanceof r)for(let[f,m]of l.values.entries())t.push([f,m])}return new r(t)}reduce(e){return new (0, _chunkLO5XBCIYjs.f)(this.entries).reduce(e)}reduceRight(e){return new (0, _chunkLO5XBCIYjs.f)(this.entries).reduceRight(e)}foldLeft(e){let t=new (0, _chunkLO5XBCIYjs.f)(this.entries);return n=>t.foldLeft(e)(n)}foldRight(e){let t=new (0, _chunkLO5XBCIYjs.f)(this.entries);return n=>t.foldRight(e)(n)}get(e){return _chunkLO5XBCIYjs.c.call(void 0, this.values.get(e))}getOrElse(e,t){return _chunkLO5XBCIYjs.c.call(void 0, this.values.get(e)).getOrElse(t)}get isEmpty(){return this.values.size===0}orElse(e,t){let n=_chunkLO5XBCIYjs.c.call(void 0, this.values.get(e));return t}toList(){return new (0, _chunkCPB6NX2Sjs.b)(this.entries)}toSet(){return new (0, _chunkCPB6NX2Sjs.a)(this.entries)}toString(){return`Map(${this.entries.toString()})`}},U=new i([["a",1],["b",2],["c",3]]);exports.a = i;
@@ -1 +0,0 @@
1
- import{a as K}from"./chunk-2XH6TPQK.mjs";import{a as _}from"./chunk-377WQNCB.mjs";import{a as u,b as o}from"./chunk-UVR6IELR.mjs";import{c as a,f as s}from"./chunk-WMSIRQ3W.mjs";import{a as p}from"./chunk-U37JTC3U.mjs";var i=class r{constructor(e){p(this,"values");this.values=new _(e)}get entries(){return Array.from(this.values.entries()).map(([e,t])=>new K([e,t]))}add(e){return new r(this.values.set(e[0],e[1]).entries())}remove(e){let t=new r([...this.values.entries()]);return t.values.delete(e[0])?t:this}contains(e){return this.values.get(e[0])===e[1]}get size(){return this.values.size}map(e){return new r(Array.from(this.values.entries()).map(t=>[t[0],e(t[1])]))}flatMap(e){let t=[];for(let[n,V]of this.values.entries()){let l=e(V);if(l instanceof r)for(let[f,m]of l.values.entries())t.push([f,m])}return new r(t)}reduce(e){return new s(this.entries).reduce(e)}reduceRight(e){return new s(this.entries).reduceRight(e)}foldLeft(e){let t=new s(this.entries);return n=>t.foldLeft(e)(n)}foldRight(e){let t=new s(this.entries);return n=>t.foldRight(e)(n)}get(e){return a(this.values.get(e))}getOrElse(e,t){return a(this.values.get(e)).getOrElse(t)}get isEmpty(){return this.values.size===0}orElse(e,t){let n=a(this.values.get(e));return t}toList(){return new o(this.entries)}toSet(){return new u(this.entries)}toString(){return`Map(${this.entries.toString()})`}},U=new i([["a",1],["b",2],["c",3]]);export{i as a};
@@ -1 +0,0 @@
1
- import{a as e,b as r}from"./chunk-S5YAJ7CP.mjs";var o=t=>new r(t),i=t=>new e(t);export{o as a,i as b};
@@ -1 +0,0 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkCPB6NX2Sjs = require('./chunk-CPB6NX2S.js');var _chunkLO5XBCIYjs = require('./chunk-LO5XBCIY.js');var u=class e{constructor(t){this.value=t}isLeft(){return!1}isRight(){return!0}map(t){return new e(t(this.value))}flatMap(t){return t(this.value)}toOption(){return _chunkLO5XBCIYjs.d.call(void 0, this.value)}toList(){return new (0, _chunkCPB6NX2Sjs.b)([this.value])}},n= exports.b =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)}toOption(){return _chunkLO5XBCIYjs.e.call(void 0, )}toList(){return new _chunkCPB6NX2Sjs.b}};exports.a = u; exports.b = n;
File without changes
@@ -1 +0,0 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkHF33BEHOjs = require('./chunk-HF33BEHO.js');var o=t=>new (0, _chunkHF33BEHOjs.b)(t),i= exports.b =t=>new (0, _chunkHF33BEHOjs.a)(t);exports.a = o; exports.b = i;
@@ -1 +0,0 @@
1
- "use strict";