@zelgadis87/utils-core 5.5.0-beta.1 → 5.5.0-beta.2

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.
@@ -115,6 +115,8 @@ declare class Optional<T> implements TOptional<T> {
115
115
  apply(callbackIfPresent: TConsumer<T>, callbackIfEmpty: TVoidFunction): any;
116
116
  orElseReturn(newValue: T): T;
117
117
  orElse: (newValue: T) => T;
118
+ orElseReturnNull(): T | null;
119
+ orElseReturnUndefined(): T | undefined;
118
120
  orElseProduce(newValueProducer: TProducer<T>): T;
119
121
  orElseGet: (newValueProducer: TProducer<T>) => T;
120
122
  orElseReturnAndApply(newValue: T): T;
@@ -194,6 +196,8 @@ type TEmptyOptional<T> = TOptional<T> & {
194
196
  flatMapTo<R>(mapper: TFunction<T, TOptional<R>>): TEmptyOptional<T>;
195
197
  filter(predicate: TPredicate<T>): TEmptyOptional<T>;
196
198
  orElseReturn: <R>(newValue: R) => R;
199
+ orElseReturnNull(): null;
200
+ orElseReturnUndefined(): undefined;
197
201
  orElseProduce: <R>(newValueProducer: TProducer<R>) => R;
198
202
  orElseReturnNullable: <R>(newValue: R | null | undefined) => TOptional<R>;
199
203
  orElseProduceNullable: <R>(newValueProducer: TProducer<R | null | undefined>) => TOptional<R>;
@@ -210,6 +214,8 @@ type TPresentOptional<T> = TOptional<T> & {
210
214
  mapTo<R>(mapper: TFunction<T, R>): TPresentOptional<R>;
211
215
  flatMapTo<R>(mapper: TFunction<T, TOptional<R>>): TOptional<R>;
212
216
  orElseReturn: (newValue: T) => T;
217
+ orElseReturnNull(): T;
218
+ orElseReturnUndefined(): T;
213
219
  orElseProduce: (newValueProducer: TProducer<T>) => T;
214
220
  orElseReturnNullable: (newValue: T | null | undefined) => TOptional<T>;
215
221
  orElseProduceNullable: (newValueProducer: TProducer<T | null | undefined>) => TOptional<T>;
package/.rollup/index.mjs CHANGED
@@ -283,6 +283,12 @@ class Optional {
283
283
  }
284
284
  }
285
285
  orElse = this.orElseReturn.bind(this);
286
+ orElseReturnNull() {
287
+ return this.isPresent() ? this.get() : null;
288
+ }
289
+ orElseReturnUndefined() {
290
+ return this.isPresent() ? this.get() : undefined;
291
+ }
286
292
  orElseProduce(newValueProducer) {
287
293
  if (this.isPresent()) {
288
294
  return this.get();