@zelgadis87/utils-core 5.5.0-beta.4 → 6.0.0-beta.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.
package/.rollup/index.cjs CHANGED
@@ -213,7 +213,7 @@ function throwIfNullOrUndefined(source, errorProducer = () => new Error(`Unexpec
213
213
  return ifNullOrUndefined(source, () => { throw errorProducer(); });
214
214
  }
215
215
 
216
- class Optional {
216
+ class OptionalClz {
217
217
  _present;
218
218
  _value;
219
219
  constructor(t) {
@@ -224,7 +224,6 @@ class Optional {
224
224
  getRawValue() {
225
225
  return this._value;
226
226
  }
227
- /** @deprecated[2026.04.07]: Replace with {@link getOrElseThrow} (drop-in replacement with no arguments) */
228
227
  get() {
229
228
  return this.getOrElseThrow();
230
229
  }
@@ -263,12 +262,6 @@ class Optional {
263
262
  if (this.isPresent())
264
263
  return callback(this.get());
265
264
  }
266
- ifPresentThenClear(callback) {
267
- if (this.isPresent()) {
268
- callback(this.get());
269
- this.clear();
270
- }
271
- }
272
265
  apply(callbackIfPresent, callbackIfEmpty) {
273
266
  if (this.isEmpty()) {
274
267
  return callbackIfEmpty();
@@ -285,7 +278,6 @@ class Optional {
285
278
  return newValue;
286
279
  }
287
280
  }
288
- orElse = this.orElseReturn.bind(this);
289
281
  orElseReturnNull() {
290
282
  return this.isPresent() ? this.get() : null;
291
283
  }
@@ -300,7 +292,6 @@ class Optional {
300
292
  return newValueProducer();
301
293
  }
302
294
  }
303
- orElseGet = this.orElseProduce.bind(this);
304
295
  orElseReturnAndApply(newValue) {
305
296
  if (this.isPresent()) {
306
297
  return this.get();
@@ -341,18 +332,16 @@ class Optional {
341
332
  }
342
333
  orElseReturnNullable(newValue) {
343
334
  if (this.isEmpty())
344
- return Optional.ofNullable(newValue);
335
+ return OptionalClz.ofNullable(newValue);
345
336
  return this;
346
337
  }
347
- orElseNullable = this.orElseReturnNullable.bind(this);
348
338
  orElseProduceNullable(newValueProducer) {
349
339
  if (this.isEmpty()) {
350
340
  const newValue = newValueProducer();
351
- return Optional.ofNullable(newValue);
341
+ return OptionalClz.ofNullable(newValue);
352
342
  }
353
343
  return this;
354
344
  }
355
- orElseGetNullable = this.orElseProduceNullable.bind(this);
356
345
  orElseThrow(errorProducer) {
357
346
  if (this.isEmpty())
358
347
  throw errorProducer();
@@ -364,35 +353,35 @@ class Optional {
364
353
  throw errorProducer(this.get());
365
354
  }
366
355
  mapTo(mapper) {
367
- return this.apply(() => Optional.ofNullable(mapper(this.get())), () => Optional.empty());
356
+ return this.apply(() => OptionalClz.ofNullable(mapper(this.get())), () => OptionalClz.empty());
368
357
  }
369
358
  flatMapTo(mapper) {
370
- return this.apply(() => mapper(this.get()), () => Optional.empty());
359
+ return this.apply(() => mapper(this.get()), () => OptionalClz.empty());
371
360
  }
372
361
  filter(predicate) {
373
362
  if (this.isEmpty())
374
363
  return this;
375
364
  if (predicate(this.get()))
376
365
  return this;
377
- return Optional.empty();
366
+ return OptionalClz.empty();
378
367
  }
379
368
  static empty() {
380
- return new Optional(undefined);
369
+ return new OptionalClz(undefined);
381
370
  }
382
371
  static of(t) {
383
372
  if (isNullOrUndefined(t))
384
373
  throw new ErrorCannotInstantiatePresentOptionalWithEmptyValue();
385
- return new Optional(t);
374
+ return new OptionalClz(t);
386
375
  }
387
376
  static ofNullable(t) {
388
- return new Optional(t);
377
+ return new OptionalClz(t);
389
378
  }
390
379
  static findInArray(arr, predicate) {
391
- return Optional.ofNullable(arr.find(predicate));
380
+ return OptionalClz.ofNullable(arr.find(predicate));
392
381
  }
393
382
  static findIndexInArray(arr, predicate) {
394
383
  const idx = arr.findIndex(predicate);
395
- return idx === -1 ? Optional.empty() : Optional.of(idx);
384
+ return idx === -1 ? OptionalClz.empty() : OptionalClz.of(idx);
396
385
  }
397
386
  }
398
387
  class ErrorGetEmptyOptional extends Error {
@@ -841,11 +830,11 @@ function shallowArrayEquals(a, b) {
841
830
  }
842
831
  /** @deprecated[2026.03.01]: Use {@link Optional.findInArray} instead. */
843
832
  function findInArray(arr, predicate) {
844
- return Optional.findInArray(arr, predicate);
833
+ return OptionalClz.findInArray(arr, predicate);
845
834
  }
846
835
  /** @deprecated[2026.03.01]: Use {@link Optional.findIndexInArray} instead. */
847
836
  function findIndexInArray(arr, predicate) {
848
- return Optional.findIndexInArray(arr, predicate);
837
+ return OptionalClz.findIndexInArray(arr, predicate);
849
838
  }
850
839
  function zip(ts, rs) {
851
840
  if (ts.length !== rs.length)
@@ -866,8 +855,8 @@ function unzip(arr) {
866
855
  */
867
856
  function arrayGet(arr, index) {
868
857
  if (index < 0 || index >= arr.length)
869
- return Optional.empty();
870
- return Optional.of(arr[index]);
858
+ return OptionalClz.empty();
859
+ return OptionalClz.of(arr[index]);
871
860
  }
872
861
 
873
862
  function isTrue(x) {
@@ -1446,7 +1435,7 @@ const NEVER = new Promise(_resolve => { });
1446
1435
 
1447
1436
  /**
1448
1437
  * Returns a random integer in the range [min, max].
1449
- * @deprecated Use randomIntegerInInterval or randomDecimalInInterval instead
1438
+ * @deprecated[2026.03.17]: Use randomIntegerInInterval or randomDecimalInInterval instead.
1450
1439
  */
1451
1440
  function randomNumberInInterval(min, max) {
1452
1441
  return Math.floor(Math.random() * (max - min + 1) + min);
@@ -1501,8 +1490,6 @@ function entriesToDict(entries) {
1501
1490
  function entriesToEntries(dict, mapper) {
1502
1491
  return entriesToDict(dictToEntries(dict).map((entry) => mapper(entry)));
1503
1492
  }
1504
- /** @deprecated[2025.08.01]: Compatibility layer. */
1505
- const mapEntries = entriesToEntries;
1506
1493
  function entriesToList(dict, mapper) {
1507
1494
  return dictToEntries(dict).map((entry) => mapper(entry));
1508
1495
  }
@@ -2508,7 +2495,7 @@ class TimeInstant extends TimeBase {
2508
2495
  });
2509
2496
  }
2510
2497
  /**
2511
- * @deprecated [2025.10.19]: Use fromIso8601 instead.
2498
+ * @deprecated[2025.10.19]: Use fromIso8601 instead.
2512
2499
  */
2513
2500
  static tryFromIso8601 = this.fromIso8601;
2514
2501
  static now() {
@@ -4128,7 +4115,7 @@ exports.NEVER = NEVER;
4128
4115
  exports.NonExhaustiveSwitchError = NonExhaustiveSwitchError;
4129
4116
  exports.Operation = Operation;
4130
4117
  exports.OperationAggregateError = OperationAggregateError;
4131
- exports.Optional = Optional;
4118
+ exports.Optional = OptionalClz;
4132
4119
  exports.PredicateBuilder = PredicateBuilder;
4133
4120
  exports.RandomTimeDuration = RandomTimeDuration;
4134
4121
  exports.RateThrottler = RateThrottler;
@@ -4241,7 +4228,6 @@ exports.jsonCloneDeep = jsonCloneDeep;
4241
4228
  exports.last = last$1;
4242
4229
  exports.listToDict = listToDict;
4243
4230
  exports.mapDefined = mapDefined;
4244
- exports.mapEntries = mapEntries;
4245
4231
  exports.mapFirstTruthy = mapFirstTruthy;
4246
4232
  exports.mapTruthys = mapTruthys;
4247
4233
  exports.max = max;