@zelgadis87/utils-core 4.6.2 → 4.7.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/esbuild/index.mjs CHANGED
@@ -1963,13 +1963,16 @@ var Optional = class _Optional {
1963
1963
  this._value = defined ? t : void 0;
1964
1964
  this._present = defined;
1965
1965
  }
1966
- get rawValue() {
1966
+ getRawValue() {
1967
1967
  return this._value;
1968
1968
  }
1969
1969
  get() {
1970
+ return this.getOrElseThrow(() => new ErrorGetEmptyOptional());
1971
+ }
1972
+ getOrElseThrow(errorProducer) {
1970
1973
  if (this.isEmpty())
1971
- throw new ErrorGetEmptyOptional();
1972
- return this.rawValue;
1974
+ throw errorProducer();
1975
+ return this._value;
1973
1976
  }
1974
1977
  set(t) {
1975
1978
  if (isNullOrUndefined(t))
@@ -1993,13 +1996,13 @@ var Optional = class _Optional {
1993
1996
  }
1994
1997
  ifPresent(callback) {
1995
1998
  if (this.isPresent())
1996
- callback(this.rawValue);
1999
+ callback(this.get());
1997
2000
  }
1998
2001
  apply(callbackIfPresent, callbackIfEmpty) {
1999
2002
  if (this.isEmpty()) {
2000
2003
  callbackIfEmpty();
2001
2004
  } else {
2002
- callbackIfPresent(this.rawValue);
2005
+ callbackIfPresent(this.get());
2003
2006
  }
2004
2007
  }
2005
2008
  orElse(newValue) {
@@ -2014,31 +2017,23 @@ var Optional = class _Optional {
2014
2017
  }
2015
2018
  return this;
2016
2019
  }
2017
- orElseThrow(produceError) {
2020
+ orElseThrow(errorProducer) {
2018
2021
  if (this.isEmpty())
2019
- throw produceError();
2022
+ throw errorProducer();
2020
2023
  return this;
2021
2024
  }
2022
2025
  mapTo(mapper) {
2023
2026
  return this.flatMapTo((t) => _Optional.ofNullable(mapper(t)));
2024
2027
  }
2025
2028
  flatMapTo(mapper) {
2026
- if (this.isPresent()) {
2027
- const newValue = mapper(this.rawValue);
2028
- return newValue;
2029
- }
2030
- return this;
2029
+ return this.isPresent() ? mapper(this.get()) : _Optional.empty();
2031
2030
  }
2032
2031
  filter(predicate) {
2033
- if (this.isPresent()) {
2034
- if (predicate(this.rawValue)) {
2035
- return this;
2036
- } else {
2037
- return _Optional.empty();
2038
- }
2039
- } else {
2032
+ if (this.isEmpty())
2040
2033
  return this;
2041
- }
2034
+ if (predicate(this.get()))
2035
+ return this;
2036
+ return _Optional.empty();
2042
2037
  }
2043
2038
  static empty() {
2044
2039
  return new _Optional(void 0);
@@ -2054,7 +2049,7 @@ var Optional = class _Optional {
2054
2049
  };
2055
2050
  var ErrorGetEmptyOptional = class extends Error {
2056
2051
  constructor() {
2057
- super("Cannot retrieve a value from an EmptyOptional.");
2052
+ super("Cannot retrieve a value from an empty Optional.");
2058
2053
  }
2059
2054
  };
2060
2055
  var ErrorSetEmptyOptional = class extends Error {