simple-optional 1.0.1 → 1.1.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.
@@ -4,6 +4,7 @@ export declare class Optional<T> {
4
4
  static of<T>(value: T): Optional<T>;
5
5
  static ofNullable<T>(value: T | null): Optional<T>;
6
6
  static empty<T>(): Optional<T>;
7
+ static require<T>(value: T | null | undefined): T;
7
8
  isEmpty(): boolean;
8
9
  isPresent(): boolean;
9
10
  ifPresent(consumer: (value: T) => void): void;
package/dist/optional.js CHANGED
@@ -17,6 +17,9 @@ class Optional {
17
17
  static empty() {
18
18
  return new Optional(null);
19
19
  }
20
+ static require(value) {
21
+ return Optional.ofNullable(value !== null && value !== void 0 ? value : null).get();
22
+ }
20
23
  isEmpty() {
21
24
  return !this.isPresent();
22
25
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "simple-optional",
3
- "version": "1.0.1",
3
+ "version": "1.1.0",
4
4
  "description": "Simplified Optional container inspired by Java 8 implementation.",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",