@lsby/ts-fp-data 0.2.3 → 0.2.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -28,6 +28,12 @@ module.exports = __toCommonJS(either_exports);
28
28
 
29
29
  // src/data/maybe.ts
30
30
  var Maybe = class {
31
+ static nothing() {
32
+ return new Nothing();
33
+ }
34
+ static just(a) {
35
+ return new Just(a);
36
+ }
31
37
  static pure(a) {
32
38
  return new Just(a);
33
39
  }
@@ -100,6 +106,12 @@ var Nothing = class _Nothing extends Maybe {
100
106
 
101
107
  // src/data/either.ts
102
108
  var Either = class _Either {
109
+ static left(a) {
110
+ return new Left(a);
111
+ }
112
+ static right(a) {
113
+ return new Right(a);
114
+ }
103
115
  static pure(a) {
104
116
  return new Right(a);
105
117
  }
@@ -158,6 +170,9 @@ var Left = class _Left extends Either {
158
170
  try() {
159
171
  throw this.\u503C;
160
172
  }
173
+ tryAndWrap() {
174
+ throw new Error(String(this.\u503C));
175
+ }
161
176
  };
162
177
  var Right = class _Right extends Either {
163
178
  constructor(\u503C) {
@@ -206,6 +221,9 @@ var Right = class _Right extends Either {
206
221
  try() {
207
222
  return this.\u503C;
208
223
  }
224
+ tryAndWrap() {
225
+ return this.\u503C;
226
+ }
209
227
  };
210
228
  // Annotate the CommonJS export names for ESM import in node:
211
229
  0 && (module.exports = {
@@ -5,6 +5,8 @@ type 任意Either = Either<any, any>;
5
5
  type 计算右值们<A> = A extends [] ? [] : A extends [infer x, ...infer xs] ? x extends Either<unknown, infer c> ? [c, ...计算右值们<xs>] : never : never;
6
6
  type 计算左值们<A> = A extends [] ? [] : A extends [infer x, ...infer xs] ? x extends Either<infer c, unknown> ? [c, ...计算左值们<xs>] : never : never;
7
7
  declare abstract class Either<L, R> {
8
+ static left<L, R>(a: L): Either<L, R>;
9
+ static right<L, R>(a: R): Either<L, R>;
8
10
  static pure<L, R>(a: R): Either<L, R>;
9
11
  static lift<B, Arr extends 任意Either[]>(arr: [...Arr], f: (a: 计算右值们<Arr>) => B): Either<_____<计算左值们<Arr>>, B>;
10
12
  abstract map<B>(_f: (a: R) => B): Either<L, B>;
@@ -20,6 +22,7 @@ declare abstract class Either<L, R> {
20
22
  abstract mplus(a: Either<L, R>): Either<L, R>;
21
23
  abstract toMaybe(): Maybe<R>;
22
24
  abstract try(): R;
25
+ abstract tryAndWrap(): R;
23
26
  }
24
27
  declare class Left<L, R> extends Either<L, R> {
25
28
  private 值;
@@ -38,6 +41,7 @@ declare class Left<L, R> extends Either<L, R> {
38
41
  mplus(a: Either<L, R>): Either<L, R>;
39
42
  toMaybe(): Maybe<R>;
40
43
  try(): R;
44
+ tryAndWrap(): R;
41
45
  }
42
46
  declare class Right<L, R> extends Either<L, R> {
43
47
  private 值;
@@ -56,6 +60,7 @@ declare class Right<L, R> extends Either<L, R> {
56
60
  mplus(_a: Either<L, R>): Either<L, R>;
57
61
  toMaybe(): Maybe<R>;
58
62
  try(): R;
63
+ tryAndWrap(): R;
59
64
  }
60
65
 
61
66
  export { Either, Left, Right, type 任意Either, type 计算右值们, type 计算左值们 };
@@ -26,6 +26,12 @@ __export(maybe_exports, {
26
26
  });
27
27
  module.exports = __toCommonJS(maybe_exports);
28
28
  var Maybe = class {
29
+ static nothing() {
30
+ return new Nothing();
31
+ }
32
+ static just(a) {
33
+ return new Just(a);
34
+ }
29
35
  static pure(a) {
30
36
  return new Just(a);
31
37
  }
@@ -1,4 +1,6 @@
1
1
  declare abstract class Maybe<A> {
2
+ static nothing<A>(): Maybe<A>;
3
+ static just<A>(a: A): Maybe<A>;
2
4
  static pure<A>(a: A): Maybe<A>;
3
5
  abstract map<B>(f: (a: A) => B): Maybe<B>;
4
6
  abstract bind<B>(f: (a: A) => Maybe<B>): Maybe<B>;
@@ -27,6 +27,12 @@ module.exports = __toCommonJS(task_exports);
27
27
 
28
28
  // src/data/maybe.ts
29
29
  var Maybe = class {
30
+ static nothing() {
31
+ return new Nothing();
32
+ }
33
+ static just(a) {
34
+ return new Just(a);
35
+ }
30
36
  static pure(a) {
31
37
  return new Just(a);
32
38
  }
@@ -99,6 +105,12 @@ var Nothing = class _Nothing extends Maybe {
99
105
 
100
106
  // src/data/either.ts
101
107
  var Either = class _Either {
108
+ static left(a) {
109
+ return new Left(a);
110
+ }
111
+ static right(a) {
112
+ return new Right(a);
113
+ }
102
114
  static pure(a) {
103
115
  return new Right(a);
104
116
  }
@@ -157,6 +169,9 @@ var Left = class _Left extends Either {
157
169
  try() {
158
170
  throw this.\u503C;
159
171
  }
172
+ tryAndWrap() {
173
+ throw new Error(String(this.\u503C));
174
+ }
160
175
  };
161
176
  var Right = class _Right extends Either {
162
177
  constructor(\u503C) {
@@ -205,6 +220,9 @@ var Right = class _Right extends Either {
205
220
  try() {
206
221
  return this.\u503C;
207
222
  }
223
+ tryAndWrap() {
224
+ return this.\u503C;
225
+ }
208
226
  };
209
227
 
210
228
  // src/data/task.ts
@@ -34,6 +34,12 @@ module.exports = __toCommonJS(seq_exports);
34
34
 
35
35
  // src/data/maybe.ts
36
36
  var Maybe = class {
37
+ static nothing() {
38
+ return new Nothing();
39
+ }
40
+ static just(a) {
41
+ return new Just(a);
42
+ }
37
43
  static pure(a) {
38
44
  return new Just(a);
39
45
  }
@@ -106,6 +112,12 @@ var Nothing = class _Nothing extends Maybe {
106
112
 
107
113
  // src/data/either.ts
108
114
  var Either = class _Either {
115
+ static left(a) {
116
+ return new Left(a);
117
+ }
118
+ static right(a) {
119
+ return new Right(a);
120
+ }
109
121
  static pure(a) {
110
122
  return new Right(a);
111
123
  }
@@ -164,6 +176,9 @@ var Left = class _Left extends Either {
164
176
  try() {
165
177
  throw this.\u503C;
166
178
  }
179
+ tryAndWrap() {
180
+ throw new Error(String(this.\u503C));
181
+ }
167
182
  };
168
183
  var Right = class _Right extends Either {
169
184
  constructor(\u503C) {
@@ -212,6 +227,9 @@ var Right = class _Right extends Either {
212
227
  try() {
213
228
  return this.\u503C;
214
229
  }
230
+ tryAndWrap() {
231
+ return this.\u503C;
232
+ }
215
233
  };
216
234
 
217
235
  // src/data/task.ts
@@ -45,6 +45,12 @@ module.exports = __toCommonJS(src_exports);
45
45
 
46
46
  // src/data/maybe.ts
47
47
  var Maybe = class {
48
+ static nothing() {
49
+ return new Nothing();
50
+ }
51
+ static just(a) {
52
+ return new Just(a);
53
+ }
48
54
  static pure(a) {
49
55
  return new Just(a);
50
56
  }
@@ -117,6 +123,12 @@ var Nothing = class _Nothing extends Maybe {
117
123
 
118
124
  // src/data/either.ts
119
125
  var Either = class _Either {
126
+ static left(a) {
127
+ return new Left(a);
128
+ }
129
+ static right(a) {
130
+ return new Right(a);
131
+ }
120
132
  static pure(a) {
121
133
  return new Right(a);
122
134
  }
@@ -175,6 +187,9 @@ var Left = class _Left extends Either {
175
187
  try() {
176
188
  throw this.\u503C;
177
189
  }
190
+ tryAndWrap() {
191
+ throw new Error(String(this.\u503C));
192
+ }
178
193
  };
179
194
  var Right = class _Right extends Either {
180
195
  constructor(\u503C) {
@@ -223,6 +238,9 @@ var Right = class _Right extends Either {
223
238
  try() {
224
239
  return this.\u503C;
225
240
  }
241
+ tryAndWrap() {
242
+ return this.\u503C;
243
+ }
226
244
  };
227
245
 
228
246
  // src/data/lazy.ts
@@ -1,10 +1,16 @@
1
1
  import {
2
2
  Just,
3
3
  Nothing
4
- } from "./chunk-NXA54GUD.js";
4
+ } from "./chunk-CE6K56ZX.js";
5
5
 
6
6
  // src/data/either.ts
7
7
  var Either = class _Either {
8
+ static left(a) {
9
+ return new Left(a);
10
+ }
11
+ static right(a) {
12
+ return new Right(a);
13
+ }
8
14
  static pure(a) {
9
15
  return new Right(a);
10
16
  }
@@ -63,6 +69,9 @@ var Left = class _Left extends Either {
63
69
  try() {
64
70
  throw this.\u503C;
65
71
  }
72
+ tryAndWrap() {
73
+ throw new Error(String(this.\u503C));
74
+ }
66
75
  };
67
76
  var Right = class _Right extends Either {
68
77
  constructor(\u503C) {
@@ -111,6 +120,9 @@ var Right = class _Right extends Either {
111
120
  try() {
112
121
  return this.\u503C;
113
122
  }
123
+ tryAndWrap() {
124
+ return this.\u503C;
125
+ }
114
126
  };
115
127
 
116
128
  export {
@@ -1,5 +1,11 @@
1
1
  // src/data/maybe.ts
2
2
  var Maybe = class {
3
+ static nothing() {
4
+ return new Nothing();
5
+ }
6
+ static just(a) {
7
+ return new Just(a);
8
+ }
3
9
  static pure(a) {
4
10
  return new Just(a);
5
11
  }
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  Left,
3
3
  Right
4
- } from "./chunk-CMETOIMZ.js";
4
+ } from "./chunk-2TQ3IMR2.js";
5
5
 
6
6
  // src/data/task.ts
7
7
  var TaskDo = class _TaskDo {
@@ -1,14 +1,14 @@
1
1
  import {
2
2
  Task
3
- } from "./chunk-EFQMZNIN.js";
3
+ } from "./chunk-UBCNNCCC.js";
4
4
  import {
5
5
  Left,
6
6
  Right
7
- } from "./chunk-CMETOIMZ.js";
7
+ } from "./chunk-2TQ3IMR2.js";
8
8
  import {
9
9
  Just,
10
10
  Nothing
11
- } from "./chunk-NXA54GUD.js";
11
+ } from "./chunk-CE6K56ZX.js";
12
12
 
13
13
  // src/func/seq.ts
14
14
  function seqArrayTask(a) {
@@ -5,6 +5,8 @@ type 任意Either = Either<any, any>;
5
5
  type 计算右值们<A> = A extends [] ? [] : A extends [infer x, ...infer xs] ? x extends Either<unknown, infer c> ? [c, ...计算右值们<xs>] : never : never;
6
6
  type 计算左值们<A> = A extends [] ? [] : A extends [infer x, ...infer xs] ? x extends Either<infer c, unknown> ? [c, ...计算左值们<xs>] : never : never;
7
7
  declare abstract class Either<L, R> {
8
+ static left<L, R>(a: L): Either<L, R>;
9
+ static right<L, R>(a: R): Either<L, R>;
8
10
  static pure<L, R>(a: R): Either<L, R>;
9
11
  static lift<B, Arr extends 任意Either[]>(arr: [...Arr], f: (a: 计算右值们<Arr>) => B): Either<_____<计算左值们<Arr>>, B>;
10
12
  abstract map<B>(_f: (a: R) => B): Either<L, B>;
@@ -20,6 +22,7 @@ declare abstract class Either<L, R> {
20
22
  abstract mplus(a: Either<L, R>): Either<L, R>;
21
23
  abstract toMaybe(): Maybe<R>;
22
24
  abstract try(): R;
25
+ abstract tryAndWrap(): R;
23
26
  }
24
27
  declare class Left<L, R> extends Either<L, R> {
25
28
  private 值;
@@ -38,6 +41,7 @@ declare class Left<L, R> extends Either<L, R> {
38
41
  mplus(a: Either<L, R>): Either<L, R>;
39
42
  toMaybe(): Maybe<R>;
40
43
  try(): R;
44
+ tryAndWrap(): R;
41
45
  }
42
46
  declare class Right<L, R> extends Either<L, R> {
43
47
  private 值;
@@ -56,6 +60,7 @@ declare class Right<L, R> extends Either<L, R> {
56
60
  mplus(_a: Either<L, R>): Either<L, R>;
57
61
  toMaybe(): Maybe<R>;
58
62
  try(): R;
63
+ tryAndWrap(): R;
59
64
  }
60
65
 
61
66
  export { Either, Left, Right, type 任意Either, type 计算右值们, type 计算左值们 };
@@ -2,8 +2,8 @@ import {
2
2
  Either,
3
3
  Left,
4
4
  Right
5
- } from "../chunk-CMETOIMZ.js";
6
- import "../chunk-NXA54GUD.js";
5
+ } from "../chunk-2TQ3IMR2.js";
6
+ import "../chunk-CE6K56ZX.js";
7
7
  export {
8
8
  Either,
9
9
  Left,
@@ -1,4 +1,6 @@
1
1
  declare abstract class Maybe<A> {
2
+ static nothing<A>(): Maybe<A>;
3
+ static just<A>(a: A): Maybe<A>;
2
4
  static pure<A>(a: A): Maybe<A>;
3
5
  abstract map<B>(f: (a: A) => B): Maybe<B>;
4
6
  abstract bind<B>(f: (a: A) => Maybe<B>): Maybe<B>;
@@ -2,7 +2,7 @@ import {
2
2
  Just,
3
3
  Maybe,
4
4
  Nothing
5
- } from "../chunk-NXA54GUD.js";
5
+ } from "../chunk-CE6K56ZX.js";
6
6
  export {
7
7
  Just,
8
8
  Maybe,
@@ -1,9 +1,9 @@
1
1
  import {
2
2
  Task,
3
3
  TaskDo
4
- } from "../chunk-EFQMZNIN.js";
5
- import "../chunk-CMETOIMZ.js";
6
- import "../chunk-NXA54GUD.js";
4
+ } from "../chunk-UBCNNCCC.js";
5
+ import "../chunk-2TQ3IMR2.js";
6
+ import "../chunk-CE6K56ZX.js";
7
7
  export {
8
8
  Task,
9
9
  TaskDo
@@ -8,10 +8,10 @@ import {
8
8
  seqEitherTask,
9
9
  seqMaybeArray,
10
10
  seqMaybeTask
11
- } from "../chunk-6EMV6TLL.js";
12
- import "../chunk-EFQMZNIN.js";
13
- import "../chunk-CMETOIMZ.js";
14
- import "../chunk-NXA54GUD.js";
11
+ } from "../chunk-UFP2YX5Y.js";
12
+ import "../chunk-UBCNNCCC.js";
13
+ import "../chunk-2TQ3IMR2.js";
14
+ import "../chunk-CE6K56ZX.js";
15
15
  export {
16
16
  seqArrayEitherCollectRight,
17
17
  seqArrayEitherFirstLeft,
package/dist/esm/index.js CHANGED
@@ -13,21 +13,21 @@ import {
13
13
  seqEitherTask,
14
14
  seqMaybeArray,
15
15
  seqMaybeTask
16
- } from "./chunk-6EMV6TLL.js";
16
+ } from "./chunk-UFP2YX5Y.js";
17
17
  import {
18
18
  Task,
19
19
  TaskDo
20
- } from "./chunk-EFQMZNIN.js";
20
+ } from "./chunk-UBCNNCCC.js";
21
21
  import {
22
22
  Either,
23
23
  Left,
24
24
  Right
25
- } from "./chunk-CMETOIMZ.js";
25
+ } from "./chunk-2TQ3IMR2.js";
26
26
  import {
27
27
  Just,
28
28
  Maybe,
29
29
  Nothing
30
- } from "./chunk-NXA54GUD.js";
30
+ } from "./chunk-CE6K56ZX.js";
31
31
  export {
32
32
  Either,
33
33
  Just,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lsby/ts-fp-data",
3
- "version": "0.2.3",
3
+ "version": "0.2.5",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  "require": "./dist/cjs/index.cjs",