@nunofyobiz/effect-extras 0.0.2 → 2.0.0

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.
package/dist/index.js CHANGED
@@ -23,7 +23,7 @@ __export(ArrayX_exports, {
23
23
  slice: () => slice,
24
24
  takeFirstWhere: () => takeFirstWhere2,
25
25
  takeLastWhere: () => takeLastWhere2,
26
- zipWithThese: () => zipWithThese
26
+ zipWithWarnings: () => zipWithWarnings
27
27
  });
28
28
 
29
29
  // src/RecordX/RecordX.ts
@@ -93,195 +93,201 @@ var collectBy = dual(
93
93
  )
94
94
  );
95
95
 
96
- // src/These/These.ts
97
- var These_exports = {};
98
- __export(These_exports, {
99
- LeftAndRight: () => LeftAndRight,
100
- LeftOnly: () => LeftOnly,
101
- RightOnly: () => RightOnly,
102
- WithLeft: () => WithLeft,
103
- WithRight: () => WithRight,
104
- flatMapLeft: () => flatMapLeft,
105
- flatMapLeftEffect: () => flatMapLeftEffect,
106
- flatMapRight: () => flatMapRight,
107
- flatMapRightEffect: () => flatMapRightEffect,
96
+ // src/WarnResult/WarnResult.ts
97
+ var WarnResult_exports = {};
98
+ __export(WarnResult_exports, {
99
+ SuccessOnly: () => SuccessOnly,
100
+ SuccessWithWarnings: () => SuccessWithWarnings,
101
+ WarningsOnly: () => WarningsOnly,
102
+ WithSuccess: () => WithSuccess,
103
+ WithWarnings: () => WithWarnings,
104
+ flatMapSuccess: () => flatMapSuccess,
105
+ flatMapSuccessEffect: () => flatMapSuccessEffect,
106
+ flatMapWarnings: () => flatMapWarnings,
107
+ flatMapWarningsEffect: () => flatMapWarningsEffect,
108
108
  fromNullables: () => fromNullables,
109
109
  is: () => is,
110
- leftOption: () => leftOption,
111
- leftOrElse: () => leftOrElse,
112
- leftOrUndefined: () => leftOrUndefined,
113
110
  mapBoth: () => mapBoth,
114
111
  mapBothEffect: () => mapBothEffect,
115
- mapLeft: () => mapLeft,
116
- mapLeftEffect: () => mapLeftEffect,
117
- mapRight: () => mapRight,
118
- mapRightEffect: () => mapRightEffect,
112
+ mapSuccess: () => mapSuccess,
113
+ mapSuccessEffect: () => mapSuccessEffect,
114
+ mapWarnings: () => mapWarnings,
115
+ mapWarningsEffect: () => mapWarningsEffect,
119
116
  match: () => match,
120
- matchLeft: () => matchLeft,
121
- matchRight: () => matchRight,
117
+ matchSuccess: () => matchSuccess,
118
+ matchWarnings: () => matchWarnings,
122
119
  optionFromNullables: () => optionFromNullables,
123
120
  orElse: () => orElse,
124
121
  orUndefined: () => orUndefined,
125
- rightOption: () => rightOption,
126
- rightOrElse: () => rightOrElse,
127
- rightOrUndefined: () => rightOrUndefined
122
+ successOption: () => successOption,
123
+ successOrElse: () => successOrElse,
124
+ successOrUndefined: () => successOrUndefined,
125
+ warningsOption: () => warningsOption,
126
+ warningsOrElse: () => warningsOrElse,
127
+ warningsOrUndefined: () => warningsOrUndefined
128
128
  });
129
129
  var taggedEnum = Data.taggedEnum();
130
- var LeftOnly = taggedEnum.LeftOnly;
131
- var RightOnly = taggedEnum.RightOnly;
132
- var LeftAndRight = taggedEnum.LeftAndRight;
130
+ var WarningsOnly = taggedEnum.WarningsOnly;
131
+ var SuccessOnly = taggedEnum.SuccessOnly;
132
+ var SuccessWithWarnings = taggedEnum.SuccessWithWarnings;
133
133
  var is = taggedEnum.$is;
134
134
  var match = taggedEnum.$match;
135
- var WithLeft = ({
136
- left,
137
- right
138
- }) => Predicate.isNotNullish(right) ? LeftAndRight({ left, right }) : LeftOnly({ left });
139
- var WithRight = ({
140
- left,
141
- right
142
- }) => Predicate.isNotNullish(left) ? LeftAndRight({ left, right }) : RightOnly({ right });
135
+ var WithWarnings = ({
136
+ warnings,
137
+ success
138
+ }) => Predicate.isNotNullish(success) ? SuccessWithWarnings({ warnings, success }) : WarningsOnly({ warnings });
139
+ var WithSuccess = ({
140
+ warnings,
141
+ success
142
+ }) => Predicate.isNotNullish(warnings) ? SuccessWithWarnings({ warnings, success }) : SuccessOnly({ success });
143
143
  var optionFromNullables = ({
144
- left,
145
- right
144
+ warnings,
145
+ success
146
146
  }) => {
147
- if (Predicate.isNotNullish(left) && Predicate.isNotNullish(right)) {
148
- return Option.some(LeftAndRight({ left, right }));
147
+ if (Predicate.isNotNullish(warnings) && Predicate.isNotNullish(success)) {
148
+ return Option.some(SuccessWithWarnings({ warnings, success }));
149
149
  }
150
- if (Predicate.isNotNullish(left)) {
151
- return Option.some(LeftOnly({ left }));
150
+ if (Predicate.isNotNullish(warnings)) {
151
+ return Option.some(WarningsOnly({ warnings }));
152
152
  }
153
- if (Predicate.isNotNullish(right)) {
154
- return Option.some(RightOnly({ right }));
153
+ if (Predicate.isNotNullish(success)) {
154
+ return Option.some(SuccessOnly({ success }));
155
155
  }
156
156
  return Option.none();
157
157
  };
158
158
  var fromNullables = ({
159
- left,
160
- right,
159
+ warnings,
160
+ success,
161
161
  orElse: orElse2 = () => {
162
- throw new Error("Both left and right are nullable");
162
+ throw new Error("Both warnings and success are nullish");
163
163
  }
164
- }) => pipe(optionFromNullables({ left, right }), Option.getOrElse(orElse2));
165
- var matchLeft = ({
166
- Left,
167
- RightOnly: RightOnly2
168
- }) => (these) => pipe(
169
- these,
164
+ }) => pipe(optionFromNullables({ warnings, success }), Option.getOrElse(orElse2));
165
+ var matchWarnings = ({
166
+ Warnings,
167
+ SuccessOnly: SuccessOnly2
168
+ }) => (warnResult) => pipe(
169
+ warnResult,
170
170
  match({
171
- LeftOnly: ({ left }) => Left(left),
172
- RightOnly: ({ right }) => RightOnly2(right),
173
- LeftAndRight: ({ left }) => Left(left)
171
+ WarningsOnly: ({ warnings }) => Warnings(warnings),
172
+ SuccessOnly: ({ success }) => SuccessOnly2(success),
173
+ SuccessWithWarnings: ({ warnings }) => Warnings(warnings)
174
174
  }),
175
175
  // Make Typescript happy
176
176
  (a) => a
177
177
  );
178
- var matchRight = ({
179
- LeftOnly: LeftOnly2,
180
- Right
181
- }) => (these) => pipe(
182
- these,
178
+ var matchSuccess = ({
179
+ WarningsOnly: WarningsOnly2,
180
+ Success
181
+ }) => (warnResult) => pipe(
182
+ warnResult,
183
183
  match({
184
- LeftOnly: ({ left }) => LeftOnly2(left),
185
- RightOnly: ({ right }) => Right(right),
186
- LeftAndRight: ({ right }) => Right(right)
184
+ WarningsOnly: ({ warnings }) => WarningsOnly2(warnings),
185
+ SuccessOnly: ({ success }) => Success(success),
186
+ SuccessWithWarnings: ({ success }) => Success(success)
187
187
  }),
188
188
  // Make Typescript happy
189
189
  (a) => a
190
190
  );
191
191
  var orElse = ({
192
- orElseLeft,
193
- orElseRight
192
+ orElseWarnings,
193
+ orElseSuccess
194
194
  }) => match({
195
- LeftOnly: ({ left }) => LeftAndRight({ left, right: orElseRight() }),
196
- RightOnly: ({ right }) => LeftAndRight({ left: orElseLeft(), right }),
197
- LeftAndRight: ({ left, right }) => LeftAndRight({ left, right })
195
+ WarningsOnly: ({ warnings }) => SuccessWithWarnings({ warnings, success: orElseSuccess() }),
196
+ SuccessOnly: ({ success }) => SuccessWithWarnings({ warnings: orElseWarnings(), success }),
197
+ SuccessWithWarnings: ({ warnings, success }) => SuccessWithWarnings({ warnings, success })
198
198
  });
199
199
  var orUndefined = orElse({
200
- orElseLeft: () => void 0,
201
- orElseRight: () => void 0
200
+ orElseWarnings: () => void 0,
201
+ orElseSuccess: () => void 0
202
202
  });
203
- var leftOrElse = (orElseReturn) => (these) => pipe(
204
- these,
203
+ var warningsOrElse = (orElseReturn) => (warnResult) => pipe(
204
+ warnResult,
205
205
  orElse({
206
- orElseLeft: orElseReturn,
207
- orElseRight: constUndefined
206
+ orElseWarnings: orElseReturn,
207
+ orElseSuccess: constUndefined
208
208
  }),
209
- Struct.get("left")
209
+ Struct.get("warnings")
210
210
  );
211
- var leftOrUndefined = leftOrElse(() => void 0);
212
- var rightOrElse = (orElseReturn) => (these) => pipe(
213
- these,
211
+ var warningsOrUndefined = warningsOrElse(() => void 0);
212
+ var successOrElse = (orElseReturn) => (warnResult) => pipe(
213
+ warnResult,
214
214
  orElse({
215
- orElseLeft: constUndefined,
216
- orElseRight: orElseReturn
215
+ orElseWarnings: constUndefined,
216
+ orElseSuccess: orElseReturn
217
217
  }),
218
- Struct.get("right")
219
- );
220
- var rightOrUndefined = rightOrElse(() => void 0);
221
- var rightOption = (these) => pipe(
222
- these,
223
- matchRight({
224
- LeftOnly: () => Option.none(),
225
- Right: Option.some
218
+ Struct.get("success")
219
+ );
220
+ var successOrUndefined = successOrElse(() => void 0);
221
+ var successOption = (warnResult) => pipe(
222
+ warnResult,
223
+ matchSuccess({
224
+ WarningsOnly: () => Option.none(),
225
+ Success: Option.some
226
226
  })
227
227
  );
228
- var leftOption = (these) => pipe(
229
- these,
230
- matchLeft({
231
- Left: Option.some,
232
- RightOnly: () => Option.none()
228
+ var warningsOption = (warnResult) => pipe(
229
+ warnResult,
230
+ matchWarnings({
231
+ Warnings: Option.some,
232
+ SuccessOnly: () => Option.none()
233
233
  })
234
234
  );
235
235
  var mapBoth = ({
236
- mapLeft: mapLeft2,
237
- mapRight: mapRight2
236
+ mapWarnings: mapWarnings2,
237
+ mapSuccess: mapSuccess2
238
238
  }) => match({
239
- LeftOnly: ({ left }) => LeftOnly({ left: mapLeft2(left) }),
240
- RightOnly: ({ right }) => RightOnly({ right: mapRight2(right) }),
241
- LeftAndRight: ({ left, right }) => LeftAndRight({ left: mapLeft2(left), right: mapRight2(right) })
239
+ WarningsOnly: ({ warnings }) => WarningsOnly({ warnings: mapWarnings2(warnings) }),
240
+ SuccessOnly: ({ success }) => SuccessOnly({ success: mapSuccess2(success) }),
241
+ SuccessWithWarnings: ({ warnings, success }) => SuccessWithWarnings({
242
+ warnings: mapWarnings2(warnings),
243
+ success: mapSuccess2(success)
244
+ })
242
245
  });
243
246
  var mapBothEffect = ({
244
- mapLeft: mapLeft2,
245
- mapRight: mapRight2
247
+ mapWarnings: mapWarnings2,
248
+ mapSuccess: mapSuccess2
246
249
  }) => match({
247
- LeftOnly: ({ left }) => pipe(
248
- mapLeft2(left),
249
- Effect.map((left2) => LeftOnly({ left: left2 }))
250
+ WarningsOnly: ({ warnings }) => pipe(
251
+ mapWarnings2(warnings),
252
+ Effect.map((warnings2) => WarningsOnly({ warnings: warnings2 }))
250
253
  ),
251
- RightOnly: ({ right }) => pipe(
252
- mapRight2(right),
253
- Effect.map((right2) => RightOnly({ right: right2 }))
254
+ SuccessOnly: ({ success }) => pipe(
255
+ mapSuccess2(success),
256
+ Effect.map((success2) => SuccessOnly({ success: success2 }))
254
257
  ),
255
- LeftAndRight: ({ left, right }) => pipe(
256
- Effect.all({ left: mapLeft2(left), right: mapRight2(right) }),
258
+ SuccessWithWarnings: ({ warnings, success }) => pipe(
259
+ Effect.all({
260
+ warnings: mapWarnings2(warnings),
261
+ success: mapSuccess2(success)
262
+ }),
257
263
  Effect.map(
258
- ({ left: left2, right: right2 }) => LeftAndRight({ left: left2, right: right2 })
264
+ ({ warnings: warnings2, success: success2 }) => SuccessWithWarnings({ warnings: warnings2, success: success2 })
259
265
  )
260
266
  )
261
267
  });
262
- var mapLeft = (mapLeft2) => mapBoth({ mapLeft: mapLeft2, mapRight: identity });
263
- var flatMapLeft = (mapLeft2) => match({
264
- LeftOnly: ({ left }) => mapLeft2(left),
265
- RightOnly: ({ right }) => RightOnly({ right }),
266
- LeftAndRight: ({ left }) => mapLeft2(left)
267
- });
268
- var mapLeftEffect = (mapLeft2) => mapBothEffect({ mapLeft: mapLeft2, mapRight: Effect.succeed });
269
- var flatMapLeftEffect = (mapLeft2) => match({
270
- LeftOnly: ({ left }) => mapLeft2(left),
271
- RightOnly: ({ right }) => Effect.succeed(RightOnly({ right })),
272
- LeftAndRight: ({ left }) => mapLeft2(left)
273
- });
274
- var mapRight = (mapRight2) => mapBoth({ mapLeft: identity, mapRight: mapRight2 });
275
- var flatMapRight = (mapRight2) => match({
276
- LeftOnly: ({ left }) => LeftOnly({ left }),
277
- RightOnly: ({ right }) => mapRight2(right),
278
- LeftAndRight: ({ right }) => mapRight2(right)
279
- });
280
- var mapRightEffect = (mapRight2) => mapBothEffect({ mapLeft: Effect.succeed, mapRight: mapRight2 });
281
- var flatMapRightEffect = (mapRight2) => match({
282
- LeftOnly: ({ left }) => Effect.succeed(LeftOnly({ left })),
283
- RightOnly: ({ right }) => mapRight2(right),
284
- LeftAndRight: ({ right }) => mapRight2(right)
268
+ var mapWarnings = (mapWarnings2) => mapBoth({ mapWarnings: mapWarnings2, mapSuccess: identity });
269
+ var flatMapWarnings = (mapWarnings2) => match({
270
+ WarningsOnly: ({ warnings }) => mapWarnings2(warnings),
271
+ SuccessOnly: ({ success }) => SuccessOnly({ success }),
272
+ SuccessWithWarnings: ({ warnings }) => mapWarnings2(warnings)
273
+ });
274
+ var mapWarningsEffect = (mapWarnings2) => mapBothEffect({ mapWarnings: mapWarnings2, mapSuccess: Effect.succeed });
275
+ var flatMapWarningsEffect = (mapWarnings2) => match({
276
+ WarningsOnly: ({ warnings }) => mapWarnings2(warnings),
277
+ SuccessOnly: ({ success }) => Effect.succeed(SuccessOnly({ success })),
278
+ SuccessWithWarnings: ({ warnings }) => mapWarnings2(warnings)
279
+ });
280
+ var mapSuccess = (mapSuccess2) => mapBoth({ mapWarnings: identity, mapSuccess: mapSuccess2 });
281
+ var flatMapSuccess = (mapSuccess2) => match({
282
+ WarningsOnly: ({ warnings }) => WarningsOnly({ warnings }),
283
+ SuccessOnly: ({ success }) => mapSuccess2(success),
284
+ SuccessWithWarnings: ({ success }) => mapSuccess2(success)
285
+ });
286
+ var mapSuccessEffect = (mapSuccess2) => mapBothEffect({ mapWarnings: Effect.succeed, mapSuccess: mapSuccess2 });
287
+ var flatMapSuccessEffect = (mapSuccess2) => match({
288
+ WarningsOnly: ({ warnings }) => Effect.succeed(WarningsOnly({ warnings })),
289
+ SuccessOnly: ({ success }) => mapSuccess2(success),
290
+ SuccessWithWarnings: ({ success }) => mapSuccess2(success)
285
291
  });
286
292
 
287
293
  // src/ResultX/ResultX.ts
@@ -296,7 +302,7 @@ var slice = dual(
296
302
  3,
297
303
  (array, start, end) => array.slice(start, end)
298
304
  );
299
- var zipWithThese = dual(
305
+ var zipWithWarnings = dual(
300
306
  3,
301
307
  (array1, array2, f) => {
302
308
  const newLength = Math.max(array1.length, array2.length);
@@ -306,23 +312,23 @@ var zipWithThese = dual(
306
312
  return Array.makeBy(newLength, (index) => {
307
313
  if (index < array1.length && index < array2.length) {
308
314
  return f(
309
- These_exports.LeftAndRight({
310
- left: array1[index],
311
- right: array2[index]
315
+ WarnResult_exports.SuccessWithWarnings({
316
+ warnings: array1[index],
317
+ success: array2[index]
312
318
  })
313
319
  );
314
320
  }
315
321
  if (index < array1.length) {
316
322
  return f(
317
- These_exports.LeftOnly({
318
- left: array1[index]
323
+ WarnResult_exports.WarningsOnly({
324
+ warnings: array1[index]
319
325
  })
320
326
  );
321
327
  }
322
328
  if (index < array2.length) {
323
329
  return f(
324
- These_exports.RightOnly({
325
- right: array2[index]
330
+ WarnResult_exports.SuccessOnly({
331
+ success: array2[index]
326
332
  })
327
333
  );
328
334
  }
@@ -1001,6 +1007,6 @@ var hasNotNullableProperty = dual(
1001
1007
  (object, key) => Predicate.hasProperty(object, key) && Predicate.isNotNullish(object[key])
1002
1008
  );
1003
1009
 
1004
- export { ArrayX_exports as ArrayX, BigIntX_exports as BigIntX, BooleanX_exports as BooleanX, DurationX_exports as DurationX, EffectX_exports as EffectX, FormDataX_exports as FormDataX, MapX_exports as MapX, NonNullableX_exports as NonNullableX, NumberX_exports as NumberX, OptionX_exports as OptionX, OrderX_exports as OrderX, PredicateX_exports as PredicateX, PromiseX_exports as PromiseX, RecordX_exports as RecordX, ResultX_exports as ResultX, SchemaX_exports as SchemaX, SetX_exports as SetX, StringX_exports as StringX, StructX_exports as StructX, These_exports as These, fromNullableOrThrow as nn };
1010
+ export { ArrayX_exports as ArrayX, BigIntX_exports as BigIntX, BooleanX_exports as BooleanX, DurationX_exports as DurationX, EffectX_exports as EffectX, FormDataX_exports as FormDataX, MapX_exports as MapX, NonNullableX_exports as NonNullableX, NumberX_exports as NumberX, OptionX_exports as OptionX, OrderX_exports as OrderX, PredicateX_exports as PredicateX, PromiseX_exports as PromiseX, RecordX_exports as RecordX, ResultX_exports as ResultX, SchemaX_exports as SchemaX, SetX_exports as SetX, StringX_exports as StringX, StructX_exports as StructX, WarnResult_exports as WarnResult, fromNullableOrThrow as nn };
1005
1011
  //# sourceMappingURL=index.js.map
1006
1012
  //# sourceMappingURL=index.js.map