@zelgadis87/utils-core 5.0.3 → 5.0.4

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
@@ -2077,6 +2077,12 @@ var Optional = class _Optional {
2077
2077
  this._value = t;
2078
2078
  this._present = true;
2079
2079
  }
2080
+ setNullable(t) {
2081
+ if (isDefined(t)) {
2082
+ return this.set(t);
2083
+ }
2084
+ return this;
2085
+ }
2080
2086
  clear() {
2081
2087
  this._value = void 0;
2082
2088
  this._present = false;
@@ -2102,31 +2108,69 @@ var Optional = class _Optional {
2102
2108
  callbackIfPresent(this.get());
2103
2109
  }
2104
2110
  }
2105
- orElse(newValue) {
2111
+ orElseReturn(newValue) {
2106
2112
  if (this.isPresent()) {
2107
- return this._value;
2113
+ return this.get();
2108
2114
  } else {
2109
2115
  return newValue;
2110
2116
  }
2111
2117
  }
2112
- orElseGet(newValueProducer) {
2118
+ orElse = this.orElseReturn.bind(this);
2119
+ orElseProduce(newValueProducer) {
2113
2120
  if (this.isPresent()) {
2114
- return this._value;
2121
+ return this.get();
2115
2122
  } else {
2116
2123
  return newValueProducer();
2117
2124
  }
2118
2125
  }
2119
- orElseNullable(newValue) {
2126
+ orElseGet = this.orElseProduce.bind(this);
2127
+ orElseReturnAndApply(newValue) {
2128
+ if (this.isPresent()) {
2129
+ return this.get();
2130
+ } else {
2131
+ this.set(newValue);
2132
+ return newValue;
2133
+ }
2134
+ }
2135
+ orElseProduceAndApply(newValueProducer) {
2136
+ if (this.isPresent()) {
2137
+ return this.get();
2138
+ } else {
2139
+ const newValue = newValueProducer();
2140
+ this.set(newValue);
2141
+ return newValue;
2142
+ }
2143
+ }
2144
+ orElseReturnNullableAndApply(newValue) {
2145
+ if (this.isPresent()) {
2146
+ return this;
2147
+ } else {
2148
+ this.setNullable(newValue);
2149
+ return this;
2150
+ }
2151
+ }
2152
+ orElseProduceNullableAndApply(newValueProducer) {
2153
+ if (this.isPresent()) {
2154
+ return this;
2155
+ } else {
2156
+ const newValue = newValueProducer();
2157
+ this.setNullable(newValue);
2158
+ return this;
2159
+ }
2160
+ }
2161
+ orElseReturnNullable(newValue) {
2120
2162
  if (this.isEmpty()) return _Optional.ofNullable(newValue);
2121
2163
  return this;
2122
2164
  }
2123
- orElseGetNullable(newValueProducer) {
2165
+ orElseNullable = this.orElseReturnNullable.bind(this);
2166
+ orElseProduceNullable(newValueProducer) {
2124
2167
  if (this.isEmpty()) {
2125
2168
  const newValue = newValueProducer();
2126
2169
  return _Optional.ofNullable(newValue);
2127
2170
  }
2128
2171
  return this;
2129
2172
  }
2173
+ orElseGetNullable = this.orElseProduceNullable.bind(this);
2130
2174
  orElseThrow(errorProducer) {
2131
2175
  if (this.isEmpty())
2132
2176
  throw errorProducer();